获取关于MS图一个缩放视图点 [英] Get points on a zoomed view on MS Chart

查看:213
本文介绍了获取关于MS图一个缩放视图点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Microsoft图表控件,并允许用户选择。 我希望能够当用户选择一个区域进行放大,以获得当前的缩放(查看)区域的数据点。如何任何想法才能做到这一点?我使用的.Net 4.5。

I'm using Microsoft Chart controls and allowing user selection. I want to be able to get the data points of the current zoomed (viewed) area once the user selects an area to zoom. Any ideas on how can this be done? I'm using .Net 4.5.

推荐答案

下面是发送当前可见数据点到控制台输出的一个例子:

Here is an example that sends the currently visible DataPoints to the Console output:

// two shortcuts
ChartArea CA = chart1.ChartAreas[0];
Series S = chart1.Series[0];

// these are the X-Values of the zoomed portion:
double min = CA.AxisX.ScaleView.ViewMinimum;
double max = CA.AxisX.ScaleView.ViewMaximum;

// these are the respective DataPoints:
    DataPoint pt0 = S.Points.Select(x => x)
                     .Where(x => x.XValue >= min)
                     .DefaultIfEmpty(S.Points.First()).First();
    DataPoint pt1 = S.Points.Select(x => x)
                     .Where(x => x.XValue <= max)
                     .DefaultIfEmpty(S.Points.Last()).Last();

// test output:
for (int i = S.Points.IndexOf(pt0); i < S.Points.IndexOf(pt1); i++)
    Console.WriteLine(i + " :  " + S.Points[i]);

您可以在 SelectionRangeChanged 事件把这个。

这篇关于获取关于MS图一个缩放视图点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆