- Online Barcode Generator
- How To
- Buy Now
If you want to display and compare the results of multiple data series, you may use this clustered stacked chart type. And with this stacked chart of ASP.NET AJAX, you can easily create a stacked bar chart, stacked spline area chart or stacked area chart. And this page will guide you to add a stacked bar chart in ASP.NET application using C# code. And the creating process applies well to both stacked spline area chart and stacked area chart.
Before conducting following settings, please drag an AjaxPanel item from toolbox to aspx web page and also drag a chart control to that AjaxPanel first.
Sample C# Code for Setting Chart Type
To set the chart type, you can add following C# code to your aspx.cs file. Here two methods are offered and both can make the chart extended in the form of stacked bar chart.
Sample C# Code for Setting Chart Skin
You can choose different skin and template for your web stacked bar chart graph. You can view the total data in one column of the stacked bar chart, each data item take some area of column according to the data content.
KaxChart1.Skin = "KetticStyle";
Set Stacked Bar Chart Title in C# Code
You are free to add and modify the title of stacked bar chart using following sample C# code, rotating, reiszing the web chart title is supported. And if you want to make the title link to other html page, you can also define the url property. More chart title elements can be found at setting chart title element in c#.
Set Stacked Bar Chart Orientation Using C# Code
You can create the stacked bar chart either vertically or horizontally.
KaxChart1.SeriesOrientation = ChartSeriesOrientation.Horizontal;
Stacked Bar Settings
Define Stacked Bar Chart Series in C#
The C# code below is used to add two data series into created stacked bar chart. Of course, you can add multiple data series by using the property KaxChart1.Series. And each data series can have different items, which is control by the property AddItem(). To view more tutorial, please follow this link to set chart series element using c#.
Using above sample C# code, we could easily add two data categories to source stacked bar chart. Now to enhance the chart visual effect, we can set each bar group with different colors. Then we can display the differences between different data series in a more vivid way. Besides, you can sort the groups of data to make the wanted order to show them. Then the web chart report will display the bars as you ordered, so you can make easy analysis to these data values.
Set Chart Axis Using C# Code
In the real life application, to make our chart be better viewed and more easily understood, we need to customize the axis scaling and spacing of created stacked bar chart based on our source data value. For instance, if the scaling is much bigger than the data value, the whole chart will be too small to analyze. Since the axis contains x axis and y axis, we need to set the two dimensions respectively. More settings guidance, please follow the link to chart axis at set chart axis element with c#.
After you finish the basic and stacked bar settings using above sample C# code, you can easily create a simple stacked bar chart in ASP.NET web application. Of course, you can also view the final output of the sample stacked bar chart by running our Stackedbar chart online demo.
ASP.NET AJAX UI Controls