调整ChartArea图表高度 [英] Adjust ChartArea Height of Chart

查看:171
本文介绍了调整ChartArea图表高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了动态生成的箱形图。我不确定如何调整所有图表的图表区域的高度。我尝试在线研究,但仍无法找到解决方案。



这是我的代码:

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

Chart1.Series.Add(new Series());
Chart1.Series [0] .ChartType = SeriesChartType.BoxPlot;
列表< 对象 > lst = tg.AsEnumerable()。ToList < object > ();

foreach(tg.Rows中的DataRow行)
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);

//创建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);





问题:如何设置图表的 chartarea 高度



如果有人感谢可以帮助我。谢谢!



问候,

Felicia

解决方案



ChartArea本身的大小无法直接设置。只有图表的大小作为表格的控制。



ChartArea-Size取决于:

- 如果系列描述显示(和系列文本本身也是)

- 每种描述的字体大小(系列,轴等)

- 你想拥有一个Axis-title

- 你想要一个图表标题



......也许还有一些图表的属性..

hi Members,
I have created box plot chart which will be generated dynamically. I am not sure of how I could adjust the height of chartarea of all charts. I tried research online but still could not find a solution to it.

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 set the height of chartarea of a chart?

Appreciate if someone could help me on this. Thanks!

Regards,
Felicia

解决方案

Hi,
the Size of the ChartArea itself could not set directly. Only the Size of the Chart as a Control of your Form.

The ChartArea-Size depends on :
- if the Series-Description is displayed (and the Series-Text itself also)
- the Font-Size of each Kind of description (Series, Axis etc.)
- you want to have an Axis-title
- you want to have a Chart-title

... and perhaps also some more properties of the Chart ...


这篇关于调整ChartArea图表高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆