c# Winform MSChart reverse Y Axis

懵懂的女人 提交于 2019-12-11 04:09:50

问题


I am using the MSChart control on a Windows form.

I am trying to have a descending Y axis by using AxisY.IsReversed = true, but still keep the X axis on the bottom. By default, when I used AxisY.IsReversed = true, then the X axis goes up to the top. I then tried the setting the AxisY.Crossing = Max to flip the axis to the maximum end of the Y axis (which is at the bottom) but it won't go below the X axis, it only goes as far as just above it.

Please help me!!!!!


回答1:


The behavior you describe is the same behavior as shown in Microsoft demo project. I believe there is no tweak to make labels of X axis simply appear under the X axis, as there is nothing similar to Axis.LabelPosition property, that would specify, that labels should be under the axis.

Either when you specify chart1.ChartAreas[0].AxisX.IsMarksNextToAxis = false;, then labels appear on top of the chart, not on the bottom as desired.

The only tweak you can use, is not to set AxisY.IsReversed = true;, but make all your Y values *-1 (make them negative). Then use LabelStyle.Format to format negative numbers as positive.

chart1.ChartAreas[0].AxisY.IsReversed = false;               
chart1.ChartAreas[0].AxisY.LabelStyle.Format = "##.##;##.##;##.##";


来源:https://stackoverflow.com/questions/25736973/c-sharp-winform-mschart-reverse-y-axis

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