Document Solutions for Excel, Java Edition | Document Solutions
Features / Chart / Configure Chart / Chart Area
In This Topic
    Chart Area
    In This Topic

    In DsExcel Java, you can use the methods of the IChartArea interface in order to set up the chart area as per your preferences.

    You can work with Chart Area in the following ways:

    Configure chart area style

    You can configure the chart area style by changing its font, format and other attributes using the getFont method, getFormat method and setRoundedCorners method of the IChartArea interface.

    To configure chart area style in your worksheet, refer to the following example code.

    Java
    Copy Code
    // Configure chart area style
    IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 20, 360, 230);
    worksheet.getRange("A1:D6").setValue(
            new Object[][] { { null, "S1", "S2", "S3" }, { "Item1", 10, 25, 25 }, { "Item2", -51, -36, 27 },
                    { "Item3", 52, -85, -30 }, { "Item4", 22, 65, 65 }, { "Item5", 23, 69, 69 } });
    shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true);
    IChartArea chartarea = shape.getChart().getChartArea();
            
    // Font
    chartarea.getFont().getColor().setRGB(Color.GetMediumSeaGreen());
    chartarea.getFont().setName("Times New Roman");
    chartarea.getFont().setSize(12);
            
    // Rounded corners.
    chartarea.setRoundedCorners(true);

    Set chart area format

    To set chart area format in your worksheet, refer to the following example code.

    Java
    Copy Code
    chartarea.getFormat().getFill().getColor().setRGB(Color.GetLightGray());
    chartarea.getFormat().getLine().getColor().setRGB(Color.GetMediumSeaGreen());
    chartarea.getFormat().getLine().setWeight(1.5);