vb.net 在 Visual Studio Graphs 中标记轴

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26736384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 18:26:14  来源:igfitidea点击:

Labelling Axes in Visual Studio Graphs

vb.netvisual-studio-2010.net-4.0

提问by BenK

I have tried using the instruction:

我试过使用指令:

Graph1.Series("Series1").Points(1).AxisLabel = "X Axis Label"

to label the X axis on a graph. A similar instruction should apply to the Y axis.

在图形上标记 X 轴。类似的说明应适用于 Y 轴。

Unfortunately, the instruction produces the following error:

不幸的是,该指令产生以下错误:

ArgumentOutOfRangeException was unhandled
Index was out of range. Must be non-negative and less than the size of the collection.

What's wrongwith my instruction? How do I deal with the error?

我的指令有什么问题?我该如何处理错误?

回答by user3510227

If you want to add titles to the axis you need to modify the ChartArea not the Series.

如果要向轴添加标题,则需要修改 ChartArea 而不是系列。

The Series represents the data points used by the chart, but you can use this to set an axis label for the entire series or individual points.

系列表示图表使用的数据点,但您可以使用它为整个系列或单个点设置轴标签。

It looks like your error is due to having no data points in the table series.

看起来您的错误是由于表系列中没有数据点。

Here's the difference between the two:

这是两者之间的区别:

    Chart1.Series("Series1").AxisLabel = "Series Label"
    Chart1.Series("Series1").Points(0).AxisLabel = "Point Label"

    Chart1.ChartAreas("ChartArea1").AxisX.Title = "Chart Area X Axis Label"
    Chart1.ChartAreas("ChartArea1").AxisY.Title = "Chart Area Y Axis Label"

Chart with labelled axis

带标签轴的图表