2013-10-08 2 views
1

ZedGraph에 데이터를 플로팅하고 있습니다. FileStream을 사용하여 파일을 읽습니다. 가끔 내 데이터가 200 메가 바이트보다 큽니다. 이 양의 데이터를 그리려면 필자는 피크 값을 계산하거나 창을 적용해야합니다. 그러나 나는 확대 된 영역의 모든 지점을보고 싶다. 제안 사항을 공유하십시오.C# : ZedGraph 확대/축소 된 모든 영역 표시

 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 메가 바이트에서 300 메가 바이트 사이 인 경우.

답변

0

대신 PointPairList을 사용하는 대신 FilteredPointList을 사용하는 것이 좋습니다. 이 방법으로 모든 포인트를 메모리에 유지할 수 있습니다. ZedGraph는 디스플레이에 필요한 포인트 만 표시합니다.

FilteredPointList 클래스는 잘 설명되어있다. here.

당신은 조금 당신의 코드를 이런 식으로 변경해야합니다

: 당신은 메모리의 모든 포인트를 호스팅하지 할 수없는 경우, 당신은 제공해야합니다

// 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 구현을 소유하십시오. FilteredPointList 그 자체에서 영감을 얻을 수 있습니다.

SetBounds 메서드를 사용하여 이미 구현 한 데시 메이션 알고리즘에 따라 매개 변수의 최소, 최대 및 최대 값을 사용하여 디스크에서 포인트를 미리로드합니다.

+0

FilteredPointList를 사용하려면 배열에있는 모든 데이터가 필요합니까? 그렇지 않습니다. 그렇다면 메모리 부족으로 인해 전체 데이터를 한 번에 배열에 저장할 수 없습니다. – Blast

+0

답장을 보내 주셔서 감사합니다. 나는 그것을 사용자 정의하려고합니다. – Blast