Y-Axis
A timeseries chart can have one or more Y-axes. The latter situation occurs when you need to build a multi-series or multivariate chart.
A Y-axis in a timeseries chart looks as shown in the image below:
Configure Y-axis
Use the YAxes
object of the timeSeries
instance of the TimeSeriesChart
class to define a Y-axis. After that, use the following to configure the axes.
Set the aggregation function using the
Aggregation
property ofYAxes
object. which accepts enum of typeTimeSeriesAggregation.Function
.TimeSeriesAggregation.Function
can accept one of the enum values fromSUM
,COUNT
,MAX
,MIN
,LAST
,FIRST
,AVERAGE
,VARIANCE
orSTDDEV
.Set the axis type using the
AxisType
property of theYAxes
object, which accepts enum of typeTimeSeriesYAxisObject.YAxisType
.TimeSeriesYAxisObject.YAxisType
can accept the following enum values:LINEAR
LOG
Set a prefix for the values on the Y-axis using the
Prefix
property of theFormat
object.Prefix
accepts a string type parameter.Set a suffix for the values on the Y-axis using the
Suffix
property of theFormat
object.Suffix
accepts a string type parameter.Set the maximum value for the Y-axis using the double type
Max
property of theYAxes
object.Set the minimum value for the Y-axis using the double type
Min
property of theYAxes
object.Set the plot type using the
PlotType
property of theYAxes
object, which accepts enum of typeTimeSeriesYAxisObject.SeriesPlotType
.TimeSeriesYAxisObject.SeriesPlotType
can accept the enum values fromLINE
,COLUMN
,AREA
,SPLINE
,STEPLINE
,OHLC
andCANDLESTICK
.Set the Y-axis title using the string type
Title
property of theYAxes
object.Finally, to set the plot type for the chart, use the
Add()
method of thePlot
object.
Refer to the code given below:
/* add different configuration */
timeSeries.YAxes.Aggregation = TimeSeriesAggregation.Function.COUNT;
timeSeries.YAxes.AxisType = TimeSeriesYAxisObject.YAxisType.LINEAR;
timeSeries.YAxes.Format.Prefix = "$";
timeSeries.YAxes.Format.Suffix = "K";
timeSeries.YAxes.Max = 30000;
timeSeries.YAxes.Min = 10000;
timeSeries.YAxes.PlotType = TimeSeriesYAxisObject.SeriesPlotType.AREA;
timeSeries.YAxes.Title = "Total Sales";
timeSeries.YAxes.Plot.Add("GDP", TimeSeriesYAxisObject.YAxisType.LOG, TimeSeriesAggregation.Function.LAST);
The chart will look as shown below: