首页 > 技术文章 > MyTask3

yefengCrazy 2016-05-07 00:06 原文

近日做这个项目的时候感觉比较棘手的还是各类chart图处理的问题,详细的我就不多说了,代码我会贴出来,大家可以参考下,注释我还是写的比较详细的

1.饼状图百分比绑定问题(纠结了很久)

// 
        	// chart1
        	// 
        	chartArea1.Name = "ChartArea1";
        	this.chart1.ChartAreas.Add(chartArea1);
        	legend1.Name = "Legend1";
        	this.chart1.Legends.Add(legend1);
        	this.chart1.Location = new System.Drawing.Point(1104, 0);
        	this.chart1.Name = "chart1";
        	series1.ChartArea = "ChartArea1";
        	series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Doughnut;
        	series1.Color = System.Drawing.Color.Gold;
        	series1.IsValueShownAsLabel = true;
        	series1.LabelFormat = "{P2}";
        	series1.Legend = "Legend1";
        	series1.Name = "Series1";
        	this.chart1.Series.Add(series1);
        	this.chart1.Size = new System.Drawing.Size(371, 240);
        	this.chart1.TabIndex = 1;
        	this.chart1.Tag = "123456";
        	this.chart1.Text = "chart1";
        	title1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
        	title1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.LeftRight;
        	title1.BackHatchStyle = System.Windows.Forms.DataVisualization.Charting.ChartHatchStyle.BackwardDiagonal;
        	title1.Name = "Title1";
        	title1.Text = "1-18年龄阶段";
        	title1.TextStyle = System.Windows.Forms.DataVisualization.Charting.TextStyle.Shadow;
        	this.chart1.Titles.Add(title1);
        	this.chart1.Click += new System.EventHandler(this.Chart1Click);

大家可以对照designer的属性看看
series1.LabelFormat = "{P2}";
这个是要设置好的,然后后台绑定数据即可

chart1.Series["Series1"].Points.DataBindXY(xValues, yValues1);

2.为了防止异常,技巧就是设置按钮的Enable属性,灵活运用的话,赶脚好好~~

3.关于窗体适应的问题,我至今没找到解决方案,在室友的机器上,不能看到下面(好吧,是我的船屏幕太大了Orz)

4.关于spline图清除已经画了的点,我还是没找到解决方案,clear和dispose属性都试过,然并卵~~

5.关于数据库问题,如果作为“单机版应用来看”,其实在程序里面设置radiobutton,然后用判断可以解决未装数据库导致程序卡顿的问题

6.~~~暂时只想到这么多,啊喂,话说我做的时候不止这么丁点问题啊,尼玛~

7.想到再更新~~欢迎提问,欢迎赐教

推荐阅读