如何绘制四个(或更多)水平workareas? [英] how to draw four (or more) workareas horizontally?
问题描述
下面是其中提请1/2/3/4码和平(取决于备注)图表:
Here is a peace of code which draws 1/2/3/4 (depends on remarks) charts:
private void button1_Click(object sender, EventArgs e)
{
List<int> queue = new List<int>();
queue.Add(1); queue.Add(2); queue.Add(3); queue.Add(4);
chart1.ChartAreas.Add(queue[0].ToString());
chart1.ChartAreas.Add(queue[1].ToString());
chart1.ChartAreas.Add(queue[2].ToString());
chart1.ChartAreas.Add(queue[3].ToString());
chart1.Series.Add("test1");
chart1.Series.Add("test2");
chart1.Series.Add("test3");
chart1.Series.Add("test4");
chart1.Series["test1"].ChartArea = "1";
chart1.Series["test2"].ChartArea = "2";
chart1.Series["test3"].ChartArea = "3";
chart1.Series["test4"].ChartArea = "4";
Random rdn = new Random();
for (int i = 0; i < 50; i++)
{
chart1.Series["test1"].Points.AddXY(rdn.Next(0, 10), rdn.Next(0, 10));
chart1.Series["test2"].Points.AddXY(rdn.Next(0, 10), rdn.Next(0, 10));
chart1.Series["test3"].Points.AddXY(rdn.Next(0, 10), rdn.Next(0, 10));
chart1.Series["test4"].Points.AddXY(rdn.Next(0, 10), rdn.Next(0, 10));
}
chart1.Series["test1"].ChartType = SeriesChartType.FastLine;
chart1.Series["test2"].ChartType = SeriesChartType.FastLine;
chart1.Series["test3"].ChartType = SeriesChartType.FastLine;
chart1.Series["test4"].ChartType = SeriesChartType.FastLine;
}
如果我画两个或三个图表其水平似乎是这样的:
If I draw two or three charts it appears horizontally something like:
............
............
...........
............
或
............
............
............
............
............
............
当我加入第四chartarea它开始打造第二个列
When I add fourth chartarea it starts create second "column"
.......... .. ............
............ ............
............ ......... ...
............ ............
怎样做才能迫使布局有一列?我已经找到位置属性,但无法找到如何正确地使用它的方式:(
What to do to force layout with one column ? I have found "Position" property but couldn't find the way how to use it correctly :(
推荐答案
我认为所有的对齐属性居然比对区本身..
I think all the alignment properties actually are more about data aligning than about the areas themselves..
貌似默认的了解数据对齐位置=自动
将与有关如何最好地利用空间,直到你关掉自己的想法赢,所以我相信,你必须设置位置
> ChartAreas 中的代码下面是玩一个例子:
Looks like the default Position = Auto
will win with its own ideas about how to use the space best, until you switch it off; so I believe that you have to set the Positions
of the ChartAreas
in code. Here is an example to play with:
float dist = 1f;
float h = 23f;
float w = 80f;
CA1.Position = new ElementPosition(dist, dist * 2 + h * 0, w, h);
CA2.Position = new ElementPosition(dist, dist * 3 + h * 1, w, h);
CA3.Position = new ElementPosition(dist, dist * 4 + h * 2, w, h);
CA4.Position = new ElementPosition(dist, dist * 5 + h * 3, w, h);
这四个数字的的 ElementPosition
是持有总图表区的百分比(!)浮动。我已经允许了一点距离,并设置ChartAreas至23%的高度和80%的宽度。
The four numbers of an ElementPosition
are floats that hold percentages (!) of the total chart area. I have allowed a little distance and set the ChartAreas to 23% height and 80% width.
好消息是,这些数字将调整期间举行..
The good news is that these numbers will hold during resize..
下面是截图(无数据):
Here is a screenshot (without data):
这不是奇怪的是,这些东西所以非常难找了呢? (这是我第3次尝试吧..)
Isn't is strange that these things are so very hard to find out? (This is my 3rd try at it..)
这篇关于如何绘制四个(或更多)水平workareas?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!