问题
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
回答1:
Try this:
Title title = new Title();
title.Font = new Font("Arial", 14, FontStyle.Bold);
title.Text = "My Chart Title";
Chart1.Titles.Add(title);
来源:https://stackoverflow.com/questions/32936053/how-to-bold-and-change-font-size-of-chart-title