Kᴀτᴢ
Kᴀτᴢ

Reputation: 2176

Change position of y axis label to bottom of windows forms chart

Actually my chart is looking like that:

enter image description here

As you can see the labels are overlapped with the other series. How can I set the label for series2 (=columns) to the bottom above the x-axis? It seems there is no property for that? Thanks

Upvotes: 1

Views: 2426

Answers (1)

TaW
TaW

Reputation: 54433

You can show the y-values of one series at one axis. This can be the primary axis (at the bottom), but then the x-values won't show. Or it can be the secondary axis; for this here is what you can do:

First enable the second x-axis :

chart.ChartAreas[0].AxisX2.Enabled = AxisEnabled.True;

Then associate the series you want to this secondary axis:

yourSeries.XAxisType = AxisType.Secondary;

Finally tell the series to display its y-values on its axis labels:

yourSeries.AxisLabel = "#VAL";

If your other series shows its values close to the points:

yourOtherSeries.IsValueShownAsLabel = true;

..this could be the result :

enter image description here

Here I have colored the axis labels to go with their series:

chart.ChartAreas[0].AxisX2.LabelStyle.ForeColor = yourSeries.Color;

Upvotes: 1

Related Questions