【问题标题】:How to Bold and Change Font Size of Chart Title如何加粗和更改图表标题的字体大小
【发布时间】:2016-01-01 08:51:18
【问题描述】:

我可以动态创建箱线图。我现在面临的问题是我不知道如何粗体和更改图表标题字体大小

我在网上研究了一段时间,但不知道该怎么做。

这是我的代码:

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

问题:如何加粗图表标题

如何更改图表标题字号

感谢是否有人可以帮助我。谢谢!

问候,

费利西亚

【问题讨论】:

  • 查看这段代码生成的 HTML。从那里,您可以看到标题是如何呈现的。您将能够使用 css 对其进行格式化。或者您可以在您的问题中发布 html。

标签: javascript c# css asp.net data-visualization


【解决方案1】:

试试这个:

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

【讨论】:

  • btw @jstreet,你知道如何改变轴X标签的字体吗?我试过这样: Chart1.Series[0].Font=new Font("Arial", 9, FontStyle.Bold);但不起作用:(
  • 试试:Chart1.ChartAreas[0].AxisX.LabelStyle.Font = new Font();
  • 一般来说,你应该熟悉使用 VS Designer。它使查找和配置此类与图表外观相关的属性变得更快、更容易。并且只使用后面的代码来处理数据。
  • 哦,好的,我会的,感谢@jstreet 再次帮助我! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-09
  • 2020-12-01
  • 2019-01-30
  • 1970-01-01
相关资源
最近更新 更多