IChartDataPoint
public interface IChartDataPoint
Contains properties of a single data point on the chart.
Examples:
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 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");
}
///
/// Applies a number of data points to a series.
///
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);
}
}
Methods
Method | Description |
---|---|
getBubble3D() | Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them. |
getExplosion() | Specifies the amount the data point shall be moved from the center of the pie. |
getInvertIfNegative() | Specifies whether the parent element shall inverts its colors if the value is negative. |
getMarker() | Specifies a data marker. |
setBubble3D(boolean value) | Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them. |
setExplosion(int value) | Specifies the amount the data point shall be moved from the center of the pie. |
setInvertIfNegative(boolean value) | Specifies whether the parent element shall inverts its colors if the value is negative. |
getBubble3D()
public abstract boolean getBubble3D()
Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.
Examples:
Shows how to use 3D effects with bubble charts.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.BUBBLE_3_D, 500.0, 350.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
Assert.assertTrue(chart.getSeries().get(0).getBubble3D());
// Apply a data label to each bubble that displays its diameter.
for (int i = 0; i < 3; i++) {
chart.getSeries().get(0).hasDataLabels(true);
ChartDataLabel cdl = chart.getSeries().get(0).getDataLabels().get(i);
chart.getSeries().get(0).getDataLabels().get(i).getFont().setSize(12.0);
cdl.setShowBubbleSize(true);
}
doc.save(getArtifactsDir() + "Charts.Bubble3D.docx");
Returns: boolean - The corresponding boolean value.
getExplosion()
public abstract int getExplosion()
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.
Examples:
Shows how to move the slices of a pie chart away from the center.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.PIE, 500.0, 350.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Sales", chart.getSeries().get(0).getName());
// "Slices" of a pie chart may be moved away from the center by a distance via the respective data point's Explosion attribute.
// Add a data point to the first portion of the pie chart and move it away from the center by 10 points.
// Aspose.Words create data points automatically if them does not exist.
ChartDataPoint dataPoint = chart.getSeries().get(0).getDataPoints().get(0);
dataPoint.setExplosion(10);
// Displace the second portion by a greater distance.
dataPoint = chart.getSeries().get(0).getDataPoints().get(1);
dataPoint.setExplosion(40);
doc.save(getArtifactsDir() + "Charts.PieChartExplosion.docx");
Returns: int - The corresponding int value.
getInvertIfNegative()
public abstract boolean getInvertIfNegative()
Specifies whether the parent element shall inverts its colors if the value is negative.
Examples:
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 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");
}
///
/// Applies a number of data points to a series.
///
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);
}
}
Returns: boolean - The corresponding boolean value.
getMarker()
public abstract ChartMarker getMarker()
Specifies a data marker. Marker is automatically created when requested.
Examples:
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 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");
}
///
/// Applies a number of data points to a series.
///
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);
}
}
Returns: ChartMarker - The corresponding ChartMarker value.
setBubble3D(boolean value)
public abstract void setBubble3D(boolean value)
Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.
Examples:
Shows how to use 3D effects with bubble charts.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.BUBBLE_3_D, 500.0, 350.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
Assert.assertTrue(chart.getSeries().get(0).getBubble3D());
// Apply a data label to each bubble that displays its diameter.
for (int i = 0; i < 3; i++) {
chart.getSeries().get(0).hasDataLabels(true);
ChartDataLabel cdl = chart.getSeries().get(0).getDataLabels().get(i);
chart.getSeries().get(0).getDataLabels().get(i).getFont().setSize(12.0);
cdl.setShowBubbleSize(true);
}
doc.save(getArtifactsDir() + "Charts.Bubble3D.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |
setExplosion(int value)
public abstract 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.
Examples:
Shows how to move the slices of a pie chart away from the center.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.PIE, 500.0, 350.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Sales", chart.getSeries().get(0).getName());
// "Slices" of a pie chart may be moved away from the center by a distance via the respective data point's Explosion attribute.
// Add a data point to the first portion of the pie chart and move it away from the center by 10 points.
// Aspose.Words create data points automatically if them does not exist.
ChartDataPoint dataPoint = chart.getSeries().get(0).getDataPoints().get(0);
dataPoint.setExplosion(10);
// Displace the second portion by a greater distance.
dataPoint = chart.getSeries().get(0).getDataPoints().get(1);
dataPoint.setExplosion(40);
doc.save(getArtifactsDir() + "Charts.PieChartExplosion.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The corresponding int value. |
setInvertIfNegative(boolean value)
public abstract void setInvertIfNegative(boolean value)
Specifies whether the parent element shall inverts its colors if the value is negative.
Examples:
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 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");
}
///
/// Applies a number of data points to a series.
///
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);
}
}
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The corresponding boolean value. |