Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Bold and Change Font Size of Chart Title

I can create Box Plot Chart dynamically. The issue I faced now is I have no idea how to bold and change the font size of the chart title.

I have researched online for awhile but could not figure out how to do this.

This is my codes:

Chart Chart1 = new Chart();
                Chart1.DataSource = tg;
                Chart1.Width = 600;
                Chart1.Height = 350;

                Chart1.Series.Add(new Series());
                Chart1.Series[0].ChartType = SeriesChartType.BoxPlot;
                List<object> lst = tg.AsEnumerable().ToList<object>();

                foreach (DataRow row in tg.Rows)
                    Chart1.Series[0].Points.AddXY(row["VALUE"], new object[] { row["Min"], row["Max"], row["Avg"], row["Percentile25"], row["Percentile50"], row["Percentile75"] });

                Chart1.Series[0]["PixelPointWidth"] = "38";
                string title = (tg.Rows[0]["TITLE"].ToString());
                Chart1.Titles.Add(title);

                //create chartareas
                ChartArea ca = new ChartArea();

                ca.AxisX = new Axis();
                ca.AxisX.MajorGrid.Enabled = false;
                ca.AxisY = new Axis();
                ca.AxisY.MajorGrid.Enabled = false;
                Chart1.ChartAreas.Add(ca);

                //databind
                Chart1.DataBind();
                Chart1.Visible = true;

                panel.Controls.Add(Chart1);

Question: How to Bold Chart Title?

How to Change Font Size of Chart Title?

Appreciate if someone could help me on this. Thanks!

Regards,

Felicia

like image 547
Felicia Soh Avatar asked Sep 10 '25 11:09

Felicia Soh


1 Answers

Try this:

        Title title = new Title();
        title.Font = new Font("Arial", 14, FontStyle.Bold);
        title.Text = "My Chart Title";
        Chart1.Titles.Add(title);
like image 67
jsanalytics Avatar answered Sep 12 '25 23:09

jsanalytics