How to change the MS Charts label font size in C#?

10,037

Solution 1

You can change the Font individually for each DataPoint:

MIN.Points[0].Font = new System.Drawing.Font("Consolas", 10f);
MIN.Points[1].Font = new System.Drawing.Font("Consolas", 12f);
MIN.Points[2].Font = new System.Drawing.Font("Consolas", 14f);

Or you can change the Font for all Labels of your series:

MIN.Font = new System.Drawing.Font("Times", 16f);

enter image description here

Solution 2

   Chart2.ChartAreas.["yourChartArea"].AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None;

   Chart2.ChartAreas.["yourChartArea"].AxisX.LabelStyle.Font 
= new System.Drawing.Font("Trebuchet MS", 2.25F, System.Drawing.FontStyle.Bold);
Share:
10,037
Sachith
Author by

Sachith

Updated on June 05, 2022

Comments

  • Sachith
    Sachith almost 2 years

    I have created few MS charts. Below code extracted from my application. It is working fine. but I want to increase the font size of label. How can I change the font size of label ?

    Thanks.

     Series MIN = Chart2.Series.Add("Minimum");
     MIN.Points.DataBindXY(listVersion, MIN_list[j]);
     MIN.ChartType = SeriesChartType.Line;
     MIN.Color = Color.Red;
     MIN.BorderWidth = 3;
     MIN.IsValueShownAsLabel = true;
     MIN.LabelBackColor = System.Drawing.Color.Red;
     MIN.LabelForeColor = System.Drawing.Color.White;
    
  • Sachith
    Sachith about 8 years
    It changes the label in X-Axis. Actually I want to change the label on graphs. Please refer this [image] (oi67.tinypic.com/vyxe29.jpg)