creating a custom label for axis y in ASP.Net chart as a string

匿名 (未验证) 提交于 2019-12-03 02:31:01

问题:

I have a 3 point axis for axisY in a chart for ASP.NET. Right now it shows 1, 2, and 3. I need to assign string values to the points. I have found that it is somewhere in here:

Chart1.ChartAreas[0].AxisY.CustomLabels.Add(??????);

Not sure how to get it not to have to take a double value and be able to assign a string to the point.

回答1:

You have to create a custom label, set its properties, then add it to the axis

What about this?

    CustomLabel label = new CustomLabel();      label.FromPosition = -1.0;     label.ToPosition = 1.0;     label.Text = "0";     label.RowIndex = 0;      Chart1.ChartAreas[0].AxisY.CustomLabels.Clear();     Chart1.ChartAreas[0].AxisY.CustomLabels.Add(label);

This will render a 0 where the Y-axis meets the X-axis.



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