ChartXValue

Inheritance: java.lang.Object

public class ChartXValue

Represents an X value for a chart series.

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.

Methods

MethodDescription
equals(Object obj)Gets a flag indicating whether the specified object is equal to the current X value object.
fromDateTime(Date value)Creates a ChartXValue instance of the ChartXValueType.DATE_TIME type.
fromDouble(double value)Creates a ChartXValue instance of the ChartXValueType.DOUBLE type.
fromMultilevelValue(ChartMultilevelValue value)Creates a ChartXValue instance of the ChartXValueType.MULTILEVEL type.
fromString(String value)Creates a ChartXValue instance of the ChartXValueType.STRING type.
fromTimeSpan(long value)Creates a ChartXValue instance of the ChartXValueType.TIME type.
getDateTimeValue()Gets the stored datetime value.
getDoubleValue()Gets the stored numeric value.
getMultilevelValue()Gets the stored multilevel value.
getStringValue()Gets the stored string value.
getTimeValue()Gets the stored time value.
getValueType()Gets the type of the X value stored in the object.
hashCode()

equals(Object obj)

public boolean equals(Object obj)

Gets a flag indicating whether the specified object is equal to the current X value object.

Parameters:

ParameterTypeDescription
objjava.lang.Object

Returns: boolean

fromDateTime(Date value)

public static ChartXValue fromDateTime(Date value)

Creates a ChartXValue instance of the ChartXValueType.DATE_TIME type.

Parameters:

ParameterTypeDescription
valuejava.util.Date

Returns: ChartXValue

fromDouble(double value)

public static ChartXValue fromDouble(double value)

Creates a ChartXValue instance of the ChartXValueType.DOUBLE type.

Examples:

Shows how to populate chart series with data.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder();

 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));
 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), ChartYValue.fromDouble(17.0));

 ChartSeries series2 = chart.getSeries().get(1);

 // Clear X and Y values of the second series.
 series2.clearValues();

 // 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");
 

Parameters:

ParameterTypeDescription
valuedouble

Returns: ChartXValue

fromMultilevelValue(ChartMultilevelValue value)

public static ChartXValue fromMultilevelValue(ChartMultilevelValue value)

Creates a ChartXValue instance of the ChartXValueType.MULTILEVEL type.

Parameters:

ParameterTypeDescription
valueChartMultilevelValue

Returns: ChartXValue

fromString(String value)

public static ChartXValue fromString(String value)

Creates a 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");
 

Parameters:

ParameterTypeDescription
valuejava.lang.String

Returns: ChartXValue

fromTimeSpan(long value)

public static ChartXValue fromTimeSpan(long value)

Creates a ChartXValue instance of the ChartXValueType.TIME type.

Parameters:

ParameterTypeDescription
valuelong

Returns: ChartXValue

getDateTimeValue()

public Date getDateTimeValue()

Gets the stored datetime value.

Returns: java.util.Date - The stored datetime value.

getDoubleValue()

public double getDoubleValue()

Gets the stored numeric value.

Returns: double - The stored numeric value.

getMultilevelValue()

public ChartMultilevelValue getMultilevelValue()

Gets the stored multilevel value.

Returns: ChartMultilevelValue - The stored multilevel value.

getStringValue()

public String getStringValue()

Gets the stored string value.

Returns: java.lang.String - The stored string value.

getTimeValue()

public long getTimeValue()

Gets the stored time value.

Returns: long - The stored time value.

getValueType()

public int getValueType()

Gets the type of the X value stored in the object.

Returns: int - The type of the X value stored in the object. The returned value is one of ChartXValueType constants.

hashCode()

public int hashCode()

Returns: int