首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >放大下采样图表

放大下采样图表
EN

Stack Overflow用户
提问于 2014-09-26 16:13:59
回答 1查看 626关注 0票数 1

我使用的是.NET Winform版本Teechart4.1.2012.1032。

我修改了你提供的样品。"Extended\Reducing number of points\DownSampling“但当我放大图表时,fastline的标记计数不是100,downSampling.DisplayedPointCount。我怎么解决它呢?

代码语言:javascript
复制
  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
    }
EN

回答 1

Stack Overflow用户

发布于 2014-09-30 20:25:19

DisplayedPointCount指定DownSampling函数应该绘制的点数,并将此数字显示为最大点数。作为I explained here,您可能需要将其与公差属性相结合才能获得预期的结果。所以,你可以这样做:

代码语言:javascript
复制
  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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26054996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档