Your search did not match any results.

Charts - Stacked Bar

This demo shows the stacked bar series type that visualizes data as columns stacked over each other. You can use this series type to compare values of an individual series with total values aggregated for each argument.

www.wikipedia.org
Backend API
@(Html.DevExtreme().Chart() .ID("chart") .CommonSeriesSettings(s => s .ArgumentField("State") .Type(SeriesType.StackedBar) ) .Series(s => { s.Add().ValueField("Young").Name("0-14"); s.Add().ValueField("Middle").Name("15-64"); s.Add().ValueField("Older").Name("65 and older"); }) .Legend(l => l .VerticalAlignment(VerticalEdge.Bottom) .HorizontalAlignment(HorizontalAlignment.Center) .ItemTextPosition(Position.Top) ) .ValueAxis(a => a .Add() .Title(t => t.Text("millions")) .Position(Position.Right) ) .Title("Male Age Structure") .Export(e => e.Enabled(true)) .Tooltip(t => t .Enabled(true) .Location(ChartTooltipLocation.Edge) .CustomizeTooltip(@<text> function(arg) { return { text: arg.seriesName + " years: " + arg.valueText }; } </text>) ) .DataSource(new[] { new { State = "Germany", Young = 5.3, Middle = 26.0, Older = 8.0 }, new { State = "Japan", Young = 6.45, Middle = 30.5, Older = 11.22 }, new { State = "Russia", Young = 12.56, Middle = 45.5, Older = 6.5 }, new { State = "USA", Young = 32.0, Middle = 87.0, Older = 15.0 } }) )
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 StackedBar() { return View(); } } }
#chart { height: 440px; }

Bind to Data

In this demo, series is bound to data directly. See the Bind Series to Data article for information. The "state" field name is assigned to the argumentField property of the commonSeriesSettings object since the stacked bar chart contains series with the same argument field.

Specify Common Series Settings

To configure settings for all series in the chart, use the commonSeriesSettings object. For example, specify the series type.

Customize Stacked Bar Chart

Use the verticalAlignment and horizontalAlignment properties of the legend object to specify the legend position in the chart. You can specify the text's position relative to the marker in a legend item in the itemTextPosition property.

To configure tooltips in the chart, use the tooltip object. To enable the tooltips, assign true to the enabled property of this object. If you want to customize a specific tooltip, assign a function to the customizeTooltip property. In this demo, the function returns the tooltip's text that shows the series name and point value.