[英]OxyPlot InvalidatePlot not refreshing data
I'm trying to dynamically add points to a LineSeries
, but it doesn't show up after invalidating the plot. 我正在尝试向LineSeries
动态添加点,但是在使绘图无效后它不会显示。 Using newest OxyPlot version 2014.1.301.1, straight from NuGet. 使用直接来自NuGet的最新OxyPlot版本2014.1.301.1。 It works if I set the ItemSource
to a new list, but editing the Items property does nothing. 如果我将ItemSource
设置为新列表,它将起作用,但是编辑Items属性不会执行任何操作。
XAML: XAML:
<Window x:Class="SparrowTesting.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sparrow="http://sparrowtoolkit.codeplex.com/wpf"
xmlns:oxy="http://oxyplot.codeplex.com"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<oxy:Plot Title="OxyTest" x:Name="chart">
<oxy:Plot.Series>
<oxy:LineSeries></oxy:LineSeries>
</oxy:Plot.Series>
</oxy:Plot>
<Button Grid.Row="1" x:Name="button1" Click="button1_Click">
<TextBlock>GO</TextBlock>
</Button>
</Grid>
</Window>
Code: 码:
chart.Series[0].Items.Add(new DataPoint(1, 2));
chart.InvalidatePlot(true);//Does nothing
Ignore the Items
property and work only with the ItemSource
, it then works like a charm. 忽略Items
属性,仅使用ItemSource
,然后将其像ItemSource
一样工作。
chart.Series[0].ItemsSource = new List<DataPoint>();
(chart.Series[0].ItemsSource as List<DataPoint>).Add(new DataPoint())
//Profit
I haven't been able to work chart.InvalidatePlot(true);
我无法工作chart.InvalidatePlot(true);
but chart.Series.Clear();
但是chart.Series.Clear();
has worked well. 运作良好。 I would try placing it before your new data points with something like this: 我会尝试将其放置在新数据点之前,如下所示:
chart.Series.Clear();
chart.Series[0].Items.Add(new DataPoint(1, 2));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.