Search code examples
c#formschartslabelmschart

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


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;

Solution

  • 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