最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Bold and Change Font Size of Chart Title - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question edited Mar 13, 2019 at 8:45 jsanalytics 13.2k4 gold badges26 silver badges46 bronze badges asked Oct 4, 2015 at 17:06 Felicia SohFelicia Soh 8653 gold badges18 silver badges32 bronze badges 1
  • Look at the HTML that this code generates. And from there, you could see how the title is rendered. You will the be able to format it, using css. Or you could post the html in your question. – Olivier De Meulder Commented Oct 4, 2015 at 17:50
Add a ment  | 

1 Answer 1

Reset to default 7

Try this:

        Title title = new Title();
        title.Font = new Font("Arial", 14, FontStyle.Bold);
        title.Text = "My Chart Title";
        Chart1.Titles.Add(title);
发布评论

评论列表(0)

  1. 暂无评论