I have data with date against data so I wanted to plot LineSeries of it. I am using following code I wanted to put Date on X-axis and bind my data with my dates.
public class LineChart
{
public PlotModel MyModel { get; set; }
DateTime from_date, end_date;
public LineChart()
{
var plotModel = new PlotModel {
Title="Multiview"
};
var xAxis = new DateTimeAxis {
StringFormat="MM/DD/yyyy"
};
var linearAxis = new LinearAxis();
plotModel.Axes.Add(xAxis);
plotModel.Axes.Add(linearAxis);
var series1 = new LineSeries {
StrokeThickness=3,
MarkerType=MarkerType.Cross,
MarkerStroke=OxyColors.Aqua,
MarkerSize=4,
MarkerStrokeThickness=1,
DataFieldX="Date",
DataFieldY="Value",
Smooth=true
};
series1.Points.Add(new DataPoint(1.2,4.5));
series1.Points.Add(new DataPoint(2.2, 5.8));
series1.Points.Add(new DataPoint(4.4, 8.7));
plotModel.Series.Add(series1);
this.MyModel = plotModel;
}
Since DataPoint
accepts only (double,double)
data type, then How to I plot Date against my date??