public class ChartData extends DomObject<Chart> implements IChartData
Represents data used for a chart plotting.
| Modifier and Type | Method and Description |
|---|---|
IChartCategoryCollection |
getCategories()
Gets the primary categories (or both primary and secondary categories
if
getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is false). |
IChartDataWorkbook |
getChartDataWorkbook()
Gets the cells factory to create cells used for chart series or categories.
|
int |
getDataSourceType()
Represents external workbook path if external data source, null otherwise
|
java.lang.String |
getExternalWorkbookPath()
Represents data source of the chart
|
java.lang.String |
getRange()
Gets chart data range.
|
IChartCategoryCollection |
getSecondaryCategories()
Gets the secondary categories if
getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is true. |
IChartSeriesCollection |
getSeries()
Gets the series.
|
IChartSeriesGroupCollection |
getSeriesGroups()
Gets the groups of series.
|
boolean |
getUseSecondaryCategories()
If false then
getSecondaryCategories() property return null and data
in getCategories() property is used both for primary and secondary series. |
byte[] |
readWorkbookStream()
Writes the internally contained Excel workbook it into an in-memory stream.
|
void |
setExternalWorkbook(java.lang.String workbookPath)
Sets external workbook as a data source for the chart.
|
void |
setExternalWorkbook(java.lang.String workbookPath,
boolean updateChartData)
Sets external workbook as a data source for the chart.
|
void |
setRange(java.lang.String formula)
Set chart data range.
|
void |
setUseSecondaryCategories(boolean value)
If false then
getSecondaryCategories() property return null and data
in getCategories() property is used both for primary and secondary series. |
void |
switchRowColumn()
Swap the data over the axis.
|
void |
writeWorkbookStream(byte[] ms)
Initializes the internally contained Excel workbook with user-specified value.
|
getParent_Immediatepublic final IChartDataWorkbook getChartDataWorkbook()
Gets the cells factory to create cells used for chart series or categories.
Read-only IChartDataWorkbook.
getChartDataWorkbook in interface IChartDatapublic final IChartSeriesCollection getSeries()
Gets the series.
Read-only IChartSeriesCollection.
getSeries in interface IChartDatapublic final IChartSeriesGroupCollection getSeriesGroups()
Gets the groups of series.
Read-only IChartSeriesGroupCollection.
getSeriesGroups in interface IChartDatapublic final IChartCategoryCollection getCategories()
Gets the primary categories (or both primary and secondary categories
if getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is false).
Read-only IChartCategoryCollection.
Example. What categories are related to series - ChartData.getCategories() or ChartData.getSecondaryCategories()?if (series.getPlotOnSecondAxis() && series.getChart().getChartData().getUseSecondaryCategories()) { // related categories are series.getChart().getChartData().getSecondaryCategories() } else { // related categories are series.getChart().getChartData().getCategories() }
getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is false then (getSecondaryCategories())
property return null and data in this getCategories() property is used both for primary
and secondary series.
If getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is true then data in (getSecondaryCategories())
property is used for secondary series and data in this getCategories() property is used
for primary series.
getCategories in interface IChartDatapublic final boolean getUseSecondaryCategories()
If false then getSecondaryCategories() property return null and data
in getCategories() property is used both for primary and secondary series.
If true then data in getSecondaryCategories() property is used for secondary series and data
in getCategories() property is used for primary series.
Read/write boolean.
Example. What categories are related to series - ChartData.getCategories() or ChartData.getSecondaryCategories()?if (series.getPlotOnSecondAxis() && series.getChart().getChartData().getUseSecondaryCategories()) { // related categories are series.getChart().getChartData().getSecondaryCategories() } else { // related categories are series.getChart().getChartData().getCategories() }
getUseSecondaryCategories in interface IChartDatapublic final void setUseSecondaryCategories(boolean value)
If false then getSecondaryCategories() property return null and data
in getCategories() property is used both for primary and secondary series.
If true then data in getSecondaryCategories() property is used for secondary series and data
in getCategories() property is used for primary series.
Read/write boolean.
Example. What categories are related to series - ChartData.getCategories() or ChartData.getSecondaryCategories()?if (series.getPlotOnSecondAxis() && series.getChart().getChartData().getUseSecondaryCategories()) { // related categories are series.getChart().getChartData().getSecondaryCategories() } else { // related categories are series.getChart().getChartData().getCategories() }
setUseSecondaryCategories in interface IChartDatapublic final IChartCategoryCollection getSecondaryCategories()
Gets the secondary categories if getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is true.
Read-only IChartCategoryCollection.
Example. What categories are related to series - ChartData.getCategories() or ChartData.getSecondaryCategories()?if (series.getPlotOnSecondAxis() && series.getChart().getChartData().getUseSecondaryCategories()) { // related categories are series.getChart().getChartData().getSecondaryCategories() } else { // related categories are series.getChart().getChartData().getCategories() }
getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is false then this (getSecondaryCategories())
property return null and data in getCategories() property is used both for primary
and secondary series.
If getUseSecondaryCategories()/setUseSecondaryCategories(boolean) property is true then data in
this getSecondaryCategories() property is used for secondary series and data
in getCategories() property is used for primary series.
getSecondaryCategories in interface IChartDatapublic final byte[] readWorkbookStream()
Writes the internally contained Excel workbook it into an in-memory stream.
readWorkbookStream in interface IChartDatapublic final void writeWorkbookStream(byte[] ms)
Initializes the internally contained Excel workbook with user-specified value.
writeWorkbookStream in interface IChartDatams - The user-supplied stream containing the entire Excel workbook.public final int getDataSourceType()
Represents external workbook path if external data source, null otherwise
getDataSourceType in interface IChartDatapublic final java.lang.String getExternalWorkbookPath()
Represents data source of the chart
getExternalWorkbookPath in interface IChartDatapublic final java.lang.String getRange()
Gets chart data range.
Presentation pres = new Presentation(); try { IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.PercentsStackedBar, 0, 0, 100, 100); String result = ((ChartData)chart.getChartData()).getRange(); } finally { if (pres != null) pres.dispose(); }
getRange in interface IChartDatacom.aspose.ms.System.InvalidOperationException - Chart doesn't use workbook as a data sourcepublic final void setRange(java.lang.String formula)
Set chart data range. Series and categories will be updated based on new data range. If amount of series in data range greater than count of series in the chart data then additional series with the same type as a last series in the current collection will be added to the end of the collection.
setRange in interface IChartDataformula - The cells data range formula. E.g: "Sheet1!$A$1:$C$4" , "SomeSheetName!A1:B100", "Sheet1!$A$1:$B$5;Sheet1!$D$1:$D$5".com.aspose.ms.System.ArgumentNullException - formula is null.com.aspose.ms.System.InvalidOperationException - Unsupported chart typecom.aspose.ms.System.ArgumentException - formula has incorrect format.public final void setExternalWorkbook(java.lang.String workbookPath)
Sets external workbook as a data source for the chart. Chart data will be updated from the target workbook.
Presentation pres = new Presentation(); try { IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 50, 50, 400, 600, true); IChartData chartData = chart.getChartData(); ((ChartData)chartData).setExternalWorkbook("../../workbook.xlsx"); } finally { if (pres != null) pres.dispose(); }
setExternalWorkbook in interface IChartDataworkbookPath - Path to the target workbookcom.aspose.ms.System.InvalidOperationException - External workbook is not available or can't be loaded.public final void setExternalWorkbook(java.lang.String workbookPath,
boolean updateChartData)
Sets external workbook as a data source for the chart.
Presentation pres = new Presentation(); try { IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 50, 50, 400, 600, true); IChartData chartData = chart.getChartData(); ((ChartData).setExternalWorkbook("http://path/doesnt/exists", false); } finally { if (pres != null) pres.dispose(); }
setExternalWorkbook in interface IChartDataworkbookPath - Path to the target workbookupdateChartData - If value is false only workbook path will be updated.
Chart data won't be loaded and updated from the target workbook. Can be used when target workbook doesn't exist or it's not available.
If value is true chart data will be updated from the target workbook.com.aspose.ms.System.InvalidOperationException - External workbook is not available or can't be loaded.public final void switchRowColumn()
Swap the data over the axis. Data being charted on the X axis will move to the Y axis and vice versa.
switchRowColumn in interface IChartDataCopyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.