ChartXValue

ChartXValue class

Represents an X value for a chart series.

public class ChartXValue

Properties

NameDescription
DateTimeValue { get; }Gets the stored datetime value.
DoubleValue { get; }Gets the stored numeric value.
MultilevelValue { get; }Gets the stored multilevel value.
StringValue { get; }Gets the stored string value.
TimeValue { get; }Gets the stored time value.
ValueType { get; }Gets the type of the X value stored in the object.

Methods

NameDescription
static FromDateTime(DateTime)Creates a ChartXValue instance of the DateTime type.
static FromDouble(double)Creates a ChartXValue instance of the Double type.
static FromMultilevelValue(ChartMultilevelValue)Creates a ChartXValue instance of the Multilevel type.
static FromString(string)Creates a ChartXValue instance of the String type.
static FromTimeSpan(TimeSpan)Creates a ChartXValue instance of the Time type.
override Equals(object)Gets a flag indicating whether the specified object is equal to the current X value object.
override GetHashCode()Gets a hash code for the current X value object.

Remarks

This class contains a number of static methods for creating an X value of a particular type. The ValueType 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();

Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;
ChartSeries series1 = chart.Series[0];

// Clear X and Y values of the first series.
series1.ClearValues();

// Populate the series with data.
series1.Add(ChartXValue.FromDouble(3), ChartYValue.FromDouble(10));
series1.Add(ChartXValue.FromDouble(5), ChartYValue.FromDouble(5));
series1.Add(ChartXValue.FromDouble(7), ChartYValue.FromDouble(11));
series1.Add(ChartXValue.FromDouble(9), ChartYValue.FromDouble(17));

ChartSeries series2 = chart.Series[1];

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

// Populate the series with data.
series2.Add(ChartXValue.FromDouble(2), ChartYValue.FromDouble(4));
series2.Add(ChartXValue.FromDouble(4), ChartYValue.FromDouble(7));
series2.Add(ChartXValue.FromDouble(6), ChartYValue.FromDouble(14));
series2.Add(ChartXValue.FromDouble(8), ChartYValue.FromDouble(7));

doc.Save(ArtifactsDir + "Charts.PopulateChartWithData.docx");

See Also