Creating and Customizing Charts
Possible Usage Scenarios
A chart is a visual display of information. Aspose.Cells allows developers to visualize information in charts just as Microsoft Excel does. Presenting information in charts is always helpful to decision-makers for making quick and timely decisions. It’s easier to quickly see comparisons, patterns, and trends in data with charts rather than raw numbers. Creating charts at runtime, based on the data in a spreadsheet, is one of Aspose.Cells’ useful feature. Aspose.Cells supports creating both Standard and Customized charts. Below, we will show a few examples with sample files on how to create some common MS-Excel chart types using Aspose.Cells API.
When the example code is executed, a pyramid chart is added to the worksheet. Please see the output Excel file of the following sample code.
In the above example, simply changing the ChartType to ChartType_Line creates a line chart. The complete source is provided below. when the code is executed, a line chart is added to the worksheet. Please see the output Excel file of the following sample code.
In order to create a bubble chart, the ChartType has to be set to ChartType_Bubble and few extra properties such as SetBubbleSizes & SetXValues need to be set accordingly. Upon executing the following code, a bubble chart is added to the worksheet. Please see the output Excel file of the following sample code.
Creating Custom Charts
So far, when we’ve discussed charts, we’ve looked at standard charts that have their own standard formatting settings. We only define the data source, set a few properties and the chart is created with its default format settings. But Aspose.Cells APIs also supports creating custom charts that allow developers to create charts with their own format settings. Developers can create custom charts at run-time using Aspose.Cells.
A chart is composed of a data series. When creating a custom chart, developers have the freedom to use different types of charts for different data series.
The example code below demonstrates how to create custom charts. In this example, we are going to use a column chart for the first data series and a line chart for the second series. The result is that we add a column chart, combined with a line chart, to the worksheet. Please see the output Excel file of the following sample code.