核心图混合CPTscatterPlot插值曲线和CPTscatterplot插值线性



我需要能够绘制与CPTScatterPlotInterpolationLinear具有相同Y坐标的连续线段,以及与CPTscatter PlotInterpolation Curve不具有相同Y座标的连续线段。如CPTScatterPlot插值曲线绘制所有曲线。我目前正在通过添加多个绘图来完成此操作。

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);
        }
    }

然而,创建多个使用填充的绘图会大大降低应用程序的速度。我想知道我是否可以限制我做这件事的次数?我一直找不到更改截面插值的方法??这只是核心情节的问题,还是我的逻辑或代码有问题?

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

最新更新