C# MS Chart Scaleview&;穿线

C# MS Chart Scaleview&;穿线,c#,mschart,real-time,C#,Mschart,Real Time,我从microsfot网站的样本中选取了这个例子。示例是C#的实时日期和时间。当使用短距离时,该示例非常有效,并且基本上按原样运行,但是我需要能够监控图形至少45分钟-1小时,只有到那时,值才会开始下降。我想做的是有大约5分钟的观看时间,其余的绘制图我希望能够向后滚动。下面就是问题所在。我需要添加比例视图,以便在图形滚动之前设置可以在图形上看到的量(这也不起作用),但当我将比例视图设置为1以上时,没有插入任何X轴值标签,如果是这样,则只有1个插入,不再插入。代码有点混乱,因为这非常令人沮丧。有人

我从microsfot网站的样本中选取了这个例子。示例是C#的实时日期和时间。当使用短距离时,该示例非常有效,并且基本上按原样运行,但是我需要能够监控图形至少45分钟-1小时,只有到那时,值才会开始下降。我想做的是有大约5分钟的观看时间,其余的绘制图我希望能够向后滚动。下面就是问题所在。我需要添加比例视图,以便在图形滚动之前设置可以在图形上看到的量(这也不起作用),但当我将比例视图设置为1以上时,没有插入任何X轴值标签,如果是这样,则只有1个插入,不再插入。代码有点混乱,因为这非常令人沮丧。有人可以帮助或指导我找到一个更好的图表,因为这个图表的支持和文档非常糟糕

private void startTrending_Click(object sender, EventArgs e)
    {
        // Disable all controls on the form
        startTrending.Enabled = false;
        // and only Enable the Stop button
        stopTrending.Enabled = true;            
        // Predefine the viewing area of the chart
        minValue = DateTime.Now;
        maxValue = minValue.AddMinutes(120);           
        chart1.ChartAreas[0].AxisX.Minimum = minValue.ToOADate();
        chart1.ChartAreas[0].AxisX.Maximum = maxValue.ToOADate();

        // Reset number of series in the chart.
        chart1.Series.Clear();

        // create a line chart series
        Series newSeries = new Series("Series1");
        newSeries.ChartType = SeriesChartType.Line;
        newSeries.BorderWidth = 2;
        newSeries.Color = Color.OrangeRed;
        newSeries.XValueType = ChartValueType.Time;           
        chart1.Series.Add(newSeries);            
        /*chart1.ChartAreas[0].AxisX.LabelStyle.Format = "hh:mm";
        chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Minutes;
        chart1.ChartAreas[0].AxisX.Interval = 1;
        chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 1;
        chart1.ChartAreas[0].AxisX.MajorTickMark.Interval = 0.5; 
        chart1.ChartAreas[0].AxisX.  */          
        chart1.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
        chart1.ChartAreas[0].AxisX.ScaleView.SizeType = DateTimeIntervalType.Minutes;
        chart1.ChartAreas[0].AxisX.ScaleView.Size = 1;
        chart1.ChartAreas[0].CursorX.Interval = 0;

        // start worker threads.
        if (addDataRunner.IsAlive == true)
        {
            addDataRunner.Resume();
        }
        else
        {
            addDataRunner.Start();
        }
    }

我推荐微软研究院的开源、很棒的库


它附带了一系列示例项目,其中一个项目您可能可以定制以满足您的需要。

切换到一个名为TeeChart的图表。我得付钱,但绝对值得。我在MSChart上打了几天架。在30分钟内在TeeChart做了完全相同的事情