【发布时间】:2020-02-05 22:33:26
【问题描述】:
我正在为一个用户可以在图表上放置数据的项目测试 OxyPlot。
我尝试像这样以编程方式将系列添加到 OxyPlot,但它不起作用:
<Grid>
<oxy:Plot x:Name="TestPlot" Title="" AllowDrop="True">
</oxy:Plot>
</Grid>
On Drop 事件函数:
OxyPlot.Series.LineSeries ls = new OxyPlot.Series.LineSeries();
ls.StrokeThickness = 1;
OxyPlot.Wpf.Axis Xaxis = new OxyPlot.Wpf.LinearAxis();
Xaxis.Maximum = 0;
Xaxis.Minimum = 50;
Xaxis.Position = OxyPlot.Axes.AxisPosition.Bottom;
Xaxis.Title = "time";
TestPlot.Axes.Add(Xaxis);
OxyPlot.Wpf.Axis Yaxis = new OxyPlot.Wpf.LinearAxis();
Xaxis.Maximum = 0;
Xaxis.Minimum = 500;
Xaxis.Position = OxyPlot.Axes.AxisPosition.Left;
Xaxis.Title = "Value";
TestPlot.Axes.Add(Yaxis);
ls.Points.Add(new DataPoint(0, 1));
ls.Points.Add(new DataPoint(10, 100));
ls.Points.Add(new DataPoint(20, 200));
ls.Points.Add(new DataPoint(30, 300));
TestPlot.ActualModel.Series.Add(ls);
TestPlot.InvalidatePlot(true);
但是没有显示 LineSerie。 我错过了一些东西,但是当我用谷歌搜索这个问题时无法弄清楚是什么......
感谢您的帮助。
【问题讨论】:
-
是否触发了drop事件?
-
是的,它被触发了