custom label on x-axis

被刻印的时光 ゝ 提交于 2019-12-05 04:34:44

This is possible by adding a custom label for every x value, so for each year.

Dim series1 As New Series("Series1")
series1.ChartType = SeriesChartType.Column

' Adding some points
series1.Points.AddXY(1, 1)
series1.Points.AddXY(2, 1)
series1.Points.AddXY(3, 1)

Chart1.Series.Add(series1)

' I manually set the maxium of the X axis
Chart1.ChartAreas("ChartArea1").AxisX.Interval = 1
Chart1.ChartAreas("ChartArea1").AxisX.Maximum = 4

Chart1.ChartAreas("ChartArea1").AxisX.CustomLabels.Add(0.5, 1.5, "yr1")
Chart1.ChartAreas("ChartArea1").AxisX.CustomLabels.Add(1.5, 2.5, "yr2")
Chart1.ChartAreas("ChartArea1").AxisX.CustomLabels.Add(2.5, 3.5, "yr3")

If a point has a x-value of '1', then you should add the customlabel from '0.5' to '1.5'. That way it centers nicely.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!