vb.net - 在 Visual Studio 图形中标记轴

标签 vb.net visual-studio-2010 .net-4.0

我试过使用指令:

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

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

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

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

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

最佳答案

如果您想向轴添加标题,您需要修改 ChartArea 而不是 Series。

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

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

两者的区别:

    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

关于vb.net - 在 Visual Studio 图形中标记轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26736384/

相关文章:

vb.net - e.Handled 在 VB.net 2010 中不起作用

c# - WCF 数据限制

vb.net - Team Foundation Server 无法构建。缺少库或组件?

c++ - 奇怪的英特尔 C++ 编译器错误

c++ - 告诉 VS2010 折叠区域

c# - 如何获取 IdentityReference 对象的显示名称?

windows - 在没有 .NET Framework 4.0 的情况下使用 Windows SDK 7.1 编译 C++ 代码

c# - 从URL在asp.net网站上播放youtube视频

c++ - 如何在 Visual Studio 2010 中构建 64 位托管 C++ DLL?

c# - 并行代码抛出 OutOfRangeException