前段时间,项目中开发用到
柱状图,饼图,由于vs上没有这边好的控件,在网上搜索咯下,
发现chart控件的评价还是相当高的,先说下安装步骤,首先得安装.net framework 3.5sp1,对应vs2008安装MSChart_Visual
StudioAddOn.exe,vs2010则安装MSChart.exe。安装好后打开vs软件,在数据类控件库里面就能看到chart控件了,拖过来就能用。
主要收下一些属性的意思,免得不会的又去学习一遍,浪费时间
前台:
<asp:Chart ID="chrCount" runat="server" BackColor="LightSteelBlue"
BackGradientStyle="TopBottom" BackSecondaryColor="White" EnableTheming="False"
Enable
ViewState="True" Height="303px" Width="1015px" ImageStorageMode="UseImageLocation">
<Legends>
<asp:Legend Alignment="Center" Docking="Left" Name="Legend1" Title="图例">
</asp:Legend>
</Legends>
<Titles>
<asp:Title Font="微软雅黑, 16pt" Name="Title1" Text="个贷中心信息录入岗完成笔数统计表">
</asp:Title>
</Titles>
<Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<AxisX><MajorGrid Enabled="false" /></AxisX>
<AxisY><MajorGrid Enabled="false" /></AxisY>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
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;//是否显示柱状图没列值
}
}
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;
http://fancility.taobao.com老婆开的店,有空大家去逛逛
- MSChart.rar (5.6 MB)
- 下载次数: 0