2013-09-04 4 views
0

CPTScatterPlotInterpolationLinear와 동일한 Y 좌표를 갖는 순차적 선분을 그리고 CPTScatterPlotInterpolationCurved가없는 순차 선분을 그릴 수 있어야합니다. CPTScatterPlotInterpolationCurved는 모든 선을 곡선으로 그립니다. 현재 다중 플롯을 추가하여이 작업을 수행하고 있습니다.core-plot CPTScatterPlotInterpolationCurved와 CPTScatterPlotInterpolationLinear를 조합하면

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

그러나 fill을 사용하는 여러 개의 플롯을 만들면 응용 프로그램이 크게 느려집니다. 내가 이것을 얼마나 많이 할 수 있는지 궁금해했다. 섹션의 보간법을 변경하는 방법을 찾지 못했습니까 ?? 이것이 코어 플롯의 문제일까요, 아니면 논리 또는 코드에 문제가 있습니까?

답변

0

또 다른 가능한 해결책은 곡선 섹션을 그리기 위해 데이터에 포인트를 추가하는 것입니다. 이렇게하면 하나의 플롯 만 사용할 수 있습니다. 필요한 추가 점의 수는 플롯의 크기와 선을 그리는 데 사용되는 선 스타일을 비롯한 여러 요소에 따라 달라집니다.

+0

어떻게 더 잘 설명 할 수 있을지 확신 할 수 없습니까? – CubanAzcuy

+0

예를 들어 x = 0, 1, 2 및 3에 점이 있고 1과 2 사이의 곡선을 원할 경우 점을 (예 :) 1.25 (@ 인덱스 2), 1.5 (@ 3) 및 1.75 (@ 4), 2와 3의 점을 인덱스 5와 6으로 이동하십시오. –