zoukankan      html  css  js  c++  java
  • DynamicDataDisplay 双击获取坐标

    近日由于项目需要,学习了DynamicDataDisplay实现动态曲线图,网上的资料基本上够用了,就是双击获得数据点没能找到资料,只好下载了DynamicDataDisplay的源码来学习。总结共享如下:

    1、xaml定义

                <d3:ChartPlotter Name="chart0" MouseDoubleClick="chart1_MouseDoubleClick">
                    <d3:ChartPlotter.HorizontalAxis>
                        <d3:HorizontalIntegerAxis></d3:HorizontalIntegerAxis>
                    </d3:ChartPlotter.HorizontalAxis>
                    <d3:ChartPlotter.VerticalAxis>
                        <d3:VerticalIntegerAxis></d3:VerticalIntegerAxis>
                    </d3:ChartPlotter.VerticalAxis>
                    <d3:HorizontalAxisTitle Content="rotate(℃)" Name="chart2Title"></d3:HorizontalAxisTitle>
                </d3:ChartPlotter>
    2、变量定义

    private ObservableDataSource<Point> dataSources = new ObservableDataSource<Point>();

    private int t=0;

    3、Window_Loaded中

                  chart0.AddLineGraph(dataSources, Color.Red, 3, 'A');

                  chart0.FitToView();
    4、利用timer加入数据

            DispatcherTimer            timerSine = new DispatcherTimer();
                        timerSine.Tick += new EventHandler(timerSine_Tick);
                        timerSine.Interval = TimeSpan.FromMilliseconds(10);
    timerSine.Start();

     private void timerSine_Tick(object sender, EventArgs e)
            {
                    dataSources.AppendAsync(Dispatcher, new Point(t, 2*t));

                    t+= timerSine.Interval.Milliseconds;

            }

    5、双击获得数据点Point

            private void chart0_MouseDoubleClick(object sender, MouseButtonEventArgs e)
            {
                    ChartPlotter chart = sender as ChartPlotter;
                    Point p = e.GetPosition(this).ScreenToData(chart.Transform);
            }

  • 相关阅读:
    ASP.NET Core: What I learned!
    Entity Framework Core with GraphQL and SQL Server using HotChocolate
    Angular 9 Chart.js with NG2-Charts Demo
    POST调用WCF方法-项目实践
    项目实战-登录速度优化笔记
    MP4视频流base64数据转成Blob对象
    使用Vue+ElementUI实现前端分页
    JS端实现图片、视频时直接下载而不是打开预览
    Dynamic CRM工作流流程实战
    Dynamic CRM插件调试与单元测试
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/5521657.html
Copyright © 2011-2022 走看看