简体   繁体   中英

Windows Forms Chart: How to disable X primary axis and keep X seconday axis tick labels?

I am trying to have a Chart that only displays the secondary X axis (top axis) but whenever I disable the primary X axis (bottom), the secondary X axis tick labels disapears...

When I enable secondary axis:

chartArea1.AxisX2.Enabled = AxisEnabled.True;

X2轴已启用

When I disable seconday axis:

chartArea1.AxisX.Enabled = AxisEnabled.False;

X1轴已禁用

I have been trying many things but I could not find a solution that did not look like a hack.

Instead of turning it off you can style it to disappear:

Axis axis = chart1.ChartAreas[0].Axes[0];   // your indices
LabelStyle als = new LabelStyle();
als.ForeColor = chart1.ChartAreas[0].BackColor; 
axis.LabelStyle = als;
axis.MajorTickMark.TickMarkStyle = TickMarkStyle.None;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM