Your search did not match any results.

Line

Line charts help visualize data and display them as lines with points placed over specified intervals. This demo shows how to initialize and configure Line, Stacked Line, and Full-Stacked Line charts. A Stacked Line chart visualizes multiple data series and allows you to compare the manner in which each series contributes to the total aggregate value for specific arguments. A Full-Stacked Line chart helps compare the percentage value of multiple line series for each argument. Use the drop-down menu under the chart to switch between chart types.

Bind to Data

You can bind line charts to one of the following data sources:

In this demo, the chart is populated with data from a local JavaScript array.

Configure Series

The series type defines the appearance of your chart. To display a Line, Stacked Line, or Full-Stacked Line series, set the type property to one of these types.

You also need to bind the series to data. Set the argumentField and valueField properties to data fields that contain arguments and values for your series. You can specify these properties in an object in the series array or include them in the commonSeriesSettings object. In this demo, the argumentField and type properties are specified for all series in the commonSeriesSettings object.

Enable Tooltips

When you hover the mouse pointer over a series point, it shows a tooltip with information about the series point. To display tooltips, you need to enable the tooltip.enabled property.

Export Chart to Image

To allow a user to print the chart or export it as a PNG, JPEG, or SVG file, set the export.enabled property to true. This setting adds a button that opens a drop-down menu with export and print commands. In this demo, you can find this button in the upper-right corner.

Backend API
<div id="chart-demo"> @(Html.DevExtreme().Chart() .ID("line-chart") .Palette(VizPalette.Violet) .CommonSeriesSettings(s => s .ArgumentField("Country") .Type(SeriesType.Line) ) .Margin(m => m.Bottom(20)) .ArgumentAxis(a => a .ValueMarginsEnabled(false) .DiscreteAxisDivisionMode(DiscreteAxisDivisionMode.CrossLabels) .Grid(g => g.Visible(true)) ) .Series(s => { s.Add().ValueField("Hydro").Name("Hydro-electric"); s.Add().ValueField("Oil").Name("Oil"); s.Add().ValueField("Gas").Name("Natural gas"); s.Add().ValueField("Coal").Name("Coal"); s.Add().ValueField("Nuclear").Name("Nuclear"); }) .Legend(l => l .VerticalAlignment(VerticalEdge.Bottom) .HorizontalAlignment(HorizontalAlignment.Center) .ItemTextPosition(Position.Bottom) ) .Title(t => t .Text("Energy Consumption in 2004") .Subtitle(s => s.Text("(Millions of Tons, Oil Equivalent)")) ) .Export(e => e.Enabled(true)) .Tooltip(t => t.Enabled(true)) .DataSource(new[] { new { Country = "USA", Hydro = 71.2, Oil = 910.4, Gas = 483.2, Coal = 564.3, Nuclear = 216.1 }, new { Country = "China", Hydro = 72.5, Oil = 223.6, Gas = 36.0, Coal = 956.9, Nuclear = 11.3 }, new { Country = "Russia", Hydro = 47.7, Oil = 149.4, Gas = 432.3, Coal = 105.0, Nuclear = 29.3 }, new { Country = "Japan", Hydro = 17.9, Oil = 283.6, Gas = 61.8, Coal = 120.8, Nuclear = 52.8 }, new { Country = "India", Hydro = 14.4, Oil = 86.4, Gas = 25.1, Coal = 204.8, Nuclear = 3.8 }, new { Country = "Germany", Hydro = 6.6, Oil = 101.7, Gas = 92.7, Coal = 85.7, Nuclear = 30.8 } }) ) <div class="options"> <div class="caption">Options</div> <div class="option"> <span>Series Type</span> @(Html.DevExtreme().SelectBox() .DataSource(new[] { SeriesType.Line, SeriesType.StackedLine, SeriesType.FullStackedLine }) .Value(SeriesType.Line) .InputAttr("aria-label", "Series Type") .OnValueChanged(@<text> function (e) { $("#line-chart").dxChart("option", "commonSeriesSettings.type", e.value); } </text>) ) </div> </div> </div>
using DevExtreme.AspNet.Data; using DevExtreme.AspNet.Mvc; using DevExtreme.NETCore.Demos.Models; using DevExtreme.NETCore.Demos.Models.SampleData; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; namespace DevExtreme.NETCore.Demos.Controllers { public class ChartsController : Controller { public ActionResult Line() { return View(); } } }
.options { padding: 20px; background-color: rgba(191, 191, 191, 0.15); margin-top: 20px; } .option { margin-top: 10px; } .caption { font-size: 18px; font-weight: 500; } .option > span { margin-right: 10px; } .option > .dx-widget { display: inline-block; vertical-align: middle; }