问题
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