Set Data source for the chart

In our previous topics, we have already provided many examples to demonstrate that how can you set a data source for your chart but in this topic, we are going to provide more details about the types of data that can be set for a chart.

Setting Chart Data

There are two types of data to deal with while working on charts using Aspose.Cells as follows:

  • Chart data.
  • Category data.

Chart Data

Chart data is the data that we use as a data source to build our charts. We can add a range of the cells (containing chart data) by calling the SeriesCollection object’s Add method.

Category Data

Category data is used for the labeling of chart data and can be added to SeriesCollection by using its CategoryData property. A complete example is given below to demonstrate the use of chart and category data. After executing the above example code, a column chart will be added to the worksheet as shown below.

Advance topics

  • Change Data Source of the Chart to Destination Worksheet while Copying Rows or Range
  • Create Dynamic Charts
  • Easy way for Chart Setup using Chart.SetChartDataRange method
  • Find Type of X and Y Values of Points in Chart Series