简体   繁体   English

动态数据在具有同步X轴的实时图表上显示缩放和工具提示

[英]DynamicDataDisplay zoom and tooltips on realtime charts with syncronous X axis

Some time ago I posted the question about synchronous charts. 前一段时间,我发布了有关同步图表的问题 I found the solution here, but I still have some problems. 我在这里找到了解决方案,但仍然存在一些问题。

  • I need to zoom in and out on Y axis on StrokeChart to see my date. 我需要在StrokeChart的Y轴上放大和缩小以查看日期。 I don't know why, but the range doesn't change on next added point. 我不知道为什么,但是下一个添加点的范围不会改变。 Actually range is 0-1 on Y axis. 实际上,Y轴上的范围是0-1。 It's strange, but I can live with that 很奇怪,但我可以忍受
  • The second question is: how to configure zoom on chart area? 第二个问题是:如何配置放大图表区域? I want it to zoom only Y axis when I scroll up/down. 向上/向下滚动时,我只希望它缩放Y轴。
  • And last, but not least: How to make realtime tooltips on chart which is build using ObservableCollection? 最后但并非最不重要的一点:如何在使用ObservableCollection构建的图表上制作实时工具提示? It can be done for EnumerableDataSource easy. 可以轻松实现EnumerableDataSource。 you can check this and this . 你可以检查这个这个 I tried to do thing described by user "Thecentury", but it doesn't work. 我尝试执行用户“ Thecentury”描述的操作,但不起作用。 I even added method AddMapping to ObservableCollection and rebuilt the library, but it still doesn't work. 我什至在ObservableCollection中添加了AddMapping方法并重建了库,但仍然无法正常工作。 So I don't know what to do next. 所以我不知道下一步该怎么做。

I appreciate for any help and advice. 感谢您的帮助和建议。 Thank you 谢谢

Regarding zooming I think I managed to solve the problem. 关于缩放,我认为我设法解决了这个问题。

In MouseNavigation.cs add new properties MouseNavigation.cs中添加新属性

// 2014-02-22 - MPEKALSKI - added property to make possible
                         limiting on zoom on only one axis
private bool? _zoomX;
/// <summary>
/// Property for allowing/disallowing for zoom along X axis. By default allowed (true).
/// </summary>
public bool zoomX
{
    get { return _zoomX ?? true; }
    set { _zoomX = value; }
}
private bool? _zoomY;
/// <summary>
/// Property for allowing/disallowing for zoom along Y axis. By default allowed (true).
/// </summary>
public bool zoomY
{
    get { return _zoomY ?? true; }
    set { _zoomY = value; }
}     

In the same class modify the method 在同一个类中修改方法

private void MouseWheelZoom(Point mousePos, int wheelRotationDelta)

by substituting 通过代替

Viewport.Visible = Viewport.Visible.Zoom(zoomTo, zoomSpeed);

with

    // 2014-02-23 - MPEKALSKI - if we do not allow for change in Y
    //                          then keep the old value, by analogy for X
    Rect zoomedRect = Viewport.Visible.Zoom(zoomTo, zoomSpeed);
    if (zoomY == false) { zoomedRect.Y = Viewport.Visible.Y; 
                          zoomedRect.Height = Viewport.Visible.Height; }
    if (zoomX == false) { zoomedRect.X = Viewport.Visible.X;
                          zoomedRect.Width = Viewport.Visible.Width; }
    Viewport.Visible = zoomedRect;

The use now is pretty straightforward given chartPlotter object just set properties zoomY or zoomX to false to prevent zooming along this axis. 给定chartPlotter对象只需将属性zoomY或zoomX设置为false即可防止沿该轴缩放,现在使用起来非常简单。

chartPlotter2.MouseNavigation.zoomY = false;

I do not know is it the most optimal solution, but it works for me. 我不知道这是最理想的解决方案,但对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM