2014-09-26 2 views
1

.NET Winform 버전 teechart 4.1.2012.1032를 사용합니다.축소 샘플링 차트 확대

내가 제공 한 샘플을 수정했습니다. "Extended \ 포인트 감소 \ DownSampling 추가" 그러나 챠트를 확대 할 때, 쇄선 마크 수는 100이 아닙니다. downSampling.DisplayedPointCount. 어떻게 해결할 수 있습니까?

private void InitializeChart() 
    { 
     this.cursorTool1 = new Steema.TeeChart.Tools.CursorTool();// 
     this.tChart1.Tools.Add(this.cursorTool1);// 
     this.cursorTool1.FollowMouse = true;// 
     this.cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;// 
     this.cursorTool1.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(this.cursorTool1_Change);// 

     CreateArrays(); 
     tChart1.Aspect.View3D = false; 
     tChart1.Zoom.Direction = ZoomDirections.Both;//.Horizontal;// 
     tChart1.Series.Add(points = new Steema.TeeChart.Styles.Points()); 
     tChart1.Series.Add(fastLine = new Steema.TeeChart.Styles.FastLine()); 

     downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart); 
     points.Add(xValues, yValues); 
     points.Active = false; 

     downSampling.DisplayedPointCount = 100; 
     downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLast;// Null; 
     fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint; 
     fastLine.DataSource = points; 
     fastLine.Function = downSampling; 

     this.tChart1.Axes.Custom.Add(new Steema.TeeChart.Axis(this.tChart1.Chart));// 
     this.tChart1[1].CustomVertAxis = this.tChart1.Axes.Custom[0];// 
     this.tChart1[0].CustomVertAxis = this.tChart1.Axes.Custom[0];// 

     this.fastLine.Marks.Visible = true;// 
    } 

    private void CreateArrays() 
    { 
     int length = 2600000; 

     xValues = new Nullable<double>[length]; 
     yValues = new Nullable<double>[length]; 

     Random rnd = new Random(); 
     for (int i = 0; i < length; i++) 
     { 
      xValues[i] = i; 
      yValues[i] = i; 
     } 
    } 

    private void tChart1_Zoomed(object sender, EventArgs e) 
    { 
     tChart1[1].CheckDataSource(); //series 1 is the function series 
    } 

답변

0

DisplayedPointCount는 DownSampling 함수가 그려야하는 포인트의 수를 지정하고이 수를 최대 포인트 수로 표시합니다. I explained here과 같이 예상되는 결과를 얻으려면 Tolerance 속성과 결합해야 할 수도 있습니다. 그래서 다음과 같이 할 수 있습니다 :

public partial class Form1 : Form 
    { 
    public Form1() 
    { 
     InitializeComponent(); 
     InitializeChart(); 
    } 

    private void InitializeChart() 
    { 
     //tChart1.Dock = DockStyle.Fill; 
     tChart1.Aspect.View3D = false; 
     tChart1.Zoomed += tChart1_Zoomed; 

     Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart); 

     Random y = new Random(); 
     for (int i = 0; i < 10000; i++) 
     { 
     points1.Add(DateTime.Now.AddHours(i), y.Next()); 
     } 

     points1.XValues.DateTime = true; 
     points1.Pointer.HorizSize = 1; 
     points1.Pointer.VertSize = 1; 

     Steema.TeeChart.Functions.DownSampling downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart); 
     downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.Average; 
     downSampling1.Tolerance = 100; 
     downSampling1.DisplayedPointCount = Convert.ToInt32(downSampling1.Tolerance * 4); 

     Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart); 
     line1.Function = downSampling1; 
     line1.DataSource = points1; 
     line1.Marks.Visible = true; 
     line1.Marks.Style = MarksStyles.PointIndex; 

     UpdateTitle(); 
    } 

    void tChart1_Zoomed(object sender, EventArgs e) 
    { 
     tChart1[1].CheckDataSource(); 
     UpdateTitle(); 
    } 

    private void UpdateTitle() 
    { 
     tChart1.Header.Text = (tChart1[1].Function as Steema.TeeChart.Functions.DownSampling).DisplayedPointCount.ToString(); 
    } 
    } 
+0

나는 DisplayedPointCount의 의미를 알고 있습니다. DisplayedPointCount를 100으로 설정하면 100 점이 그려집니다. 그러나 확대 할 때, 값 수 100은 Axes.Bottom.Modimum과 Maximum 사이에서 다시 그려야한다고 생각합니다. 그러나 결과는 그렇지 않았습니다. 어떻게 해결할 수 있습니까? 이 버그인가? 이 케이스에 대한 샘플 코드를 보여주세요 (다운 샘플링 기능의 경우 확대/축소). 고맙습니다. –

+0

@DugSungKim 자신을 명확하게 설명하지 못했지만, 두려웠습니다. DisplayedPointCount는 표시 될 최대 점 수이지만이 값에 도달한다는 것을 의미하지는 않습니다. 어쨌든, 방금 솔루션 제안으로 내 대답을 업데이트했습니다. –

+0

답변 해 주셔서 감사합니다. 그러나 points1.Active가 false이면 코드에 올바르게 표시되지 않습니다. 필자의 경우, Points1.Active는 false 여야합니다. 그렇지 않으면 많은 데이터가 표시되고 차트 성능이 좋지 않을 수 있기 때문입니다. 다른 해결책이 있습니까? –

관련 문제