Recently, due to project requirements, I have made several statistical charts. I found the zedgraph and dotnetchartin controls on the Internet.
Zedgraph: supports winform and webform. It supports visual design and is mainly open-source.
Dotnetchartin: Need to find the cracked version online: http://files.cnblogs.com/xiaogangqq123/dotnetcharting.rar
It is said on the Internet that the dotnetchartin control is relatively performance-consuming, and supports 2D and 3D. The zedgraph control is open-source and has high scalability, but only supports 2D graphics. It has good performance.
Because the project needs to be three-dimensional, we chose dotnetchartin. After several repeated tests, we feel that dotnetchartin has good performance. Of course, it is ideal.
Due to the small amount of information on dotnetchartin on the internet, I read the help documentation. I made a demo to perform a preliminary test on 10 lines of 10 thousand data records and 10 10 0.1 million data records.
10 thousand: The image generation speed is about 2 to 5 seconds;
0.1 million: the speed is estimated to be between 5 seconds and 10 seconds,
This is basically the case. paste the Code:
Public class charting {# region common variables /// <summary> // image storage path /// </Summary> Public String phaysicalimagepath {Get; set ;} /// <summary> /// title /// </Summary> Public String title {Get; set ;} /// <summary> /// X axis name /// </Summary> Public String xname {Get; set ;} /// <summary> /// Y axis name /// </Summary> Public String yname {Get; set ;} /// <summary> /// legend name // </Summary> Public String serisename {Get; set ;} /// <summary> /// width /// </Summary> Public int serisewidth {Get; set ;} /// <summary> /// height /// </Summary> Public int seriseheight {Get; set ;} /// <summary> // data source // </Summary> Public datatable datasoure {Get; set;} public bool isuse3d {Get; set ;} public chartype type {Get; Set ;}# endregionpublic charting () {}/// <summary> /// column chart /// </Summary> /// <returns> </returns> Public void createcombo (dotnetcharting. chart chart1) {chart1.title = title; chart1.xaxis. label. TEXT = xname; chart1.yaxis. label. TEXT = This. yname; chart1.tempdirectory = This. phaysicalimagepath; chart1.width = This. serisewidth; chart1.height = This. seriseheight; chart1.type = charttype. combo; chart1.series. type = seriestype. cylinder; chart1.series. name = This. serisename; chart1.series. data = This. datasoure; chart1.seriescollection. add (); chart1.defaultseries. defaultelement. showvalue = true; chart1.shadingeffect = true; chart1.use3d = isuse3d; chart1.series. defaultelement. showvalue = true;} // <summary> // pie chart // </Summary> /// <returns> </returns> Public void createpie (dotnetcharting. chart chart1) {chart1.title = title; chart1.xaxis. label. TEXT = xname; chart1.yaxis. label. TEXT = This. yname; chart1.tempdirectory = This. phaysicalimagepath; chart1.width = This. serisewidth; chart1.height = This. seriseheight; chart1.type = charttype. pie; chart1.series. type = seriestype. cylinder; chart1.series. name = This. serisename; chart1.shadingeffect = true; chart1.use3d = isuse3d; chart1.defaseries series. defaultelement. transparency = 20; chart1.defaseries series. defaultelement. showvalue = true; chart1.pielabelmode = pielabelmode. outside; chart1.seriescollection. add (getarraydata (); chart1.series. defaultelement. showvalue = true;} private seriescollection getarraydata () {seriescollection SC = new seriescollection (); datatable dt = This. datasoure; For (INT I = 0; I <DT. rows. count; I ++) {series S = new series (); S. name = DT. rows [I] [0]. tostring (); Element E = new element (); // name of each element E. name = DT. rows [I] [0]. tostring (); // the size of each element. E. yvalue = convert. todouble (DT. rows [I] [1]. tostring (); S. elements. add (E); SC. add (s) ;}return SC ;} /// <summary> /// graph /// </Summary> /// <returns> </returns> Public void createline (dotnetcharting. chart chart1) {chart1.title = title; chart1.xaxis. label. TEXT = xname; chart1.yaxis. label. TEXT = This. yname; chart1.tempdirectory = This. phaysicalimagepath; chart1.width = This. serisewidth; chart1.height = This. seriseheight; chart1.type = charttype. combo; // defambo series must be used here. type = seriestype. line or chart1.defaultseries. type = seriestype. line; chart1.series. name = This. serisename; chart1.series. data = This. datasoure; chart1.seriescollection. add (); chart1.defaultseries. defaultelement. showvalue = true; chart1.shadingeffect = false; chart1.use3d = isuse3d; chart1.series. defaultelement. showvalue = true ;}}
Front-End call code:
Charting CH = new charting (); Ch. title = "Statistics"; Ch. xname = "country"; Ch. yname = "quantity (hundreds of millions)"; Ch. serisename = "num"; Ch. seriseheight = 500; Ch. serisewidth = 1240; Ch. phaysicalimagepath = "Temp"; Ch. datasoure = getdata. gettablepie (); Ch. isuse3d = true; // create a chart. The idch of the dotnetchartin control on the chart1 page. createpie (chart1 );
If there are multiple data records (that is, there are multiple lines), for example, the column chart and line chart can call createline () and createcombo () multiple times and create unused data sources. And serisename
: Line chart: bar chart: pie chart: All test data .. the figure looks messy. I mainly use a large amount of data. there are more than 0.1 million entries .. in fact, statistics cannot be used so much. I also want to test the image generation performance of such data.
Address: http://www.cnblogs.com/xiaogangqq123/archive/2010/06/12/1756845.html