C#:ZedGraph显示缩放区域的所有点 [英] C#: ZedGraph Show All Points of Zoomed Area

查看:1349
本文介绍了C#:ZedGraph显示缩放区域的所有点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我密谋我的数据ZedGraph。使用的FileStream 来读取文件。有时候,我的数据是超过200兆字节以上。要得出这样的数据量我应该计算峰值或必须申请一个窗口。不过,我希望看到缩放区域的所有点。请分享任何建议。

I am plotting to my data to ZedGraph. Using FileStream to read files. Sometimes my data is greater than 200 megabyte. To draw this amount of data i should calculate peak values or must apply a window. However i want to see the all points of zoomed area. Please share any suggestion.

        PointPairList list1 = new PointPairList();
        int read;
        int count = 0;
        while (file.Position < file.Length)
        {
            read = file.Read(mainBuffer, 0, mainBuffer.Length);
            for (int i = 0; i < read / window; i++)
            {
                list1.Add(count++, BitConverter.ToSingle(mainBuffer, i * window));
                count++;
            }
        }
        myCurve1 = zgc.MasterPane.PaneList[1].AddCurve(null, list1, Color.Lime, SymbolType.None);
        myCurve1.IsX2Axis = true;
        zgc.MasterPane.PaneList[1].XAxis.Scale.MaxAuto = true;
        zgc.MasterPane.PaneList[1].XAxis.Scale.MinAuto = true;
        zgc.AxisChange();
        zgc.Invalidate();



窗口= 2048 100之间的文件大小兆到300兆字节。

window=2048 for file size between 100 megabyte to 300 megabyte.

推荐答案

而不是使用 PointPairList ,我会建议使用的 FilteredPointList 来代替。通过这种方式,你可以在每个点保存在内存中,ZedGraph将只显示所必需的展示点。

Instead of using a PointPairList, I would suggest to use a FilteredPointList instead. By this way, you can keep every points in memory, ZedGraph will only show the points that are necessary for display.

FilteredPointList 类是很好的解释这里

您将不得不改变你的代码有点是这样的:

You will have to change your code a bit this way:

// Load the X, Y points in two double arrays
// ...

var list1 = new FilteredPointList(xArray, yArray);

// ...

// Use the ZoomEvent to adjust the bounds of the filtered point list

void zedGraphControl1_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState)
{
    // The maximum number of point to displayed is based on the width of the graphpane, and the visible range of the X axis
    list1.SetBounds(sender.GraphPane.XAxis.Scale.Min, sender.GraphPane.XAxis.Scale.Max, (int)zgc.GraphPane.Rect.Width);

    // This refreshes the graph when the button is released after a panning operation
    if (newState.Type == ZoomState.StateType.Pan)
        sender.Invalidate();
}

修改

如果你不能没有在内存运行所有的点,那么你将不得不使用的逻辑,以提供自己的 IPointList 实施ZedGraph你的代码上面的描述。您可以从 FilteredPointList激发本身。

If you can't not host all the points in memory, then you will have to provide your own IPointList implementation for ZedGraph using the logic in the code you describe above. You can inspire from the FilteredPointList itself.

我会使用的setBounds 方法从磁盘预加载点的基础上,抽取算法你已经实现,使用最小值,最大值和在参数MaxPts。

I would use the SetBounds method to preload the points from the disk, based on the decimation algorithm you already implemented, using the min, max and MaxPts in parameters.

这篇关于C#:ZedGraph显示缩放区域的所有点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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