首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C#:ZedGraph显示缩放区域的所有点

C#:ZedGraph显示缩放区域的所有点
EN

Stack Overflow用户
提问于 2013-10-08 14:39:46
回答 1查看 1.5K关注 0票数 1

我正在绘制我的数据到ZedGraph。使用FileStream读取文件。有时我的数据大于200兆字节。要绘制这个数据量,我应该计算峰值,或者必须应用一个窗口。不过,我想看看缩放区域的所有点。请分享任何建议。

代码语言:javascript
复制
        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();

window=2048用于文件大小在100 to至300 to之间。

EN

回答 1

Stack Overflow用户

发布于 2013-10-08 20:49:19

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

FilteredPointList类得到了很好的解释,这里

您必须以这样的方式更改代码:

代码语言:javascript
复制
// 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();
}

编辑

如果不能托管内存中的所有点,那么必须使用上面描述的代码中的逻辑为ZedGraph提供自己的ZedGraph实现。您可以从FilteredPointList本身得到启发。

我将使用SetBounds方法从磁盘预加载点,基于您已经实现的抽取算法,使用参数中的min、max和MaxPts。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19250775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档