java.lang.Object
com.aspose.words.ChartDataPoint
- All Implemented Interfaces:
- IChartDataPoint, java.lang.Cloneable
public class ChartDataPoint
- extends java.lang.Object
Allows to specify formatting of a single data point on the chart.
To learn more, visit the Working with Charts documentation article.
On a series, the ChartDataPoint object is a member of the ChartDataPointCollection.
The ChartDataPointCollection contains a ChartDataPoint object for each point.
Example:
Shows how to work with data points on a line chart.
public void chartDataPoint() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.LINE, 500.0, 350.0);
Chart chart = shape.getChart();
Assert.assertEquals(3, chart.getSeries().getCount());
Assert.assertEquals("Series 1", chart.getSeries().get(0).getName());
Assert.assertEquals("Series 2", chart.getSeries().get(1).getName());
Assert.assertEquals("Series 3", chart.getSeries().get(2).getName());
// Emphasize the chart's data points by making them appear as diamond shapes.
for (ChartSeries series : chart.getSeries())
applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
// Smooth out the line that represents the first data series.
chart.getSeries().get(0).setSmooth(true);
// Verify that data points for the first series will not invert their colors if the value is negative.
Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();
while (enumerator.hasNext()) {
Assert.assertFalse(enumerator.next().getInvertIfNegative());
}
// For a cleaner looking graph, we can clear format individually.
chart.getSeries().get(1).getDataPoints().get(2).clearFormat();
// We can also strip an entire series of data points at once.
chart.getSeries().get(2).getDataPoints().clearFormat();
doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}
/// <summary>
/// Applies a number of data points to a series.
/// </summary>
private static void applyDataPoints(ChartSeries series, int dataPointsCount, int markerSymbol, int dataPointSize) {
for (int i = 0; i < dataPointsCount; i++) {
ChartDataPoint point = series.getDataPoints().get(i);
point.getMarker().setSymbol(markerSymbol);
point.getMarker().setSize(dataPointSize);
Assert.assertEquals(point.getIndex(), i);
}
}
|
Property Getters/Setters Summary |
boolean | getBubble3D() | |
void | setBubble3D(boolean value) | |
|
Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.
|
int | getExplosion() | |
void | setExplosion(int value) | |
|
Specifies the amount the data point shall be moved from the center of the pie.
Can be negative, negative means that property is not set and no explosion should be applied.
Applies only to Pie charts.
|
ChartFormat | getFormat() | |
|
Provides access to fill and line formatting of this data point.
|
int | getIndex() | |
|
Index of the data point this object applies formatting to.
|
boolean | getInvertIfNegative() | |
void | setInvertIfNegative(boolean value) | |
|
Specifies whether the parent element shall inverts its colors if the value is negative.
|
ChartMarker | getMarker() | |
|
Specifies chart data marker.
|
|
Method Summary |
void | clearFormat() | |
|
Clears format of this data point. The properties are set to the default values defined in the parent series.
|
|
Property Getters/Setters Detail |
getBubble3D/setBubble3D | |
public boolean getBubble3D() / public void setBubble3D(boolean value)
|
-
Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.
getExplosion/setExplosion | |
public int getExplosion() / public void setExplosion(int value)
|
-
Specifies the amount the data point shall be moved from the center of the pie.
Can be negative, negative means that property is not set and no explosion should be applied.
Applies only to Pie charts.
-
Provides access to fill and line formatting of this data point.
Example:
Shows how to set individual formatting for categories of a column chart.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Delete default generated series.
chart.getSeries().clear();
// Adding new series.
ChartSeries series = chart.getSeries().add("Series 1",
new String[] { "Category 1", "Category 2", "Category 3", "Category 4" },
new double[] { 1.0, 2.0, 3.0, 4.0 });
// Set column formatting.
ChartDataPointCollection dataPoints = series.getDataPoints();
dataPoints.get(0).getFormat().getFill().presetTextured(PresetTexture.DENIM);
dataPoints.get(1).getFormat().getFill().setForeColor(Color.RED);
dataPoints.get(2).getFormat().getFill().setForeColor(Color.YELLOW);
dataPoints.get(3).getFormat().getFill().setForeColor(Color.BLUE);
doc.save(getArtifactsDir() + "Charts.DataPointsFormatting.docx");
getIndex | |
public int getIndex()
|
-
Index of the data point this object applies formatting to.
Example:
Shows how to work with data points on a line chart.
public void chartDataPoint() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.LINE, 500.0, 350.0);
Chart chart = shape.getChart();
Assert.assertEquals(3, chart.getSeries().getCount());
Assert.assertEquals("Series 1", chart.getSeries().get(0).getName());
Assert.assertEquals("Series 2", chart.getSeries().get(1).getName());
Assert.assertEquals("Series 3", chart.getSeries().get(2).getName());
// Emphasize the chart's data points by making them appear as diamond shapes.
for (ChartSeries series : chart.getSeries())
applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
// Smooth out the line that represents the first data series.
chart.getSeries().get(0).setSmooth(true);
// Verify that data points for the first series will not invert their colors if the value is negative.
Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();
while (enumerator.hasNext()) {
Assert.assertFalse(enumerator.next().getInvertIfNegative());
}
// For a cleaner looking graph, we can clear format individually.
chart.getSeries().get(1).getDataPoints().get(2).clearFormat();
// We can also strip an entire series of data points at once.
chart.getSeries().get(2).getDataPoints().clearFormat();
doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}
/// <summary>
/// Applies a number of data points to a series.
/// </summary>
private static void applyDataPoints(ChartSeries series, int dataPointsCount, int markerSymbol, int dataPointSize) {
for (int i = 0; i < dataPointsCount; i++) {
ChartDataPoint point = series.getDataPoints().get(i);
point.getMarker().setSymbol(markerSymbol);
point.getMarker().setSize(dataPointSize);
Assert.assertEquals(point.getIndex(), i);
}
}
getInvertIfNegative/setInvertIfNegative | |
public boolean getInvertIfNegative() / public void setInvertIfNegative(boolean value)
|
-
Specifies whether the parent element shall inverts its colors if the value is negative.
-
Specifies chart data marker.
clearFormat | |
public void clearFormat() |
-
Clears format of this data point. The properties are set to the default values defined in the parent series.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.