前段时间,项目中开发用到柱状图,饼图,由于vs上没有这边好的控件,在网上搜索咯下,发现chart控件的评价还是相当高的,先说下安装步骤,首先得安装。net framework 3.5sp1,对应vs2008安装MSChart_VisualStudioAddOn.exe,vs2010则安装MSChart.exe.安装好后打开vs软件,在数据类控件库里面就能看到chart控件了,拖过来就能用。
健康知识
主要收下一些属性的意思,免得不会的又去学习一遍,浪费时间
前台:
BackGradientStyle="TopBottom" BackSecondaryColor="White" EnableTheming="False"
EnableViewState="True" Height="303px" Width="1015px" ImageStorageMode="UseImageLocation">
ImageStorageMode这个属性是否要将生产的图片保存到服务器。
后台:
DataSet dt = CStatsReportV3.CommitCountyByStaffid(dtDKFFRQ, nType, actid, gdzxdept, ref objDB);
chrCount.DataSource=dt;
ArrayList arrdc_staff = CStatsReportV3.F_OstaffnameListByActid(dtDKFFRQ, actid, nType, gdzxdept, ref objDB); //绑定数据源
chrCount.Series.Clear(); 将柱状图实例情况
if (arrdc_staff != null)//根据人员动态添加柱状图图例
{
foreach (Cdc_staff objstaff in arrdc_staff)
{
chrCount.Series.Add(objstaff.m_nStaffid.ToString());
chrCount.Series[objstaff.m_nStaffid.ToString()].Legend = "Legend1";
chrCount.Series[objstaff.m_nStaffid.ToString()].LegendText = objstaff.m_szStaffname;
chrCount.Series[objstaff.m_nStaffid.ToString()].XValueMember = "strDate"; //X轴为日期
chrCount.Series[objstaff.m_nStaffid.ToString()].YValueMembers = objstaff.m_szStaffname; //Y轴为用户
//if (arrdc_staff.Count <= 5)
chrCount.Series[objstaff.m_nStaffid.ToString()].IsValueShownAsLabel = true;//是否显示柱状图没列值
}
更多
http://www.cnblogs.com/qailrapis/ }
chrCount.ChartAreas["ChartArea1"].AxisY.Title = "笔数(单位:笔)"; //Y轴单位
chrCount.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//设置Y轴标题的名称所在位置位远
chrCount.ChartAreas["ChartArea1"].AxisX.Interval = 1;
//txtDateEnd.Text = chrCount.Series.LongCount()。ToString();
//string file = Server.MapPath(@"~/TmpFiles/2.jpeg");
//chrCount.SaveImage(file, ChartImageFormat.Jpeg);
//chrCount.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false; //是否显示柱状图后面的方块
//chrCount.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;