[]
        
(Showing Draft Content)

Bar Chart

Bar charts compare categorical data through horizontal bars, where length of each bar represents the value of the corresponding category. In bar charts, categories are organized along the vertical axis and data values along the horizontal axis. For example, sales of various product categories can be presented through a bar chart.

DsExcel supports the following types of bar charts.

Chart Type

Chart Snapshot

Use Case

BarClustered

DsExcel chart output displaying the barclusteredchart result created with ChartType.BarClusteredChart for developers visualizing worksheet data in the corresponding chart format.

BarClustered Chart can be used to display the comparisons of values across different categories.

BarClustered3D

DsExcel chart output displaying the barclustered3dchart result created with ChartType.BarClustered3DChart for developers visualizing worksheet data in the corresponding chart format.

BarClustered3D chart is used to display the chart demonstration in 3D,which is a modification of 2DBarClustered chart. It does not have a third dimension, it only looks volumetric in appearance.

BarStacked

DsExcel chart output displaying the barstackedchart result created with ChartType.BarStackedChart for developers visualizing worksheet data in the corresponding chart format.

BarStacked chart is used to display the relationship of each item/category to the whole in two-dimensional and three-dimensional rectangles.

BarStacked3D

DsExcel chart output displaying the barstacked3dchart result created with ChartType.BarStacked3DChart for developers visualizing worksheet data in the corresponding chart format.

BarStacked3D chart is used to represent the BarStacked chart demonstration in 3D,which looks volumetric in appearance.

BarStacked100

DsExcel chart output displaying the barstacked100chart result created with ChartType.BarStacked100Chart for developers visualizing worksheet data in the corresponding chart format.

BarStacked100 chart is used to display the comparisons of percentage that each of the values contribute to the total across different categories.

BarStacked1003D

DsExcel chart output displaying the barstacked1003dchart result created with ChartType.BarStacked1003DChart for developers visualizing worksheet data in the corresponding chart format.

BarStacked1003D chart is used to represent the BarStacked100 chart demonstration in 3D, which is a modification of 2D chart in appearance.

Using Code

Refer to the following example code to add Bar Stacked Chart:

public void BarCharts()
  {
      // Initialize workbook
      Workbook workbook = new Workbook();
      // Fetch default worksheet 
      IWorksheet worksheet = workbook.Worksheets[0];
      // Prepare data for chart
      worksheet.Range["A1:D4"].Value = new object[,]
      {
           {null, "Q1", "Q2", "Q3"},
           {"Mobile Phones", 1330, 2345, 3493},
           {"Laptops", 2032, 3632, 2197},
           {"Tablets", 6233, 3270, 2030}
      };
      worksheet.Range["A:D"].Columns.AutoFit();
      // Add BarStacked Chart
      IShape barChartshape = worksheet.Shapes.AddChart(ChartType.BarStacked, 250, 20, 360, 230);

      // Adding series to SeriesCollection
      barChartshape.Chart.SeriesCollection.Add(worksheet.Range["A1:D4"], RowCol.Columns, true, true);

      // Configure Chart Title 
      barChartshape.Chart.ChartTitle.TextFrame.TextRange.Paragraphs.Add("Annual Sales Record");

      // Saving workbook to Xlsx
      workbook.Save(@"19-BarChart.xlsx", SaveFileFormat.Xlsx);
  }