码迷,mamicode.com
首页 > 其他好文 > 详细

DynamicDataDisplay 双击获取坐标

时间:2016-05-23 22:43:17      阅读:611      评论:0      收藏:0      [点我收藏+]

标签:

近日由于项目需要,学习了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);
        }

DynamicDataDisplay 双击获取坐标

标签:

原文地址:http://www.cnblogs.com/lvdongjie/p/5521657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!