100% Stacked Column in ASP.NET MVC Charts Component
4 Oct 202311 minutes to read
100% Stacked column
To render a 100% stacked column series, use series Type
as StackingColumn100
.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("yValue").
DataSource(ViewBag.dataSource).
Name("Gold").
Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("yValue1").
DataSource(ViewBag.dataSource).
Name("Silver").
Add();
})
.PrimaryXAxis(px =>
px.Interval(1)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.IsIndexed(true)
)
.Title("Olympic Medal Counts - RIO").Render()
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x= "USA", yValue= 46, yValue1=56 },
new ChartData { x= "GBR", yValue= 27, yValue1=17 },
new ChartData { x= "CHN", yValue= 26, yValue1=36 },
new ChartData { x= "UK", yValue= 56, yValue1=16 },
new ChartData { x= "AUS", yValue= 12, yValue1=46 },
new ChartData { x= "IND", yValue= 26, yValue1=16 },
new ChartData { x= "DEN", yValue= 26, yValue1=12 },
new ChartData { x= "MEX", yValue= 34, yValue1=32},
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double yValue;
public double yValue1;
}
100% Cylindrical stacked column chart
To render a 100% cylindrical stacked column chart, set the ColumnFacet
property to Cylinder
in the chart series.
@(Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("y").
Name("UK").
ColumnFacet(Syncfusion.EJ2.Charts.ShapeType.Cylinder).
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("y1").
Name("Germany").
ColumnFacet(Syncfusion.EJ2.Charts.ShapeType.Cylinder).
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("y2").
Name("France").
ColumnFacet(Syncfusion.EJ2.Charts.ShapeType.Cylinder).
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("y3").
Name("Italy").
ColumnFacet(Syncfusion.EJ2.Charts.ShapeType.Cylinder).
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.Interval(1)
.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime)
.Title("Years")
.LabelFormat("y")
)
.PrimaryYAxis(py =>
py.Title("GDP (%) Per Annum")
.LabelFormat("{value}%")
.RangePadding(Syncfusion.EJ2.Charts.ChartRangePadding.None)
)
.Title("Gross Domestic Product Growth")
.Render())
public ActionResult Index()
{
List<CylindricalChartData> chartData = new List<CylindricalChartData>
{
new CylindricalChartData { x= new DateTime(2006, 01, 01), y= 900, y1= 190, y2= 250, y3= 150 },
new CylindricalChartData { x= new DateTime(2007, 01, 01), y= 544, y1= 226, y2= 145, y3= 120 },
new CylindricalChartData { x= new DateTime(2008, 01, 01), y= 880, y1= 194, y2= 190, y3= 115 },
new CylindricalChartData { x= new DateTime(2009, 01, 01), y= 675, y1= 250, y2= 220, y3= 125 },
new CylindricalChartData { x= new DateTime(2010, 01, 01), y= 765, y1= 222, y2= 225, y3= 132 },
new CylindricalChartData { x= new DateTime(2011, 01, 01), y= 679, y1= 181, y2= 135, y3= 137 },
new CylindricalChartData { x= new DateTime(2012, 01, 01), y= 770, y1= 128, y2= 152, y3= 110 }
};
ViewBag.dataSource = chartData;
return View();
}
public class CylindricalChartData
{
public DateTime x;
public double y;
public double y1;
public double y2;
public double y3;
}
Series customization
The following properties can be used to customize the 100% Stacked Column
series.
- Fill – Specifies the color of the series.
- Opacity – Specifies the opacity of Fill.
- DashArray – Specifies the dashes for series.
-
ChartSeriesBorder – Specifies the
Color
andWidth
of series border.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("yValue").
DashArray("5,5").
Fill("red").
Opacity(0.7).
StackingGroup("Asia").
Border(br => br.Width(2).Color("black")).
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.StackingColumn100).
XName("x").
YName("yValue1").
DashArray("5,5").
Fill("blue").
Opacity(0.7).
StackingGroup("Asia").
Border(br => br.Width(2).Color("black")).
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category))
.Render()
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x= "USA", yValue= 46, yValue1=56 },
new ChartData { x= "GBR", yValue= 27, yValue1=17 },
new ChartData { x= "CHN", yValue= 26, yValue1=36 },
new ChartData { x= "UK", yValue= 56, yValue1=16 },
new ChartData { x= "AUS", yValue= 12, yValue1=46 },
new ChartData { x= "IND", yValue= 26, yValue1=16 },
new ChartData { x= "DEN", yValue= 26, yValue1=12 },
new ChartData { x= "MEX", yValue= 34, yValue1=32},
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double yValue;
public double yValue1;
}