Ucodia
Ucodia

Reputation: 7710

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 axis enabled

When I disable seconday axis:

chartArea1.AxisX.Enabled = AxisEnabled.False;

X1 axis disabled

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

Upvotes: 0

Views: 1550

Answers (1)

TaW
TaW

Reputation: 54433

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;

Upvotes: 3

Related Questions