0

List<ChartData>カスタム コントロール用に大量のデータを 1 つに処理する必要があります。List Count 80,00,000 に達した後、約 300 万ポイントで正常に動作します。 Out of memory エラーがスローされます。リストのカウント制限はありますか? はいは、リストではなく他のコレクションを使用することを意味します。

大量のデータをメモリにロードするためのより良い手法はありますか? 問題は次の関数にあります。ChartIndexedDataPoint.Count が 30,00,000 を超えた場合

 protected override void CalculateSegments(ChartSeries series, ChartIndexedDataPoint[] points)
    {
        double[] yCoef={0};
        IChartDataPoint startPoint = null;
        IChartDataPoint endPoint = null;
        ChartPoint startControlPoint = null;
        ChartPoint endControlPoint = null;
        if (points.Length >= 2)
        {
            NaturalSpline(points, out yCoef);
            if (series.ShowEmptyPoints == false && series.Area.EnableLazyLoading == true)
            {
                allpoints = new List<IChartDataPoint>();
                if (series.ActualYAxis.IsAutoSetRange == true || series.ActualXAxis.IsAutoSetRange == true)
                {
                    series.Segments.Clear();
                    series.Adornments.Clear();

                    for (int i = 0, count = points.Length; i < count - 1; i++)
                    {
                        startPoint = points[i].DataPoint;
                        endPoint = points[i + 1].DataPoint;
                        GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                        allpoints.Add(startPoint);
                        allpoints.Add(startControlPoint);
                        allpoints.Add(endControlPoint);
                        allpoints.Add(endPoint);
                    }
                    series.Segments.Add(new ChartFastSplineSegment(allpoints, points, series)); 
                    return;
                }
                if (series.Segments.Count != 0)
                {
                    ChartFastSplineSegment segment = ((ChartFastSplineSegment)series.Segments[0]);

                    if (segment.Points != null && segment.Points.Count < points.Length)
                    {
                        segment.GetSegmet(points[points.Length - 1].DataPoint, series);
                    }
                    else if (segment.Points == null || segment.Points.Count > points.Length)
                    {                           
                        for (int i = 0, count = points.Length; i < count - 1; i++)
                        {
                            startPoint = points[i].DataPoint;
                            endPoint = points[i + 1].DataPoint;
                            GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                            allpoints.Add(startPoint);
                            allpoints.Add(startControlPoint);
                            allpoints.Add(endControlPoint);
                            allpoints.Add(endPoint);
                        }
                        segment.UpdateSegment(allpoints, series);
                        segment.refresh = true;
                    }
                }
                else
                {                        
                    for (int i = 0, count = points.Length; i < count - 1; i++)
                    {
                        startPoint = points[i].DataPoint;
                        endPoint = points[i + 1].DataPoint;
                        GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                        allpoints.Add(startPoint);
                        allpoints.Add(startControlPoint);
                        allpoints.Add(endControlPoint);
                        allpoints.Add(endPoint);
                    }
                    series.Segments.Add(new ChartFastSplineSegment(allpoints, points, series)); 
                }
            }
            else if (series.Segments.Count == 0 || series.internaldata_modified || allpoints.Count > points.Length)
            {
                allpoints = new List<IChartDataPoint>();
                series.Segments.Clear();
                series.Adornments.Clear();
                ChartIndexedDataPoint[] pts = points;
                List<ChartIndexedDataPoint> tempPointArray = new List<ChartIndexedDataPoint>();                    
                for (int i = 0; i < pts.Length-1; i++)
                {
                    switch (pts[i].DataPoint.EmptyPoint)
                    {
                        case false:
                            {
                                startPoint = points[i].DataPoint;
                                endPoint = points[i + 1].DataPoint;
                                GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                                allpoints.Add(startPoint);
                                allpoints.Add(startControlPoint);
                                allpoints.Add(endControlPoint);
                                allpoints.Add(endPoint);
                                tempPointArray.Add(pts[i]);
                                break;
                            }
                        case true:
                            {
                                if (allpoints.Count > 0)
                                {
                                    if (i < points.Length)
                                    {
                                        startPoint = points[i].DataPoint;
                                        endPoint = points[i + 1].DataPoint;
                                        GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                                        allpoints.Add(startPoint);
                                        allpoints.Add(startControlPoint);
                                        allpoints.Add(endControlPoint);
                                        allpoints.Add(endPoint);
                                    }
                                    tempPointArray.Add(points[i]);

                                }
                                break;
                            }
                    }
                }
                if (tempPointArray.Count != 0 && allpoints.Count != 0)
                {
                    series.Segments.Add(new ChartFastSplineSegment(allpoints, tempPointArray.ToArray(), series));
                }
            }
            if (series.Segments.Count > 0)
            {
                List<ChartIndexedDataPoint> tempPointArray = new List<ChartIndexedDataPoint>();
                List<ChartIndexedDataPoint> pts = points.ToList();

                if (!series.Contains_emptypt)
                {
                    int cnt = (allpoints.Count+4)/4;
                    while ((allpoints.Count + 4) / 4 != points.Length && (allpoints.Count + 4) / 4 < points.Length)
                    {
                        startPoint = points[cnt-1].DataPoint;
                        endPoint = points[cnt].DataPoint;
                        GetBezierControlPoints(startPoint, endPoint, yCoef[cnt-1], yCoef[cnt], out startControlPoint, out endControlPoint);
                        allpoints.Add(startPoint);
                        allpoints.Add(startControlPoint);
                        allpoints.Add(endControlPoint);
                        allpoints.Add(endPoint);
                        cnt++;
                    }
                }
                (series.Segments[0] as ChartFastSplineSegment).m_points = allpoints;
                if (series.ActualXAxis.IsAutoSetRange || series.Zoomactionenabled)
                {                        
                    double X_MAX = allpoints.Max(x => x.X);
                    double X_MIN = allpoints.Min(x => x.X);
                    (series.Segments[0] as ChartFastSplineSegment).xRange = new DoubleRange(X_MIN, X_MAX);//xRange + cdpt.X;
                    if (series.ActualXAxis.RangeCalculationMode == RangeCalculationMode.AdjustAcrossChartTypes)
                    {
                        (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.Start - 0.5;
                        (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.End + 0.5;
                    }
                    (series.Segments[0] as ChartFastSplineSegment).SetRange(series);

                }
                if (series.ActualYAxis.IsAutoSetRange || series.Zoomactionenabled)
                {                        
                    double Y_MAX = allpoints.Max(y => y.Y);
                    double Y_MIN = allpoints.Min(y => y.Y);

                    (series.Segments[0] as ChartFastSplineSegment).yRange = new DoubleRange(Y_MIN, Y_MAX);//yRange + cdpt.Y;

                    if (series.ActualXAxis.RangeCalculationMode == RangeCalculationMode.AdjustAcrossChartTypes)
                    {
                        (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.Start - 0.5;
                        (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.End + 0.5;
                    }

                    (series.Segments[0] as ChartFastSplineSegment).SetRange(series);
                    if (series.Zoomactionenabled)
                    {
                        series.Zoomactionenabled = false;
                    }
                }
            }
        }     
    }
4

3 に答える 3

2

メモリの問題がなくても、なんらかの方法で要約せずに、そのすべての情報を一度に表示する有意義な方法はありません。1920x1080 画面のピクセルよりも多くのデータ ポイントがあります。ユースケースに適したポイント数を減らす方法を考える必要があります。

于 2012-11-28T17:41:19.100 に答える
2

アプリケーションでデータ仮想化を利用できますか? http://www.codeproject.com/Articles/34405/WPF-Data-Virtualization

于 2012-11-28T17:23:15.360 に答える
0

最後に、私はこの問題を解決しました。

allpoints.Add(startPoint);
allpoints.Add(startControlPoint);
allpoints.Add(endControlPoint);
allpoints.Add(endPoint);

allpoints を 4 つのリストに

startPoints<IChartDataPoint>
endControlPointS<IChartDataPoint>
endControlPointS<IChartDataPoint>
endPointS<IChartDataPoint>
于 2012-11-29T16:51:28.273 に答える