
Can't create a PlotModel
This discussion was imported from CodePlex
jessimb wrote at 2014-06-14 22:33:
The added or subtracted valued results in a unrepresentable DateTime.
That error gets thrown when I call
var Plot1 = new PlotModel();
Visual Studio points me to missing source code for PlotView.cs
Why is this all of a sudden happening?
Please help!!
Thanks in advance.
That error gets thrown when I call
var Plot1 = new PlotModel();
Visual Studio points me to missing source code for PlotView.cs
Why is this all of a sudden happening?
Please help!!
Thanks in advance.
public PlotModel makePlot(List<double> listNum, List<DateTime> times, List<double> listNum2, List<DateTime> times2)
{
var Plot1 = new PlotModel();
Plot1.LegendSymbolLength = 24;
Plot1.Title = "Two Lines";
var objList = new List<Tuple<DateTime, double>>();
for (int i = 0; i < listNum.Count; ++i)
{
objList.Add(new Tuple<DateTime, double>(times[i], listNum[i]));
}
// define an axis Date
var dateTimeAxis = new DateTimeAxis()
{
Position = AxisPosition.Bottom,
IntervalType = DateTimeIntervalType.Milliseconds,
StringFormat = "hh:mm:ss",
TickStyle = TickStyle.Crossing,
MajorGridlineStyle = LineStyle.Solid,
MinorGridlineStyle = LineStyle.Dot
};
// Convert object client to DataPoint
var points = objList.Select(obj => new DataPoint(DateTimeAxis.ToDouble(obj.Item1), obj.Item2)).ToList();
// Create Line
var linearSeries = new LineSeries()
{
ItemsSource = points,
Color = OxyColor.FromRgb(0,0,0)
};
//pred values
for (int i = 0; i < listNum2.Count; ++i)
{
objList.Add(new Tuple<DateTime, double>(times2[i], listNum2[i]));
}
// Convert object client to DataPoint
var points2 = objList.Select(obj => new DataPoint(DateTimeAxis.ToDouble(obj.Item1), obj.Item2)).ToList();
// Create Line
var linearSeries2 = new LineSeries()
{
ItemsSource = points2,
Color = OxyColor.FromRgb(43, 255, 43)
};
var linearAxis = new LinearAxis()
{
MajorGridlineStyle = LineStyle.Solid,
MinorGridlineStyle = LineStyle.Dot,
Position = AxisPosition.Left,
TickStyle = TickStyle.Crossing
};
Plot1.Axes.Add(dateTimeAxis);
Plot1.Axes.Add(linearAxis);
Plot1.Series.Add(linearSeries);
Plot1.Series.Add(linearSeries2);
return Plot1;
}
jessimb wrote at 2014-06-15 05:59:
The problem was that I was trying to plot a null set.
Customer support service by UserEcho