MS Chart Scaleview 和螺纹加工
我从 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();
}
}
I have taken the example from the samples off the microsfot website. The example is the realtime Date&Time for C#. The example works perfectly when using a short distance and basically running it exactly as it is however I need to be able to monitor my graph for atleast 45min-1hour and only then must the values start falling off. What I would like to do is have about 5min watch time and the rest of the plotted graph I would like to be able to scroll back. So below is the area that is the problem. I need to add the scale view in order to set the amount I can see on the graph before it scrolls(Which doesnt work as well), but the moment I make the scale view above 1 none of the X-Axis value labels are inserted and if so then only 1 of them are and no more. The code is a bit messy as this has been very frustrating. Can someone either assist or guide me to a better chart as the support and documentation of this chart is terrible.
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我推荐来自 MS Research 的开源、非常棒的 WPF 动态数据显示 库。
它附带了一堆示例项目,您可以定制其中一个来满足您的需求。
I recommend the open source, and awesome, WPF Dynamic Data Display library from MS Research.
It comes with a bunch of sample projects, one of which you can probably tailor to meet your needs.
切换到名为 TeeChart 的图表。必须付费,但绝对值得。在 MSChart 上奋斗了几天。 30 分钟内在 TeeChart 中完成了完全相同的操作。
Switched to a chart called TeeChart. Got to pay for it, but definitely worth it. Been battling for a couple days on MSChart. Did the exact same thing in TeeChart in 30mins.