Exemplo n.º 1
0
        public void DownSampledTimeSeries()
        {
            var       random    = new Random();
            ChartView chartView = new ChartView();
            var       startTime = DateTime.Now;

            DateTime[] times = Enumerable.Range(1, 1000).Select(i => startTime.AddSeconds(i)).ToArray();
            double[]   y     = Enumerable.Range(1000, 1000).Select(i => Convert.ToDouble(random.Next(100))).ToArray();

            var    pointSeries = new Points();
            var    lineSeries  = new Points();
            TChart chart       = chartView.TeeChart;

            chart.Series.Add(pointSeries);
            chart.Series.Add(lineSeries);

            for (int i = 0; i < 1000; i++)
            {
                pointSeries.Add(times[i], y[i]);
            }

            pointSeries.Active = false;

            lineSeries.DataSource = pointSeries;
            lineSeries.Function   = new DownSampling(chart.Chart)
            {
                DisplayedPointCount = 4000, Method = DownSamplingMethod.Max
            };
            lineSeries.CheckDataSource();
            chart.Zoomed += delegate
            {
                lineSeries.CheckDataSource();
            };
            WindowsFormsTestHelper.ShowModal(chartView);
        }