0
我正在異步添加系列點,這就是爲什麼我失去標準的oxyplot縮放。我想在功能ZoomFunction()
恢復它,但我怎麼能得到從PlotModel.Series
最大和最小Y值PlotModel.Axes[1].Zoom()
?從PlotModel獲取系列
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new Data();
}
}
public class Data
{
public PlotModel PlotModel {get;set;}
public Data()
{
PlotModel = new PlotModel();
AddAxes(PlotModel);
AddHistoryAsync(PlotModel);
}
public void AddHistoryAsync(PlotModel PlotModel)
{
Action<PlotModel> History = new Action<PlotModel>(AddHistory);
IAsyncResult result = History.BeginInvoke(PlotModel, null, null);
}
public void AddAxes(PlotModel PlotModel)
{
var XAxis = new LinearAxis
{
Position = AxisPosition.Bottom
};
var YAxis = new LinearAxis
{
Position = AxisPosition.Left
};
PlotModel.Axes.Add(XAxis);
PlotModel.Axes.Add(YAxis);
}
public void AddHistory(PlotModel PlotModel)
{
System.Threading.Thread.Sleep(3000);
Random rnd = new Random();
LineSeries LS = new LineSeries();
for (int i = 0; i < 10; i++)
{
LS.Points.Add(new DataPoint(i, rnd.Next(1,100)));
}
PlotModel.Series.Add(LS);
ZoomFunction(PlotModel);
PlotModel.InvalidatePlot(false);
}
public void ZoomFunction(PlotModel PlotModel)
{
}
}
}