com.aspose.words

Class ChartType

  • java.lang.Object
    • com.aspose.words.ChartType
public class ChartType 
extends java.lang.Object

Utility class containing constants. Specifies type of a chart.

Example:

Shows an appropriate graph type for each chart series.
public void chartSeriesCollection() throws Exception {
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    // There are 4 ways of populating a chart's series collection
    // 1: Each series has a string array of categories, each with a corresponding data value
    // Some of the other possible applications are bar, column, line and surface charts
    Chart chart = appendChart(builder, ChartType.COLUMN, 300.0, 300.0);

    // Create and name 3 categories with a string array
    String[] categories = {"Category 1", "Category 2", "Category 3"};

    // Create 2 series of data, each with one point for every category
    // This will generate a column graph with 3 clusters of 2 bars
    chart.getSeries().add("Series 1", categories, new double[]{76.6, 82.1, 91.6});
    chart.getSeries().add("Series 2", categories, new double[]{64.2, 79.5, 94.0});

    // Categories are distributed along the X-axis while values are distributed along the Y-axis
    Assert.assertEquals(chart.getAxisX().getType(), ChartAxisType.CATEGORY);
    Assert.assertEquals(chart.getAxisY().getType(), ChartAxisType.VALUE);

    // 2: Each series will have a collection of dates with a corresponding value for each date
    // Area, radar and stock charts are some of the appropriate chart types for this
    chart = appendChart(builder, ChartType.AREA, 300.0, 300.0);

    // Create a collection of dates to serve as categories
    Date[] dates = {DocumentHelper.createDate(2014, 3, 31),
            DocumentHelper.createDate(2017, 1, 23),
            DocumentHelper.createDate(2017, 6, 18),
            DocumentHelper.createDate(2019, 11, 22),
            DocumentHelper.createDate(2020, 9, 7)
    };

    // Add one series with one point for each date
    // Our sporadic dates will be distributed along the X-axis in a linear fashion 
    chart.getSeries().add("Series 1", dates, new double[]{15.8, 21.5, 22.9, 28.7, 33.1});

    // 3: Each series will take two data arrays
    // Appropriate for scatter plots
    chart = appendChart(builder, ChartType.SCATTER, 300.0, 300.0);

    // In each series, the first array contains the X-coordinates and the second contains respective Y-coordinates of points
    chart.getSeries().add("Series 1", new double[]{3.1, 3.5, 6.3, 4.1, 2.2, 8.3, 1.2, 3.6}, new double[]{3.1, 6.3, 4.6, 0.9, 8.5, 4.2, 2.3, 9.9});
    chart.getSeries().add("Series 2", new double[]{2.6, 7.3, 4.5, 6.6, 2.1, 9.3, 0.7, 3.3}, new double[]{7.1, 6.6, 3.5, 7.8, 7.7, 9.5, 1.3, 4.6});

    // Both axes are value axes in this case
    Assert.assertEquals(chart.getAxisX().getType(), ChartAxisType.VALUE);
    Assert.assertEquals(chart.getAxisY().getType(), ChartAxisType.VALUE);

    // 4: Each series will be built from three data arrays, used for bubble charts
    chart = appendChart(builder, ChartType.BUBBLE, 300.0, 300.0);

    // The first two arrays contain X/Y coordinates like above and the third determines the thickness of each point
    chart.getSeries().add("Series 1", new double[]{1.1, 5.0, 9.8}, new double[]{1.2, 4.9, 9.9}, new double[]{2.0, 4.0, 8.0});

    doc.save(getArtifactsDir() + "Charts.ChartSeriesCollection.docx");
}

/// <summary>
/// Get the DocumentBuilder to insert a chart of a specified ChartType, width and height and clean out its default data
/// </summary>
private Chart appendChart(DocumentBuilder builder, /*ChartType*/int chartType, double width, double height) throws Exception {
    Shape chartShape = builder.insertChart(chartType, width, height);
    Chart chart = chartShape.getChart();
    chart.getSeries().clear();

    Assert.assertEquals(chart.getSeries().getCount(), 0);

    return chart;
}

Field Summary
static final intAREA = 0
Area chart.
static final intAREA_STACKED = 1
Stacked Area chart.
static final intAREA_PERCENT_STACKED = 2
100% Stacked Area chart.
static final intAREA_3_D = 3
3D Area chart.
static final intAREA_3_D_STACKED = 4
3D Stacked Area chart.
static final intAREA_3_D_PERCENT_STACKED = 5
3D 100% Stacked Area chart.
static final intBAR = 6
Bar chart.
static final intBAR_STACKED = 7
Stacked Bar chart.
static final intBAR_PERCENT_STACKED = 8
100% Stacked Bar chart.
static final intBAR_3_D = 9
3D Bar chart.
static final intBAR_3_D_STACKED = 10
3D Stacked Bar chart.
static final intBAR_3_D_PERCENT_STACKED = 11
3D 100% Stacked Bar chart.
static final intBUBBLE = 12
Bubble chart.
static final intBUBBLE_3_D = 13
3D Bubble chart.
static final intCOLUMN = 14
Column chart.
static final intCOLUMN_STACKED = 15
Stacked Column chart.
static final intCOLUMN_PERCENT_STACKED = 16
100% Stacked Column chart.
static final intCOLUMN_3_D = 17
3D Column chart.
static final intCOLUMN_3_D_STACKED = 18
3D Stacked Column chart.
static final intCOLUMN_3_D_PERCENT_STACKED = 19
3D 100% Stacked Column chart.
static final intCOLUMN_3_D_CLUSTERED = 20
3D Clustered Column chart.
static final intDOUGHNUT = 21
Doughnut chart.
static final intLINE = 22
Line chart.
static final intLINE_STACKED = 23
Stacked Line chart.
static final intLINE_PERCENT_STACKED = 24
100% Stacked Line chart.
static final intLINE_3_D = 25
3D Line chart.
static final intPIE = 26
Pie chart.
static final intPIE_3_D = 27
3D Pie chart.
static final intPIE_OF_BAR = 28
Pie of Bar chart.
static final intPIE_OF_PIE = 29
Pie of Pie chart.
static final intRADAR = 30
Radar chart.
static final intSCATTER = 31
Scatter chart.
static final intSTOCK = 32
Stock chart.
static final intSURFACE = 33
Surface chart.
static final intSURFACE_3_D = 34
3D Surface chart.
 

    • Field Detail

      • AREA = 0

        public static final int AREA
        Area chart.
      • AREA_STACKED = 1

        public static final int AREA_STACKED
        Stacked Area chart.
      • AREA_PERCENT_STACKED = 2

        public static final int AREA_PERCENT_STACKED
        100% Stacked Area chart.
      • AREA_3_D = 3

        public static final int AREA_3_D
        3D Area chart.
      • AREA_3_D_STACKED = 4

        public static final int AREA_3_D_STACKED
        3D Stacked Area chart.
      • AREA_3_D_PERCENT_STACKED = 5

        public static final int AREA_3_D_PERCENT_STACKED
        3D 100% Stacked Area chart.
      • BAR = 6

        public static final int BAR
        Bar chart.
      • BAR_STACKED = 7

        public static final int BAR_STACKED
        Stacked Bar chart.
      • BAR_PERCENT_STACKED = 8

        public static final int BAR_PERCENT_STACKED
        100% Stacked Bar chart.
      • BAR_3_D = 9

        public static final int BAR_3_D
        3D Bar chart.
      • BAR_3_D_STACKED = 10

        public static final int BAR_3_D_STACKED
        3D Stacked Bar chart.
      • BAR_3_D_PERCENT_STACKED = 11

        public static final int BAR_3_D_PERCENT_STACKED
        3D 100% Stacked Bar chart.
      • BUBBLE = 12

        public static final int BUBBLE
        Bubble chart.
      • BUBBLE_3_D = 13

        public static final int BUBBLE_3_D
        3D Bubble chart.
      • COLUMN = 14

        public static final int COLUMN
        Column chart.
      • COLUMN_STACKED = 15

        public static final int COLUMN_STACKED
        Stacked Column chart.
      • COLUMN_PERCENT_STACKED = 16

        public static final int COLUMN_PERCENT_STACKED
        100% Stacked Column chart.
      • COLUMN_3_D = 17

        public static final int COLUMN_3_D
        3D Column chart.
      • COLUMN_3_D_STACKED = 18

        public static final int COLUMN_3_D_STACKED
        3D Stacked Column chart.
      • COLUMN_3_D_PERCENT_STACKED = 19

        public static final int COLUMN_3_D_PERCENT_STACKED
        3D 100% Stacked Column chart.
      • COLUMN_3_D_CLUSTERED = 20

        public static final int COLUMN_3_D_CLUSTERED
        3D Clustered Column chart.
      • DOUGHNUT = 21

        public static final int DOUGHNUT
        Doughnut chart.
      • LINE = 22

        public static final int LINE
        Line chart.
      • LINE_STACKED = 23

        public static final int LINE_STACKED
        Stacked Line chart.
      • LINE_PERCENT_STACKED = 24

        public static final int LINE_PERCENT_STACKED
        100% Stacked Line chart.
      • LINE_3_D = 25

        public static final int LINE_3_D
        3D Line chart.
      • PIE = 26

        public static final int PIE
        Pie chart.
      • PIE_3_D = 27

        public static final int PIE_3_D
        3D Pie chart.
      • PIE_OF_BAR = 28

        public static final int PIE_OF_BAR
        Pie of Bar chart.
      • PIE_OF_PIE = 29

        public static final int PIE_OF_PIE
        Pie of Pie chart.
      • RADAR = 30

        public static final int RADAR
        Radar chart.
      • SCATTER = 31

        public static final int SCATTER
        Scatter chart.
      • STOCK = 32

        public static final int STOCK
        Stock chart.
      • SURFACE = 33

        public static final int SURFACE
        Surface chart.
      • SURFACE_3_D = 34

        public static final int SURFACE_3_D
        3D Surface chart.