如何通过命令创建新图表? [英] How to create new chart by commands?
本文介绍了如何通过命令创建新图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过命令创建图表以便稍后将其放入循环中,但它失败了!
我试过这个:
I want to create chart by commands to put it in loop later, but it failed!
I tried this:
Chart Chr = new Chart();
Chr.ID = "chr1";
Chr.Series.Add("Age");
Chr.Series["Age"].Points.AddXY("Max", 33);
Chr.Series["Age"].Points.AddXY("Xam", 50);
Chr.Series["Age"].Points.AddXY("Nax", 20);
Chr.Series["Age"].Points.AddXY("Xan", 80);
Chr.Width = 500;
Panel1.Controls.Add(Chr);
它正在运行......但它什么也没有显示!
页面占用空间,但是空格..
Aftar,我做了这些改动:
It's run.. but it shows nothing!
It take space on the page, but blank space..
Aftar that, I made these changes:
Chart Chr = new Chart();
Chr = new Chart();
Chr.ID = "chr2";
Chr.ImageLocation = "ChartPic_#SEQ(300,3)";
Chr.Series.Add("Ageq");
Chr.Series["Ageq"].ChartType = SeriesChartType.Pie;
Chr.Series["Ageq"].Palette = ChartColorPalette.Berry;
Chr.Series["Ageq"].BackImage = "ChartPic_#SEQ(300,3)";
Chr.Series["Ageq"].Points.AddXY("Maxq", 11);
Chr.Series["Ageq"].Points.AddXY("Xamq", 22);
Chr.Series["Ageq"].Points.AddXY("Naxq", 55);
Chr.Series["Ageq"].Points.AddXY("Xanq", 44);
Chr.Width = 600;
Chr.Height = 100;
Chr.Palette = ChartColorPalette.Berry;
Chr.Visible = true;
Panel1.Controls.Add(Chr);
它给了我同样的结果..
它运行..但它什么也没显示!
It gave me the same result..
It's run.. but it shows nothing!
推荐答案
你缺少系列.ChartArea
物业和传奇
物业
这里我对你做了一些修改代码
You are missingSeries.ChartArea
Property andLegend
Property
Here i have done some modifications to your code
ChartArea chartArea1 = new ChartArea();
Legend legend1 = new Legend();
Series series1 = new Series();
Chart Chr = new Chart();
Chr = new Chart();
Chr.Name = "chr2";
Chr.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
Chr.Legends.Add(legend1);
Chr.Series.Add("Ageq");
Chr.Series["Ageq"].ChartType = SeriesChartType.Pie;
Chr.Series["Ageq"].Palette = ChartColorPalette.Berry;
Chr.Series["Ageq"].Points.AddXY("Maxq", 11);
Chr.Series["Ageq"].Points.AddXY("Xamq", 22);
Chr.Series["Ageq"].Points.AddXY("Naxq", 55);
Chr.Series["Ageq"].Points.AddXY("Xanq", 44);
Chr.Size = new System.Drawing.Size(559, 418);
Chr.Palette = ChartColorPalette.Berry;
Chr.Visible = true;
panel1.Controls.Add(Chr);
这是对的!
谢谢你的工作..
我对代码进行了3次小改动,以正确的方式运行..
That's right!
Thank you it worked..
I've done 3 little changes on the code to run on the right way..
ChartArea chartArea1 = new ChartArea();
Legend legend1 = new Legend();
Series series1 = new Series();
Chart Chr = new Chart();
Chr = new Chart();
Chr.ID = "chr2";
Chr.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
Chr.Legends.Add(legend1);
Chr.Series.Add("Ageq");
Chr.Series["Ageq"].ChartType = SeriesChartType.Pie;
Chr.Series["Ageq"].Palette = ChartColorPalette.Berry;
Chr.Series["Ageq"].Points.AddXY("Maxq", 11);
Chr.Series["Ageq"].Points.AddXY("Xamq", 22);
Chr.Series["Ageq"].Points.AddXY("Naxq", 55);
Chr.Series["Ageq"].Points.AddXY("Xanq", 44);
Chr.Width = 500;
Chr.Palette = ChartColorPalette.Berry;
Chr.Visible = true;
Panel1.Controls.Add(Chr);
再次感谢你..
Thank you again..
这篇关于如何通过命令创建新图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文