Adding a Bar Chart
Spread WinRT Documentation > Developer's Guide > Working with Charts > Creating Charts > Creating Chart Types > Adding a Bar Chart

You can create many different types of bar charts such as BarClustered, BarStacked, BarStacked100pc, BarStacked100pc3D, and BarStacked3D. The following image displays a stacked bar chart.

Using Code

The following sample creates a stacked bar chart.

  1. Create values and add the values to the control with the SetArray method.
  2. Create a chart and specify the chart type with the SpreadChart class.
  3. Add the chart using the Charts property.
CS
Copy Code
GrapeCity.Xaml.SpreadSheet.Data.SpreadChart chart = new GrapeCity.Xaml.SpreadSheet.Data.SpreadChart("Chart", GrapeCity.Xaml.SpreadSheet.Data.SpreadChartType.BarStacked, "Sheet1!$A$1:$A$7", 0, 0, 200, 200);
gcSpreadSheet1.ActiveSheet.SetArray(0, 0, new object[,] { { 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 }, { 10 } });
gcSpreadSheet1.ActiveSheet.Charts.Add(chart);
VB
Copy Code
Dim chart As New GrapeCity.Xaml.SpreadSheet.Data.SpreadChart("Chart", GrapeCity.Xaml.SpreadSheet.Data.SpreadChartType.BarStacked, "Sheet1!$A$1:$A$7", 0, 0, 200, 200)
GcSpreadSheet1.ActiveSheet.SetArray(0, 0, New Object(,) {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}})
GcSpreadSheet1.ActiveSheet.Charts.Add(chart)