Chart Formatting

Format Chart Entities

Aspose.Slides for .NET lets developers add custom charts to their slides from scratch. This article explains how to format different chart entities including chart category and value axis.

Aspose.Slides for .NET provides a simple API for managing different chart entities and formatting them using custom values:

  1. Create an instance of the Presentation class.
  2. Obtain a slide’s reference by its index.
  3. Add a chart with default data along with the any of desired type (in this example we will use ChartType.LineWithMarkers).
  4. Access the chart Value Axis and set the following properties:
    1. Setting Line format for Value Axis Major Grid lines
    2. Setting Line format for Value Axis Minor Grid lines
    3. Setting Number Format for Value Axis
    4. Setting Min, Max, Major and Minor units for Value Axis
    5. Setting Text Properties for Value Axis data
    6. Setting Title for Value Axis
    7. Setting Line Format for Value Axis
  5. Access the chart Category Axis and set the following properties:
    1. Setting Line format for Category Axis Major Grid lines
    2. Setting Line format for Category Axis Minor Grid lines
    3. Setting Text Properties for Category Axis data
    4. Setting Title for Category Axis
    5. Setting Label Positioning for Category Axis
    6. Setting Rotation Angle for Category Axis labels
  6. Access the chart Legend and set the Text Properties for them
  7. Set show chart Legends without overlapping chart
  8. Access the chart Secondary Value Axis and set the following properties:
    1. Enable the Secondary Value Axis
    2. Setting Line Format for Secondary Value Axis
    3. Setting Number Format for Secondary Value Axis
    4. Setting Min, Max, Major and Minor units for Secondary Value Axis
  9. Now plot the first chart series on Secondary Value Axis
  10. Set the chart back wall fill color
  11. Set the chart plot area fill color
  12. Write the modified presentation to a PPTX file

Set Font Properties for Chart

Aspose.Slides for .NET provides support for setting the font related properties for the chart. Please follow the steps below for setting the font properties for chart.

  • Instantiate Presentation class object.
  • Add chart on the slide.
  • Set font height.
  • Save modified presentation.

Below sample example is given.

Set Format of Numerics

Aspose.Slides for .NET provides a simple API for managing chart data format:

  1. Create an instance of the Presentation class.
  2. Obtain a slide’s reference by its index.
  3. Add a chart with default data along with the any of desired type (this example uses ChartType.ClusteredColumn).
  4. Set the preset number format from the possible preset values.
  5. Traverse through the chart data cell in every chart series and set the chart data number format.
  6. Save the presentation.
  7. Set the custom number format.
  8. Traverse through chart data cell inside every chart series and setting a different chart data number format.
  9. Save the presentation.

The possible preset number format values along with their preset index and that can be used are given below:

0General
10
20.00
3#,##0
4#,##0.00
5$#,##0;$-#,##0
6$#,##0;Red$-#,##0
7$#,##0.00;$-#,##0.00
8$#,##0.00;Red$-#,##0.00
90%
100.00%
110.00E+00
12# ?/?
13# /
14m/d/yy
15d-mmm-yy
16d-mmm
17mmm-yy
18h:mm AM/PM
19h:mm:ss AM/PM
20h:mm
21h:mm:ss
22m/d/yy h:mm
37#,##0;-#,##0
38#,##0;Red-#,##0
39#,##0.00;-#,##0.00
40#,##0.00;Red-#,##0.00
41_ * #,##0_ ;_ * “_ ;_ @_
42_ $* #,##0_ ;_ $* “_ ;_ @_
43_ * #,##0.00_ ;_ * “??_ ;_ @_
44_ $* #,##0.00_ ;_ $* “??_ ;_ @_
45mm:ss
46h :mm:ss
47mm:ss.0
48##0.0E+00
49@

Set Chart Area Rounded Borders

Aspose.Slides for .NET provides support for setting chart area. IChart.HasRoundedCorners and Chart.HasRoundedCorners properties have been added in Aspose.Slides. 

  1. Instantiate Presentation class object.
  2. Add chart on the slide.
  3. Set fill type and fill color of chart
  4. Set round corner property True.
  5. Save modified presentation.

Below sample example is given.