1

I use a .NET Winform version teechart 4.1.2012.1032.

I modified the sample that you supplied. "Extended\Reducing number of points\DownSampling Additions" But When I zoom in chart, fastline's marks count is not 100 , downSampling.DisplayedPointCount. How can I resolve it?

  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
    }
Yeray
  • 5,009
  • 1
  • 13
  • 25

1 Answers1

0

The DisplayedPointCount specifies how many points the DownSampling function should paint and displays this number as a maximum number of points. As I explained here, you may need to combine it with Tolerance property to get the results you expect. So, you could do something like this:

  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();
    }
  }
Narcís Calvet
  • 7,304
  • 5
  • 27
  • 47
  • I know the meaning of DisplayedPointCount. If I set the DisplayedPointCount to 100, 100 points are drawn. But when I zoom in, I think that value count 100 must be redrawn between Axes.Bottom.Minimum and Maximum. But Results did not. How can I solve it? Is this bug? Please show me a sample code about this case(Zoom in / out in case of downsampling function) Thank you. – DugSung Kim Oct 01 '14 at 00:04
  • @DugSungKim I didn't explain myself clearly enough, I'm afraid. DisplayedPointCount is the maximum number of points that will be displayed but it doesn't mean this value will be reached. Anyway, I just updated my answer with a solution proposal. – Narcís Calvet Oct 01 '14 at 10:07
  • Thank you for your answer. But if points1.Active is false, it's not displayed correctly in your code. The Points1.Active must be false in my case, because if it is not, so many data will be displayed and than chart performance will be not so good. Is there any other solution? – DugSung Kim Oct 02 '14 at 03:57
  • @DugSungKim use points1.Visible = false; instead. That works fine for me with the example above. – Narcís Calvet Oct 02 '14 at 07:11
  • @ Narcís Calvet Thank you for your cooperation. And What is the difference Visible property and Active property of the Points or FastLine? And If I use a DataTable, Sometimes out of memory error is occured. What is the difference of DataTable and Nullable[]? What is the more efficient? – DugSung Kim Oct 06 '14 at 00:29
  • @ Narcís Calvet And when I use visible property in my code, If I zoom in, I must be changed visible = true and call CheckDataSouce() function and then change visible = false in Zoomed event function. Is there any other solution? – DugSung Kim Oct 06 '14 at 23:10
  • @DugSungKim the Visible property calls the Active property internally. They are identical. Can you provide some simple code to reproduce your problem with DataTable? I don't understand your question on efficiency between DataTable and Nullable[], can you explain? (You might like to ask a new question for new issues). – Christopher Ireland Oct 07 '14 at 13:29
  • @DugSungKim with points1.Visible/Active = false, the above code works as expected here. Maybe there is a difference between the versions we are using ... I'm using the latest version 4.1.2014.08120 (the version you're using was released 1.75 years ago) – Christopher Ireland Oct 07 '14 at 13:37