9

I want to change the Y-axis label font size.

I tried...

AxisY LineColor="64, 64, 64, 64" LabelAutoFitMinFontSize="5"
   LabelStyle Font="NanumGothic, 5pt"

and

Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font.Size = 5;

but it doesn't work. Its size cannot be modified even though I extend or minify it.

Please help me...!! :)

Chris Zeh
  • 924
  • 8
  • 23
Moonil Kim
  • 91
  • 1
  • 1
  • 3

4 Answers4

14

You seem to have forgotten to change auto fit style for this axis. It default setting replaces your font size

Chart1.ChartAreas.["ChartArea1"].AxisY.LabelAutoFitStyle 
    = LabelAutoFitStyles.None;
Chart1.ChartAreas.["ChartArea1"].AxisX.LabelStyle.Font 
    = new System.Drawing.Font("Trebuchet MS", 2.25F, System.Drawing.FontStyle.Bold);
Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Oleg
  • 1,291
  • 13
  • 16
10

You try this may be its working

Chart1.ChartAreas["ChartArea1"].AxisX.TitleFont = new Font("your required font",uyour required size, FontStyle.your required style);

Set Title Color

Chart1.ChartAreas["ChartArea1"].AxisX.ForeColor = Color.Red;

Raheel
  • 245
  • 1
  • 4
  • 15
6

Instead of trying to alter the font size directly, assign the font with the style you require. Eg:

Chart1.ChartAreas.["ChartArea1"].AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 2.25F, System.Drawing.FontStyle.Bold);

Depending on what you're doing you may also want to set IsLabelAutoFit to false as well.

Greg
  • 326
  • 2
  • 6
1

The secret is not in chartArea, but in Series:

Chart1.Series["SerieName"].Font = new Font("Arial", 7, FontStyle.Bold);