public class ChartXValue
extends java.lang.Object
Remarks:
This class contains a number of static methods for creating an X value of a particular type. The getValueType() property allows you to determine the type of an existing X value.
All non-null X values of a chart series must be of the same ChartXValueType type.
Examples:
Shows how to populate chart series with data.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
ChartSeries series1 = chart.getSeries().get(0);
// Clear X and Y values of the first series.
series1.clearValues();
// Populate the series with data.
series1.add(ChartXValue.fromDouble(3.0), ChartYValue.fromDouble(10.0), 10.0);
series1.add(ChartXValue.fromDouble(5.0), ChartYValue.fromDouble(5.0));
series1.add(ChartXValue.fromDouble(7.0), ChartYValue.fromDouble(11.0));
series1.add(ChartXValue.fromDouble(9.0));
ChartSeries series2 = chart.getSeries().get(1);
// Clear X and Y values of the second series.
series2.clear();
// Populate the series with data.
series2.add(ChartXValue.fromDouble(2.0), ChartYValue.fromDouble(4.0));
series2.add(ChartXValue.fromDouble(4.0), ChartYValue.fromDouble(7.0));
series2.add(ChartXValue.fromDouble(6.0), ChartYValue.fromDouble(14.0));
series2.add(ChartXValue.fromDouble(8.0), ChartYValue.fromDouble(7.0));
doc.save(getArtifactsDir() + "Charts.PopulateChartWithData.docx");
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Gets a flag indicating whether the specified object is equal to the current X value object.
|
static ChartXValue |
fromDateTime(java.util.Date value)
Creates a
ChartXValue instance of the ChartXValueType.DATE_TIME type. |
static ChartXValue |
fromDouble(double value)
Creates a
ChartXValue instance of the ChartXValueType.DOUBLE type. |
static ChartXValue |
fromMultilevelValue(ChartMultilevelValue value)
Creates a
ChartXValue instance of the ChartXValueType.MULTILEVEL type. |
static ChartXValue |
fromString(java.lang.String value)
Creates a
ChartXValue instance of the ChartXValueType.STRING type. |
static ChartXValue |
fromTimeSpan(long value)
Creates a
ChartXValue instance of the ChartXValueType.TIME type. |
java.util.Date |
getDateTimeValue()
Gets the stored datetime value.
|
double |
getDoubleValue()
Gets the stored numeric value.
|
ChartMultilevelValue |
getMultilevelValue()
Gets the stored multilevel value.
|
java.lang.String |
getStringValue()
Gets the stored string value.
|
long |
getTimeValue()
Gets the stored time value.
|
int |
getValueType()
Gets the type of the X value stored in the object.
|
int |
hashCode() |
public static ChartXValue fromString(java.lang.String value)
ChartXValue instance of the ChartXValueType.STRING type.
Examples:
Shows how to add/remove chart data values.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder();
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
ChartSeries department1Series = chart.getSeries().get(0);
ChartSeries department2Series = chart.getSeries().get(1);
// Remove the first value in the both series.
department1Series.remove(0);
department2Series.remove(0);
// Add new values to the both series.
ChartXValue newXCategory = ChartXValue.fromString("Q1, 2023");
department1Series.add(newXCategory, ChartYValue.fromDouble(10.3));
department2Series.add(newXCategory, ChartYValue.fromDouble(5.7));
doc.save(getArtifactsDir() + "Charts.ChartDataValues.docx");
public static ChartXValue fromDouble(double value)
ChartXValue instance of the ChartXValueType.DOUBLE type.
Examples:
Shows how to populate chart series with data.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
ChartSeries series1 = chart.getSeries().get(0);
// Clear X and Y values of the first series.
series1.clearValues();
// Populate the series with data.
series1.add(ChartXValue.fromDouble(3.0), ChartYValue.fromDouble(10.0), 10.0);
series1.add(ChartXValue.fromDouble(5.0), ChartYValue.fromDouble(5.0));
series1.add(ChartXValue.fromDouble(7.0), ChartYValue.fromDouble(11.0));
series1.add(ChartXValue.fromDouble(9.0));
ChartSeries series2 = chart.getSeries().get(1);
// Clear X and Y values of the second series.
series2.clear();
// Populate the series with data.
series2.add(ChartXValue.fromDouble(2.0), ChartYValue.fromDouble(4.0));
series2.add(ChartXValue.fromDouble(4.0), ChartYValue.fromDouble(7.0));
series2.add(ChartXValue.fromDouble(6.0), ChartYValue.fromDouble(14.0));
series2.add(ChartXValue.fromDouble(8.0), ChartYValue.fromDouble(7.0));
doc.save(getArtifactsDir() + "Charts.PopulateChartWithData.docx");
public static ChartXValue fromDateTime(java.util.Date value)
ChartXValue instance of the ChartXValueType.DATE_TIME type.public static ChartXValue fromTimeSpan(long value)
ChartXValue instance of the ChartXValueType.TIME type.public static ChartXValue fromMultilevelValue(ChartMultilevelValue value)
ChartXValue instance of the ChartXValueType.MULTILEVEL type.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int getValueType()
ChartXValueType constants.public java.lang.String getStringValue()
public double getDoubleValue()
public java.util.Date getDateTimeValue()
public long getTimeValue()
public ChartMultilevelValue getMultilevelValue()