0

我需要能够绘制与 CPTScatterPlotInterpolationLinear 具有相同 Y 坐标的连续线段,以及与 CPTScatterPlotInterpolationCurved 不具有相同 Y 坐标的线段。由于 CPTScatterPlotInterpolationCurved 绘制所有弯曲的线。我目前正在通过添加多个地块来做到这一点。

public List<CorrectedGraphPoints> GetCorrectDataPoints(List<PointF> dataSource)
        {
            int lastIndex = 0;
            bool shouldLoop = true;
            CPTScatterPlotInterpolation interpolation = CPTScatterPlotInterpolation.Curved;
            List<CorrectedGraphPoints> OuterList = new List<CorrectedGraphPoints> ();

            if (dataSource [0].Y == dataSource [1].Y)
                interpolation = CPTScatterPlotInterpolation.Linear;

            while (lastIndex+1 != dataSource.Count) {
                OuterList.Add (new CorrectedGraphPoints (interpolation));

                while (shouldLoop) 
                {

                    OuterList[OuterList.Count -1].Add(dataSource[lastIndex]);
                    if ((lastIndex + 1) < dataSource.Count) {
                        if (interpolation == CPTScatterPlotInterpolation.Linear) {
                            if (dataSource [lastIndex].Y != dataSource [lastIndex + 1].Y) {
                                interpolation = CPTScatterPlotInterpolation.Curved;
                                shouldLoop = false;
                                break;
                            }
                        }

                        if (interpolation == CPTScatterPlotInterpolation.Curved) {
                            if (dataSource [lastIndex].Y == dataSource [lastIndex + 1].Y) {
                                interpolation = CPTScatterPlotInterpolation.Linear;
                                shouldLoop = false;
                                break;
                            }
                        }
                    } 
                    else {
                        shouldLoop = false;
                        break;
                    }

                    if (shouldLoop)
                        lastIndex++;
                }

                shouldLoop = true;
            }

            return OuterList;


        }



public class CorrectedGraphPoints
    {
        private List<PointF> points;
        public List<PointF> Points { get { return points; } }

        private CPTScatterPlotInterpolation interpolation;
        public CPTScatterPlotInterpolation Interpolation { get { return interpolation; } }


        public CorrectedGraphPoints(CPTScatterPlotInterpolation interpolation)
        {
            this.interpolation = interpolation;
            points = new List<PointF> ();
        }

        public void Add(PointF point)
        {
            points.Add (point);
        }
    }

然而,创建多个使用填充的绘图会大大降低应用程序的速度。我想知道我是否可以限制我这样做的程度?我还没有找到改变部分插值的方法??这只是核心情节的问题还是我的逻辑或代码有问题?

4

1 回答 1

0

另一种可能的解决方案是在数据中添加额外的点来绘制曲线部分。这将允许您只使用一个情节。所需的附加点数取决于几个因素,包括绘图的大小和用于绘制线条的线条样式。

于 2013-09-05T01:06:45.213 回答