VS2010 Chart控件,如何显示空白图表? [英] VS2010 Chart control, how to display a blank chart?
问题描述
我正在尝试在 Windows 窗体上使用图表控件并使其工作,绘制一些实时数据,但是在数据到达之前没有显示任何内容.我想显示一个 X Y 为 10 30 的空图,但如果值高于此值,图仍具有自动范围.
I'm trying to use the chart control on a windows form and have it working, plotting some real time data, however before the data arrives nothing is displayed. I would like to show an empty graph with an X Y of 10 30 but still have the graph auto range if values go above this.
我找不到可以显示空白"图形的属性,这可能吗?如果可以,怎么办?
I cannot find a property to show the "blank" graph it this possible and if so how?
谢谢
推荐答案
您可以通过使线条颜色透明来隐藏系列的所有数据.如果您还将其 LegendText 设置为",则您只能看到轴刻度.您可以通过添加几个点并设置最小值和最大值来控制它们:
You can hide all data of a Series by making its line color Transparent. If you also set its LegendText to be " " all you can see are the Axis ticks. you can control them by adding a few Points and by setting the Minimum and Maximum values:
// short reference for our dummy:
Series S0 = chart1.Series[0];
// a simple type
S0.ChartType = SeriesChartType.Line;
// set 10 point with x-values going from 0-100 and y-values going from 1-10:
for (int i = 0; i < 100; i +=10) S0.Points.AddXY(i , i / 10);
// or add only a few, e.g. the first and last points:
//S0.Points.AddXY(100, 10);
//S0.Points.AddXY(0, 10);
// hide the line:
S0.Color = Color.Transparent;
// hide the legend text (it will still take up a little space, though)
S0.LegendText = " ";
// limit the axis to the target values
chart1.ChartAreas[0].AxisX.Maximum = 100;
chart1.ChartAreas[0].AxisX.Minimum = 0;
结果看起来像一个空图表:
The result looks like an empty chart:
这篇关于VS2010 Chart控件,如何显示空白图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!