[]
An IChart provides access to the chart's data series, axes, title, legend, plot area, and chart type so you can create and configure charts that are hosted by worksheet shapes.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
addChartInPixel(ChartType chartType,
double left,
double top,
double width,
double height) addConnector(ConnectorType type,
double beginX,
double beginY,
double endX,
double endY) IShape object that represents the new connector shape.addConnectorInPixel(ConnectorType type,
double beginX,
double beginY,
double endX,
double endY) addPicture(InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) addPicture(String filename,
double left,
double top,
double width,
double height) addPictureInPixel(InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) addPictureInPixel(String filename,
double left,
double top,
double width,
double height) addShape(AutoShapeType type,
double left,
double top,
double width,
double height) IShape object.addShapeInPixel(AutoShapeType type,
double left,
double top,
double width,
double height) voiddelete()IChartGroup object that represents the area chart group on a 3-D chart.booleangetAxes()IWall object that allows you to individually format the back wall of a 3-D chart.IChartGroup object that represents the bar chart group on a 3-D chart.IChartArea object that represents the complete chart area of the chart.IChartTitle object that represents the title of the chart.IChartGroup object that represents the column chart group on a 3-D chart.IDataTable object that represents the chart data table.intboolean#N/A values as empty cells.doublegetFloor()IFloor object that represents the floor of a 3-D chart.intbooleanbooleanbooleanintIChartGroup object that represents the line chart group on a 3-D chart.getName()IShape that contains the chart.intIChartGroup object that represents the pie chart group on a 3-D chart.IPivotTable associated with the chart.booleanbooleandoublebooleanIWall object that allows individual formatting of the side wall of a 3-D chart.IChartGroup object that represents the surface chart group on a 3-D chart.getWalls()IWall object that represents the walls of a 3-D chart.voidsetAutoScaling(boolean value) voidsetBarShape(BarShape value) voidsetChartType(ChartType value) voidsetDepthPercent(int value) voidvoidsetDisplayNaAsBlank(boolean value) #N/A values as empty cells.voidsetElevation(double value) voidsetGapDepth(int value) voidsetHasDataTable(boolean value) voidsetHasLegend(boolean value) voidsetHasTitle(boolean value) voidsetHeightPercent(int value) voidsetPerspective(int value) voidsetPlotVisibleOnly(boolean value) voidsetRightAngleAxes(boolean value) voidsetRotation(double value) voidsetShowDataLabelsOverMaximum(boolean value) voidsetSourceData(IRange source) voidsetSourceData(IRange source,
RowCol plotBy) The returned value is the object name assigned to the chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
String name = chart.getName();
IShape that contains the chart.Use this method to access the shape object that hosts the chart, such as when you need to work with the chart through the worksheet's shape collection.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape parent = chart.getParent();
IShape of the chart.The returned ChartType value identifies the current chart type, such as column, line, pie, or 3-D chart types.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
ChartType chartType = chart.getChartType();
ChartType of the chart.Use this method to change an existing chart to another ChartType.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setChartType(ChartType.Line);
value - The ChartType to apply to the chart.Use the returned ISeriesCollection object to access, add, or modify the series contained in the chart.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"));
ISeriesCollection seriesCollection = chart.getSeriesCollection();
Use the returned IAxes object to access the chart's category, value, or series axes, such as by calling IAxes.item(AxisType,AxisGroup).
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxes axes = chart.getAxes();
IAxis categoryAxis = axes.item(AxisType.Category, AxisGroup.Primary);
IAxes collection that contains the axes of the chart.IChartArea object that represents the complete chart area of the chart.The chart area contains the chart elements outside the plotted data region, such as the chart title and legend. For the area where data is plotted, see getPlotArea().
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IChartArea chartArea = chart.getChartArea();
chartArea.getFormat().getFill().getColor().setRGB(Color.GetRed());
IChartArea object that represents the complete chart area of the chart.IChartTitle object that represents the title of the chart.Use the returned title object to read or modify chart title properties, such as the title text and formatting.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getChartTitle().setText("Sales Analysis");
IChartTitle title = chart.getChartTitle();
IChartTitle object that represents the title of the chart.The plot area is the region where the chart data series are drawn.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IPlotArea plotArea = chart.getPlotArea();
IChartFormat format = plotArea.getFormat();
IPlotArea object that represents the plot area of the chart.Use the returned ILegend object to configure legend settings such as position, font, and formatting. To control whether the legend is displayed, use setHasLegend(boolean).
worksheet.getRange("A1:C3").setValue(new Object[][] {
{"Month", "Q1", "Q2"},
{"Jan", 10, 20},
{"Feb", 15, 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:C3"), RowCol.Columns, true, true);
chart.setHasLegend(true);
ILegend legend = chart.getLegend();
legend.setPosition(LegendPosition.Left);
ILegend object that represents the legend for the chart.IDataTable object that represents the chart data table.Use the returned IDataTable object to access the formatting and display settings of the chart data table. To display a data table for the chart, set setHasDataTable(boolean) to true before using this method.
worksheet.getRange("A1:C3").setValue(new Object[][] {
{"Item", "Estimated", "Actual"},
{"Income", 63300, 57450},
{"Expenses", 54500, 49630}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:C3"));
chart.setHasDataTable(true);
IDataTable dataTable = chart.getDataTable();
IDataTable object that represents the chart data table.IFloor object that represents the floor of a 3-D chart.Use this property to access floor-specific formatting and thickness settings for a 3-D chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
IFloor floor = chart.getFloor();
floor.setThickness(120);
IFloor object that represents the floor of the 3-D chart.IWall object that represents the walls of a 3-D chart.Use this method to access wall formatting that applies to the chart walls as a whole. To format the side wall or back wall individually, use getSideWall() or getBackWall().
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"A", 10},
{"B", 20}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Column3D, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IWall walls = chart.getWalls();
walls.setThickness(20);
IWall object that represents the walls of the 3-D chart.IWall object that allows individual formatting of the side wall of a 3-D chart.Use the returned wall to configure side-wall properties such as thickness, fill, and line formatting.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"A", 100},
{"B", 200}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Column3D, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IWall sideWall = chart.getSideWall();
sideWall.setThickness(20);
IWall object for the side wall of the 3-D chart.IWall object that allows you to individually format the back wall of a 3-D chart.Use the returned IWall to configure properties such as the back wall's fill, line, and thickness.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Quarter", "Sales"},
{"Q1", 100},
{"Q2", 200}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IWall backWall = chart.getBackWall();
backWall.getFormat().getFill().getColor().setRGB(Color.GetRed());
IWall object that represents the back wall of the 3-D chart.This property applies when getRightAngleAxes() is true.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRightAngleAxes(true);
chart.setAutoScaling(true);
boolean autoScaling = chart.getAutoScaling();
true if the 3-D chart is automatically scaled to be closer in size to the corresponding 2-D chart; otherwise, false.This property applies when getRightAngleAxes() is true.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRightAngleAxes(true);
chart.setAutoScaling(true);
value - true if the 3-D chart is automatically scaled to be closer in size to the corresponding 2-D chart; otherwise, false.Use this property to determine which BarShape is applied to a 3-D bar or 3-D column chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setBarShape(BarShape.Cylinder);
BarShape barShape = chart.getBarShape();
BarShape used by the 3-D bar or column chart.Use this property to control how bars or columns are rendered in a 3-D bar or 3-D column chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setBarShape(BarShape.Cylinder);
value - The BarShape to apply to the 3-D bar or column chart.If this property is true, the chart plots data from visible cells only. If this property is false, the chart plots data from both visible and hidden cells.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setPlotVisibleOnly(false);
boolean plotVisibleOnly = chart.getPlotVisibleOnly();
true if the chart plots only visible cells; otherwise, false.If this property is true, the chart plots data from visible cells only. If this property is false, the chart plots data from both visible and hidden cells.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setPlotVisibleOnly(false);
value - true if the chart plots only visible cells; otherwise, false.#N/A values as empty cells.If this property is true, data points whose values evaluate to #N/A are displayed as blank cells in the chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setDisplayNaAsBlank(true);
boolean displayNaAsBlank = chart.getDisplayNaAsBlank();
true if the chart displays #N/A values as empty cells; otherwise, false.#N/A values as empty cells.If this property is true, data points whose values evaluate to #N/A are displayed as blank cells in the chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setDisplayNaAsBlank(true);
value - true if the chart displays #N/A values as empty cells; otherwise, false.This property applies to 3-D charts. The returned value is between 20 and 2000 percent.
IChart chart = worksheet.getShapes().addChart(ChartType.Column3D, 20, 20, 300, 200).getChart();
chart.setDepthPercent(150);
int depthPercent = chart.getDepthPercent();
This property applies to 3-D charts. The value must be between 20 and 2000 percent.
IChart chart = worksheet.getShapes().addChart(ChartType.Column3D, 20, 20, 300, 200).getChart();
chart.setDepthPercent(150);
value - The depth of the 3-D chart, expressed as a percentage of the chart width.The returned value specifies whether blank cells are not plotted, interpolated, or plotted as zero by using DisplayBlanksAs constants.
IChart chart = worksheet.getShapes().addChart(ChartType.Line, 20, 20, 300, 200).getChart();
chart.setDisplayBlanksAs(DisplayBlanksAs.Interpolated);
DisplayBlanksAs displayBlanksAs = chart.getDisplayBlanksAs();
DisplayBlanksAs value that indicates how blank cells are plotted on the chart.Use this property to control whether blank values in the chart source range are displayed as gaps, connected by interpolation, or plotted as zero by using DisplayBlanksAs constants.
IRange range = worksheet.getRange("A1:B4");
range.setValue(new Object[][] {{"Month", "Sales"}, {"Jan", 10}, {"Feb", null}, {"Mar", 14}});
IChart chart = worksheet.getShapes().addChart(ChartType.Line, 20, 20, 300, 200).getChart();
chart.setSourceData(range);
chart.setDisplayBlanksAs(DisplayBlanksAs.Interpolated);
value - The blank cell plotting mode. Use DisplayBlanksAs.NotPlotted, DisplayBlanksAs.Interpolated, or DisplayBlanksAs.Zero.Use this property to retrieve the current vertical viewing angle applied to a 3-D chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setElevation(25);
double elevation = chart.getElevation();
Use this property to set the vertical viewing angle applied to a 3-D chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setElevation(25);
value - The elevation of the 3-D chart view, in degrees.This property applies to 3-D charts. The returned value is in the range from 0 to 500.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setGapDepth(200);
int gapDepth = chart.getGapDepth();
This property applies to 3-D charts. The value must be in the range from 0 to 500.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setGapDepth(200);
value - The distance between the data series in a 3-D chart, as a percentage of the marker width.Use this property to determine whether the legend is currently displayed for the chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setHasLegend(true);
boolean hasLegend = chart.getHasLegend();
true if the chart has a legend; otherwise, false.Set this property to true to show the legend, or false to hide it.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setHasLegend(true);
value - true if the chart has a legend; otherwise, false.Use setHasDataTable(boolean) to show or hide the data table for a chart. For chart types that do not support data tables, this method returns false.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setHasDataTable(true);
boolean hasDataTable = chart.getHasDataTable();
true if the chart displays a data table; otherwise, false.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setHasDataTable(true);
value - true if the chart displays a data table; otherwise, false.This property indicates whether the chart title is displayed.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setHasTitle(true);
boolean hasTitle = chart.getHasTitle();
true if the chart has a visible title; otherwise, false.Set this property to true to show the chart title, or false to hide it.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setHasTitle(true);
value - true if the chart has a visible title; otherwise, false.The returned value is between 5 and 500 percent.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setHeightPercent(150);
int heightPercent = chart.getHeightPercent();
The value must be between 5 and 500 percent.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setHeightPercent(150);
value - The height of the 3-D chart as a percentage of the chart width, from 5 to 500.The returned value is between 0 and 100. This property is ignored if getRightAngleAxes() returns true.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRightAngleAxes(false);
chart.setPerspective(30);
int perspective = chart.getPerspective();
The value must be between 0 and 100. This property is ignored if getRightAngleAxes() returns true.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRightAngleAxes(false);
chart.setPerspective(30);
value - The perspective for the 3-D chart view, from 0 to 100.This property applies only to 3-D line, column, and bar charts.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRightAngleAxes(true);
boolean rightAngleAxes = chart.getRightAngleAxes();
true if the chart axes are displayed at right angles; otherwise, false.This property applies only to 3-D line, column, and bar charts.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRightAngleAxes(true);
value - true if the chart axes are displayed at right angles; otherwise, false.This property specifies the rotation of the plot area around the z-axis in degrees. The default value is 20. Applies only to 3-D charts.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRotation(30);
double rotation = chart.getRotation();
0 to 44; otherwise, it is from 0 to 360. The default value is 20.This property specifies the rotation of the plot area around the z-axis in degrees. The default value is 20. Applies only to 3-D charts.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setRotation(30);
value - The rotation of the 3-D chart view, in degrees. For 3-D bar charts, the returned value is from 0 to 44; otherwise, it is from 0 to 360. The default value is 20.This property indicates whether data labels remain visible for data points that exceed the current maximum value of the value axis.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setShowDataLabelsOverMaximum(true);
boolean showDataLabelsOverMaximum = chart.getShowDataLabelsOverMaximum();
true if data labels are shown for values greater than the maximum value on the value axis; otherwise, false.Set this property to true to keep data labels visible for data points that exceed the current maximum value of the value axis, or false to hide them.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setShowDataLabelsOverMaximum(true);
value - true if data labels are shown for values greater than the maximum value on the value axis; otherwise, false.The returned list contains the drawing shapes currently embedded in the chart. If the chart does not contain any drawing shapes, an empty list is returned.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape autoShape = chart.addShape(AutoShapeType.Chevron, 30, 25, 120, 80);
List<IShape> shapes = chart.getShapes();
IShape firstShape = shapes.get(0);
IPivotTable associated with the chart.For a PivotChart, this method returns the PivotTable that supplies the chart data.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Product", "Amount"},
{"Apple", 100},
{"Orange", 200},
{"Apple", 150}
});
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B4"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"));
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(pivotTable.getTableRange1());
IPivotTable linkedPivotTable = chart.getPivotTable();
IPivotTable associated with the chart. Returns null if the chart is not associated with a PivotTable.The returned IPivotOptions object controls whether field buttons, such as legend, axis, value, report filter, and expand or collapse buttons, are displayed on a PivotChart.
Object[][] sourceData = new Object[][] {
{"Category", "Amount"},
{"Beverages", 100},
{"Snacks", 200}
};
worksheet.getRange("A1:B3").setValue(sourceData);
IPivotCache pivotCache = workbook.getPivotCaches().create(worksheet.getRange("A1:B3"));
IPivotTable pivotTable = worksheet.getPivotTables().add(pivotCache, worksheet.getRange("D1"), "PivotTable1");
pivotTable.getPivotFields().get("Category").setOrientation(PivotFieldOrientation.RowField);
pivotTable.getPivotFields().get("Amount").setOrientation(PivotFieldOrientation.DataField);
IChart chart = worksheet.getShapes().addChartInPixel(ChartType.ColumnClustered, 0, 100, 360, 220).getChart();
chart.setSourceData(pivotTable.getTableRange1());
IPivotOptions pivotOptions = chart.getPivotOptions();
pivotOptions.setShowLegendFieldButtons(false);
IPivotOptions object that specifies whether pivot chart buttons are displayed.IChartGroup object that represents the area chart group on a 3-D chart.Use this method to access group-level settings for a 3-D area chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Quarter", "Sales"},
{"Q1", 100},
{"Q2", 140},
{"Q3", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Area3D, 20, 20, 300, 200).getChart();
chart.setSourceData(worksheet.getRange("A1:B4"));
IChartGroup areaGroup = chart.getArea3DGroup();
areaGroup.setVaryByCategories(true);
IChartGroup object that represents the area chart group on a 3-D chart.IChartGroup object that represents the bar chart group on a 3-D chart.Use this method to access group-level settings for a 3-D bar chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Quarter", "Sales"},
{"Q1", 100},
{"Q2", 140},
{"Q3", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.BarClustered3D, 20, 20, 300, 200).getChart();
chart.setSourceData(worksheet.getRange("A1:B4"));
IChartGroup barGroup = chart.getBar3DGroup();
barGroup.setGapWidth(50);
IChartGroup object that represents the bar chart group on a 3-D chart.IChartGroup object that represents the column chart group on a 3-D chart.Use this method to access group-level settings for a 3-D column chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Quarter", "Sales"},
{"Q1", 100},
{"Q2", 140},
{"Q3", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered3D, 20, 20, 300, 200).getChart();
chart.setSourceData(worksheet.getRange("A1:B4"));
IChartGroup columnGroup = chart.getColumn3DGroup();
columnGroup.setGapWidth(50);
IChartGroup object that represents the column chart group on a 3-D chart.IChartGroup object that represents the line chart group on a 3-D chart.Use this method to access the chart group for a chart created with ChartType.Line3D.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"}, {"Jan", 12}, {"Feb", 18}, {"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Line3D, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IChartGroup line3DGroup = chart.getLine3DGroup();
IChartGroup object that represents the line chart group on a 3-D chart.IChartGroup object that represents the pie chart group on a 3-D chart.Use this method to access group-level settings for a chart created with ChartType.Pie3D.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Category", "Sales"}, {"A", 35}, {"B", 25}, {"C", 40}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Pie3D, 20, 20, 300, 200).getChart();
chart.setSourceData(worksheet.getRange("A1:B4"));
IChartGroup pie3DGroup = chart.getPie3DGroup();
IChartGroup object that represents the pie chart group on a 3-D chart.IChartGroup object that represents the surface chart group on a 3-D chart.Use this method to access group-level settings for a chart created with ChartType.Surface.
worksheet.getRange("A1:D4").setValue(new Object[][] {
{"", "Q1", "Q2", "Q3"},
{"North", 12, 18, 15},
{"South", 20, 16, 22},
{"West", 14, 19, 17}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Surface, 20, 20, 300, 200).getChart();
chart.setSourceData(worksheet.getRange("A1:D4"));
IChartGroup surfaceGroup = chart.getSurfaceGroup();
IChartGroup object that represents the surface chart group on a 3-D chart.Use this method to access the IChartGroups collection for the area chart groups in the current chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 20},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Area, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IChartGroups areaGroups = chart.getAreaGroups();
IChartGroup areaGroup = areaGroups.get(0);
IChartGroups collection that contains the area chart groups on the 2D chart.Use this method to access the IChartGroups collection for the bar chart groups in the current chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 20},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.BarClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IChartGroups barGroups = chart.getBarGroups();
IChartGroup barGroup = barGroups.get(0);
IChartGroups collection that contains the bar chart groups on the 2D chart.Use this method to access the IChartGroups collection for a column chart and then retrieve individual IChartGroup objects from that collection.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IChartGroups columnGroups = chart.getColumnGroups();
IChartGroup columnGroup = columnGroups.get(0);
IChartGroups collection that contains the column chart groups on a 2-D chart.Use this method to access the IChartGroups collection for the doughnut chart groups in the current chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Category", "Sales"},
{"North", 10},
{"South", 20},
{"West", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Doughnut, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IChartGroups doughnutGroups = chart.getDoughnutGroups();
IChartGroup doughnutGroup = doughnutGroups.get(0);
IChartGroups collection that contains the doughnut chart groups on the 2D chart.Use this method to access the IChartGroups collection for the line chart groups in the current chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 20},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Line, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IChartGroups lineGroups = chart.getLineGroups();
IChartGroup lineGroup = lineGroups.get(0);
IChartGroups collection that contains the line chart groups on the 2D chart.Use this method to access pie chart group settings exposed through IChartGroups, such as the group definitions for pie-based 2D charts.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Sales"},
{"East", 35},
{"West", 25},
{"North", 40}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Pie, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IChartGroups pieGroups = chart.getPieGroups();
Use this method to access the IChartGroups collection for the radar chart groups in the current chart.
worksheet.getRange("A1:B5").setValue(new Object[][] {
{"Category", "Score"},
{"Speed", 80},
{"Power", 65},
{"Skill", 90},
{"Focus", 75}
});
IChart chart = worksheet.getShapes().addChart(ChartType.Radar, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B5"));
IChartGroups radarGroups = chart.getRadarGroups();
IChartGroup radarGroup = radarGroups.get(0);
IChartGroups collection that contains the radar chart groups on the 2D chart.Use this method to access the IChartGroups collection for the current scatter chart. Each item in the returned collection represents a scatter chart group in the chart.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{1, 10},
{2, 20},
{3, 15},
{4, 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.XYScatter, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IChartGroups xyGroups = chart.getXYGroups();
IChartGroups collection that contains the scatter chart groups on the 2D chart.Use this method to access the IChartGroups collection for the current chart. The returned collection includes every chart group in the chart, including groups created by different chart types.
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Month", "Sales", "Target"},
{"Jan", 10, 12},
{"Feb", 20, 18},
{"Mar", 15, 16}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("B1:C4"));
chart.getSeriesCollection().get(1).setChartType(ChartType.Line);
IChartGroups chartGroups = chart.getChartGroups();
IChartGroup chartGroup = chartGroups.get(0);
IChartGroups collection that contains all chart groups in the current chart.IShape object.The shape is positioned relative to the upper-left corner of the chart area, and its size and position are specified in points.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape autoShape = chart.addShape(AutoShapeType.Chevron, 30, 25, 120, 80);
autoShape.getFill().getColor().setRGB(Color.GetBlue());
type - The type of AutoShape to create.left - The distance from the left edge of the AutoShape's boundary box to the left edge of the chart area, in points.top - The distance from the top edge of the AutoShape's boundary box to the top edge of the chart area, in points.width - The width of the AutoShape's boundary box, in points.height - The height of the AutoShape's boundary box, in points.IShape object that represents the new AutoShape.IllegalArgumentException - if type is AutoShapeType.None.The new chart is positioned relative to the upper-left corner of the chart area, and the returned IShape represents the created chart shape.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape insetChart = chart.addChart(ChartType.Line, 30, 25, 120, 90);
chartType - The type of chart to create.left - The distance from the left edge of the new chart to the left edge of the chart area, in points.top - The distance from the top edge of the new chart to the top edge of the chart area, in points.width - The width of the new chart, in points.height - The height of the new chart, in points.IShape object that represents the new chart.IShape object that represents the new connector shape.The connector is positioned by its start and end points relative to the upper-left corner of the chart area, in points.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape connector = chart.addConnector(ConnectorType.Straight, 30, 40, 180, 120);
connector.getLine().setWeight(2);
type - The type of connector shape to create.beginX - The horizontal position of the connector shape's starting point relative to the upper-left corner of the chart area, in points.beginY - The vertical position of the connector shape's starting point relative to the upper-left corner of the chart area, in points.endX - The horizontal position of the connector shape's ending point relative to the upper-left corner of the chart area, in points.endY - The vertical position of the connector shape's ending point relative to the upper-left corner of the chart area, in points.IShape object that represents the new connector shape.The picture is positioned relative to the upper-left corner of the chart area, and the returned IShape represents the newly created picture.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape picture = null;
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
picture = chart.addPicture(imagePath, 40, 30, 120, 80);
} catch (IOException e) {
}
filename - The file from which the picture is created. Must not be null.left - The distance from the left edge of the picture to the left edge of the chart area, in points.top - The distance from the top edge of the picture to the top edge of the chart area, in points.width - The width of the picture, in points.height - The height of the picture, in points.IShape object that represents the new picture.IOException - if the file cannot be read.The picture is positioned relative to the chart area. The left, top, width, and height values are measured in points.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
byte[] pictureBytes = java.util.Base64.getDecoder().decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4////fwAJ+wP9KobjigAAAABJRU5ErkJggg==");
IShape picture = null;
try (java.io.ByteArrayInputStream stream = new java.io.ByteArrayInputStream(pictureBytes)) {
picture = chart.addPicture(stream, ImageType.PNG, 40, 30, 120, 80);
} catch (java.io.IOException e) {
}
stream - The stream that provides the picture data. Must not be null.type - The type of the picture data in the stream.left - The distance from the left edge of the picture to the left edge of the chart area, in points.top - The distance from the top edge of the picture to the top edge of the chart area, in points.width - The width of the picture, in points.height - The height of the picture, in points.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the stream.The shape is positioned relative to the upper-left corner of the chart area, and the returned IShape represents the newly created AutoShape.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape autoShape = chart.addShapeInPixel(AutoShapeType.Chevron, 30, 25, 120, 80);
autoShape.getFill().getColor().setRGB(Color.GetBlue());
type - The type of AutoShape to create.left - The distance from the left edge of the AutoShape's boundary box to the left edge of the chart area, in pixels.top - The distance from the top edge of the AutoShape's boundary box to the top edge of the chart area, in pixels.width - The width of the AutoShape's boundary box, in pixels.height - The height of the AutoShape's boundary box, in pixels.IShape object that represents the new AutoShape.IllegalArgumentException - if type is AutoShapeType.None.The new chart is positioned relative to the upper-left corner of the chart area, and the returned IShape represents the created chart shape.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape insetChart = chart.addChartInPixel(ChartType.Line, 40, 30, 160, 100);
chartType - The type of chart to create.left - The distance from the left edge of the new chart to the left edge of the chart area, in pixels.top - The distance from the top edge of the new chart to the top edge of the chart area, in pixels.width - The width of the new chart, in pixels.height - The height of the new chart, in pixels.IShape object that represents the new chart.The connector's start and end points are measured from the upper-left corner of the chart area in pixels. This method returns the IShape object that represents the newly created connector.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape connector = chart.addConnectorInPixel(ConnectorType.Straight, 30, 40, 180, 120);
connector.getLine().setWeight(2);
type - The ConnectorType of the connector to create.beginX - The horizontal position of the connector's starting point relative to the upper-left corner of the chart area, in pixels.beginY - The vertical position of the connector's starting point relative to the upper-left corner of the chart area, in pixels.endX - The horizontal position of the connector's end point relative to the upper-left corner of the chart area, in pixels.endY - The vertical position of the connector's end point relative to the upper-left corner of the chart area, in pixels.IShape object that represents the new connector.The picture is positioned relative to the upper-left corner of the chart area, and the returned IShape represents the newly created picture.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IShape picture = null;
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
picture = chart.addPictureInPixel(imagePath, 30, 25, 80, 60);
picture.setName("Logo");
} catch (IOException e) {
}
filename - The file from which the picture is created. Must not be null.left - The distance from the left edge of the picture to the left edge of the chart area, in pixels.top - The distance from the top edge of the picture to the top edge of the chart area, in pixels.width - The width of the picture, in pixels.height - The height of the picture, in pixels.IShape object that represents the new picture.IOException - if the file cannot be read.The picture is added relative to the chart area. Use this method when the image content is available as a stream and the picture position and size need to be specified in pixel units.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
byte[] imageData = java.util.Base64.getDecoder().decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jmioAAAAASUVORK5CYII=");
IShape picture = null;
try (java.io.InputStream stream = new java.io.ByteArrayInputStream(imageData)) {
picture = chart.addPictureInPixel(stream, ImageType.PNG, 30, 25, 80, 60);
picture.setName("Logo");
} catch (IOException e) {
}
stream - The stream that provides the image data. Must not be null.type - The image type of the stream data.left - The distance from the left edge of the picture to the left edge of the chart area, in pixels.top - The distance from the top edge of the picture to the top edge of the chart area, in pixels.width - The width of the picture, in pixels.height - The height of the picture, in pixels.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the image stream.Use the plotBy parameter to control how the chart interprets the source range when creating series and categories.
worksheet.getRange("A1:C4").setValue(new Object[][] {
{"Month", "North", "South"},
{"Jan", 10, 12},
{"Feb", 15, 18},
{"Mar", 13, 16}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setSourceData(worksheet.getRange("A1:C4"), RowCol.Columns);
source - The range that contains the source data. Must not be null.plotBy - Specifies whether the chart reads each data series from RowCol.Columns or RowCol.Rows.The specified range is used as the chart's data source.
IRange range = worksheet.getRange("A1:B4");
range.setValue(new Object[][] {{"Month", "Sales"}, {"Jan", 10}, {"Feb", 15}, {"Mar", 12}});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.setSourceData(range);
source - The range that contains the source data. Must not be null.After this method is called, the chart is removed from the worksheet's shapes collection.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.delete();