将图表宽度设置为70% [英] Set Chart Width to 70%
问题描述
大家好,
有谁知道如何将图表宽度设置为容器的70%?我已经将容器宽度设置为100%,如下所示:container.Width = Unit.Percentage(100);
这是我的代码:
hi Members,
does anyone know how can I set chart width to 70% of the container? I have already set my container width to 100% like this: container.Width = Unit.Percentage(100);
This is my codes:
Chart Chart1= new Chart();
Chart1.DataSource = dt;
Chart1.Width = 800;
Chart1.Height = 490;
Chart1.Series.Add(new Series());
Chart1.Series[0].ChartType = SeriesChartType.BoxPlot;
List<object> List1 = dt.AsEnumerable().ToList<object>();
foreach (DataRow row in dt.Rows)
Chart1.Series[0].Points.AddXY(row["STATUS"], new object[] { row["MIN"], row["MAX"], row["25THPERCENTILE"], row["75THPERCENTILE"], row["AVG"], row["50THPRECENTILE"] });
//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);
现在,图表宽度设置为像素。我想将图表宽度设置为百分比。
问题:如何设置图表宽度到 70%?
感谢有人可以帮助我,非常感谢!!
Now currently the chart width is set to pixel. I would like to chart width to be set to percentage.
Question: How can I set chart width to 70%?
Appreciate if someone can help me on this, thanks a lot!!
推荐答案
试试这个:
Try this :
Chart1.Width = Convert.ToInt32(myContainer.Width * 0.7) ;
你必须用容器的名称替换myContainer - Control ...
you have to replace "myContainer" with the Name of your container-Control ...
这篇关于将图表宽度设置为70%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!