OxyPlot disappear after RefreshPlot(true)
This discussion was imported from CodePlex
scheang wrote at 2013-04-11 18:59:
Hi ALL, I have a program which takes OxyDataItem and plot it using LineSeries (DateTime Axis vs LinearAxis). However once I have used the function on RefreshPlot(true) the plot seems to disappear. Any idea why would this happen?
public void MyOxyPlot(string GraphName, string GraphType, DateTime StartDate, DateTime EndDate)
public void MyOxyPlot(string GraphName, string GraphType, DateTime StartDate, DateTime EndDate)
{
var tmp = new PlotModel(GraphName + " " + GraphType);
tmp.Axes.Add(new OxyPlot.Axes.LinearAxis(OxyPlot.Axes.AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot });
tmp.Axes.Add(new OxyPlot.Axes.DateTimeAxis(OxyPlot.Axes.AxisPosition.Bottom, StartDate, EndDate, null, null, OxyPlot.Axes.DateTimeIntervalType.Hours)
{
MajorGridlineStyle = LineStyle.Solid,
Angle = 90,
StringFormat = "yyyy",
MajorStep = 365.0,
//MajorStep = 1.0 / 24 / 2, // 1/24 = 1 hour, 1/24/2 = 30 minutes
IsZoomEnabled = true,
MaximumPadding = 0,
MinimumPadding = 0,
//TickStyle = TickStyle.None
});
var ls = new OxyPlot.Series.LineSeries("Line1") { DataFieldX = "X", DataFieldY = "Y" };
List<OxyDataItem> ii = new List<OxyDataItem>();
foreach (DataRow dtr in TSDataTable.Rows)
{
if ((DateTime)dtr["Time Stamp"] >= StartDate && (DateTime)dtr["Time Stamp"] <= EndDate)
ii.Add(new OxyDataItem { X = (DateTime)dtr["Time Stamp"], Y = (double)dtr[GraphType] });
ls.ItemsSource = ii;
tmp.Series.Add(ls);
if (MyMDDPlotModel == null)
{
MyMDDPlotModel = tmp;
MyMDDPlotModel.InvalidatePlot(false);
MyMDDPlotModel.RefreshPlot(true);
}
}
Customer support service by UserEcho