Sachith
Sachith

Reputation: 201

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;

Upvotes: 3

Views: 13293

Answers (2)

TaW
TaW

Reputation: 54433

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

Upvotes: 2

Rohit
Rohit

Reputation: 10236

   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);

Upvotes: 3

Related Questions