public class ChartDataPointCollection
Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Returns the number of |
||
ChartDataPoint | get(int index) | |
Returns |
Method Summary | ||
---|---|---|
ChartDataPoint | add(int index) | |
void | clear() | |
void | clearFormat() | |
Clears format of all |
||
java.util.Iterator<ChartDataPoint> | iterator() | |
Returns an enumerator object.
|
||
void | removeAt(int index) | |
public int getCount()
Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }
public ChartDataPoint get(int index)
Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }
@Deprecated public ChartDataPoint add(int index)
index
- Target data point index.Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }
@Deprecated public void clear()
Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }
public void clearFormat()
public java.util.Iterator<ChartDataPoint> iterator()
Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }
@Deprecated public void removeAt(int index)
index
- The zero-based index of the data point to clear format.Example:
Shows how to work with data points on a line chart.@Test 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 remove data points individually. chart.getSeries().get(1).getDataPoints().removeAt(2); // We can also strip an entire series of data points at once. chart.getSeries().get(2).getDataPoints().clear(); 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().add(i); point.getMarker().setSymbol(markerSymbol); point.getMarker().setSize(dataPointSize); Assert.assertEquals(point.getIndex(), i); } }