.Net DataVisualization.Charting Y 轴上的值格式化
有谁知道如何格式化和控制 .Net 4 DataVisualization.Charting 图表的 Y 轴上显示的值?
我在 Y 轴上有值,在 X 轴上有日期。 Y 轴上的值显示多个小数点,我想对它们应用自定义格式化程序,以便我可以以我想要的任何格式显示它们。例如,我可以显示 1+3/4 而不是 1.75。
我正在使用 System.Web.UI.DataVisualization.Charting 命名空间中的 Chart 对象在代码中生成所有图表。
Does anybody know how to format and control the values shown on the Y-Axis of a .Net 4 DataVisualization.Charting chart?
I have values on the Y-Axis and dates on the X-Axis. The values on the Y-Axis are showing multiple decimal points and I want to apply a custom formatter to them so that I can show them in any format I want. So for example I can show 1+3/4 instead of 1.75.
I am doing all of the chart generation in code using a Chart object from the System.Web.UI.DataVisualization.Charting namespace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在相应轴中设置
LabelStyle
的Format
属性。对于你的情况,如下所示。
请参阅以下链接了解更多详情。
(参考Kishore的回答)
http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/8f843a18-c72e-4cc1-9fcc-7ad0d9e39c15#5fcef069-7ea7-4d73-9611-90bf9e14ede3
HTH
You have to set the
Format
property ofLabelStyle
in the respective axis.In your case, like below.
Please refer the links below for further details.
(Refer the answer by Kishore)
http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/8f843a18-c72e-4cc1-9fcc-7ad0d9e39c15#5fcef069-7ea7-4d73-9611-90bf9e14ede3
HTH
我找到了答案,有一个可以设置的自定义委托,在计算所有数据成员之后和渲染图表之前调用该委托。如果您将委托附加到图表的自定义事件,您将能够在其中进行您想要的所有自定义。
I found the answer, there's a Customize delegate that can be setup which is called after all data members have been calculated and before the chart is rendered. If you attach your delegate to the Chart's Customize event you'll be able to do all the customization you want in there.