Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1130

Summary: Downsample function sometimes returns erroneous colors
Product: .NET TeeChart Reporter: christopher ireland <chris>
Component: OthersAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED FIXED    
Severity: normal    
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description christopher ireland 2015-02-10 10:42:01 EST
The following code reproduces the problem, the symptom of which is that when the button is clicked lines are drawn to the Y=0 value, that is, null values are being drawn:

    private Steema.TeeChart.Styles.Points points;
    private Steema.TeeChart.Styles.FastLine fastLine;
    private Steema.TeeChart.Functions.DownSampling downSampling;
    private Nullable<double>[] xValues, yValues;

    private void InitializeChart()
    {
      CreateArrays();
      tChart1.Aspect.View3D = false;
      tChart1.Zoom.Direction = ZoomDirections.Horizontal;
      tChart1.Series.Add(points = new Steema.TeeChart.Styles.Points());
      tChart1.Series.Add(fastLine = new Steema.TeeChart.Styles.FastLine());
      tChart1.Zoomed += tChart1_Zoomed;
      tChart1.UndoneZoom += tChart1_UndoneZoom;
      points.Add(xValues, yValues);
      downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
      points.Active = false;
      downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLastNull;
      fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;

      fastLine.DataSource = points;
      fastLine.Function = downSampling;

    }

    void tChart1_UndoneZoom(object sender, EventArgs e)
    {
      tChart1.Axes.Bottom.SetMinMax(0, tChart1[0].Count); //series 0 is the original series, although you could use any value to set the maximum
      downSampling.Tolerance = 1.0;
    }

    void tChart1_Zoomed(object sender, EventArgs e)
    {
      downSampling.Tolerance = (this.tChart1.Axes.Bottom.Maximum - this.tChart1.Axes.Bottom.Minimum) / (500.0 / 5.0);
      //this.tChart1[1].CheckDataSource();
    }


    private void CreateArrays()
    {
      int length = 2000;

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

      Random rnd = new Random();
      for (int i = 0; i < length; i++)
      {
        xValues[i] = i;
        if (i % 5 == 0)
        {
          yValues[i] = null;
        }
        else
        {
          /*****************************************************************
           *  変更点:NULLが描画されることを確認する為、90~100の範囲でランダム値
           *      を生成する。
           *****************************************************************/
          yValues[i] = rnd.Next(90, 100);
        }
      }
    }

    private void button5_Click(object sender, EventArgs e)
    {
      tChart1.Axes.Bottom.SetMinMax(620, 760);
      //tChart1.Axes.Bottom.SetMinMax(620, 690);
      downSampling.Tolerance = (this.tChart1.Axes.Bottom.Maximum - this.tChart1.Axes.Bottom.Minimum) / (500.0 / 5.0);
    }