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

C# C:ZedGraph显示缩放区域的所有点,c#,list,zedgraph,C#,List,Zedgraph,我正在将我的数据绘制到ZedGraph。使用FileStream读取文件。有时我的数据大于200兆字节。要绘制这一数量的数据,我应该计算峰值,或者必须应用一个窗口。但是,我希望看到缩放区域的所有点。请分享任何建议 PointPairList list1 = new PointPairList(); int read; int count = 0; while (file.Position < file.Length)

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

        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 MB到300 MB之间

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

FilteredPointList类的解释很好

您必须以这种方式稍微更改代码:

// 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提供自己的IPointList实现。你可以从中得到启发


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

要使用FilteredPointList,我需要阵列中的所有数据,不是吗?如果是,由于内存不足,我无法一次性将整个数据存储在数组中。谢谢您的回复。我将尝试定制它。