本文介绍了VS2010图表控件,如何显示空白图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在窗体上使用图表控件并使其工作,绘制一些实时数据,然而在数据到达之前,不显示任何内容。我想显示一个XY的10 30的空图,但仍然有图的自动范围,如果值超过这个。



我找不到一个属性来显示


解决方案

您可以通过使其线条颜色为透明来隐藏系列的所有数据。如果你还设置它的LegendText为,所有你可以看到的是轴刻度。您可以通过添加几个点并设置最小值和最大值来控制它们:

  //我们的虚拟对象的简短引用: 
系列S0 = chart1.Series [0];
//简单类型
S0.ChartType = SeriesChartType.Line;
//设置10点,其中x值从0-100并且y值从1-10开始:
for(int i = 0; i //或只添加一些,例如第一点和最后一点:$ b​​ $ b //S0.Points.AddXY(100,10);
//S0.Points.AddXY(0,10);
//隐藏行:
S0.Color = Color.Transparent;
//隐藏图例文本(它仍然占用一些空间)
S0.LegendText =;
//将轴限制为目标值
chart1.ChartAreas [0] .AxisX.Maximum = 100;
chart1.ChartAreas [0] .AxisX.Minimum = 0;

结果看起来像一个空图表:




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?

thanks

解决方案

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图表控件,如何显示空白图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 20:57