当新点来自后端时,我将 LineGraph 与数据源进行数据绑定,问题是网格未刷新,您可以执行绘图仪.FitToView() 来刷新它,但这也适合新图形到绘图仪窗口,这是如果您放大并平移到图表上的特定点,则非常令人反感,因为它将缩小以适合图表上的图形...那么,有没有办法在数据绑定后刷新它(您认为数据绑定会刷新它+..
我还可以考虑更改WPF图表,我有一个要求,它是你可以在图表上定义可拖动的点
I databind the LineGraph with a datasource when new points comes from backend, the problem is that the grid isnt refreshed, you can do a plotter.FitToView() to get it to refresh but that also fits the new graph to the plotter window this is very irretating if you have zoomed in and panned to a specific point on the chart because it will zooom out to fit the graph on the chart... So, is there a way to refresh it after databind (You think that a databind would refresh it+..
I can also consider changing WPF chart enterily i have one requirement and its that you can define draggable points on the chart
发布评论
评论(3)
我发现执行此操作的最佳方法是在后面的代码中拥有一个代表数据源的属性,并将图表的数据源绑定到该属性。让您的代码实现 INotifyPropertyChanged 并在每次更新或重新分配数据源时调用 OnPropertyChanged。这将迫使绘图仪观察绑定并重新绘制图形。
例子:
The best way that I have found to do this, is to have a Property in your code behind that represents the DataSource and bind the chart's DataSource to that property. Have your code behind implement INotifyPropertyChanged and call OnPropertyChanged every time you update or re-assign your data source. This will force the plotter to observe the binding and redraw your graph.
Example:
WPF D3 图表的界面完全是编程式的,即您必须“推送”更新,而不是使用绑定来自动刷新 UI。作为替代方案,也许可以考虑 Visiblox 图表,这里有一篇博客文章描述了如何根据需要使数据点可拖动:
http://www.visiblox.com/blog/2011/11/creating-a-custom-behaviour-part-3-the-finale
披露:我在创建 Visiblox 图表的公司工作。
The interface to the WPF D3 chart is entirely programmatic, i.e. you have to 'push' updates rather than use binding to automatically refresh the UI. As an alternative perhaps consider Visiblox chart, there is a blog post here which describes how to make datapoints draggable as you require:
http://www.visiblox.com/blog/2011/11/creating-a-custom-behaviour-part-3-the-finale
Disclosure: I work for the company that created Visiblox charts.
您是否尝试在添加新数据时重新分配数据集合?我注意到这是更新我的图表所必需的。例如,在将新对象添加到我的集合后,我会使用这个:
这开始工作,我认为这是因为图表仅响应 OnPropertyChanged 而不是 OnCollectionChanged,或类似的效果。不过,这条线毫无意义,而且会减慢大量数据的显示速度。
编辑:这包括上面杰森的回答,以通知更改!
Have you tried reassigning the data collection when you add new data? I noticed this was necessary to update my graph. For example, after adding new objects to my collection, I'd use this:
This started working, and I thought it was because the chart only responded to OnPropertyChanged and not OnCollectionChanged, or something to that effect. The line is painfully pointless and slows down the display for large amounts of data, though.
Edit: This is including Jason's answer above to notify of changes!