ChartXValueCollection
Inheritance: java.lang.Object
All Implemented Interfaces: java.lang.Iterable
public class ChartXValueCollection implements Iterable
Represents a collection of X values for a chart series.
Remarks:
All items of the collection other than null must have the same ChartXValue.getValueType().
The collection allows only changing X values. To add or insert new values to a chart series, or remove values, the appropriate methods of the ChartSeries class can be used.
Examples:
Shows how to get chart series data.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder();
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
ChartSeries series = chart.getSeries().get(0);
double minValue = Double.MAX_VALUE;
int minValueIndex = 0;
double maxValue = -Double.MAX_VALUE;
int maxValueIndex = 0;
for (int i = 0; i < series.getYValues().getCount(); i++)
{
// Clear individual format of all data points.
// Data points and data values are one-to-one in column charts.
series.getDataPoints().get(i).clearFormat();
// Get Y value.
double yValue = series.getYValues().get(i).getDoubleValue();
if (yValue < minValue)
{
minValue = yValue;
minValueIndex = i;
}
if (yValue > maxValue)
{
maxValue = yValue;
maxValueIndex = i;
}
}
// Change colors of the max and min values.
series.getDataPoints().get(minValueIndex).getFormat().getFill().setForeColor(Color.RED);
series.getDataPoints().get(maxValueIndex).getFormat().getFill().setForeColor(Color.GREEN);
doc.save(getArtifactsDir() + "Charts.GetChartSeriesData.docx");
Methods
Method | Description |
---|---|
get(int index) | Gets the X value at the specified index. |
getCount() | Gets the number of items in this collection. |
iterator() | Returns an enumerator object. |
set(int index, ChartXValue value) | Sets the X value at the specified index. |
get(int index)
public ChartXValue get(int index)
Gets the X value at the specified index.
Remarks:
Empty values are represented as null.
Parameters:
Parameter | Type | Description |
---|---|---|
index | int |
Returns: ChartXValue - The X value at the specified index.
getCount()
public int getCount()
Gets the number of items in this collection.
Returns: int - The number of items in this collection.
iterator()
public Iterator iterator()
Returns an enumerator object.
Returns: java.util.Iterator
set(int index, ChartXValue value)
public void set(int index, ChartXValue value)
Sets the X value at the specified index.
Remarks:
Empty values are represented as null.
Parameters:
Parameter | Type | Description |
---|---|---|
index | int | |
value | ChartXValue | The X value at the specified index. |