工作中点滴记录

永远保持学徒心态

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

经常遇见数据统计图,要求有Y副轴,统计图如下:

MSCHART源代码

MSCHART源代码
 1  <asp:Chart ID="Chart1" runat="server" Width="700px" Height="300px">
 2             <Series>
 3                 <asp:Series Name="Series1" ChartType="Column" BorderWidth="1" ShadowOffset="1" IsValueShownAsLabel="true"
 4                     IsVisibleInLegend="true" MarkerStyle="Circle">
 5                 </asp:Series>
 6                 <asp:Series Name="Series2" ChartType="Column" BorderWidth="1" ShadowOffset="1" IsValueShownAsLabel="true"
 7                     IsVisibleInLegend="false">
 8                 </asp:Series>
 9             </Series>
10             <ChartAreas>
11                 <asp:ChartArea Name="ChartArea1">
12                     <AxisY LineColor="64,64,64,64" IsLabelAutoFit="false">
13                         <LabelStyle />
14                         <MajorGrid LineColor="64,64,64,64" />
15                     </AxisY>
16                     <AxisY2 LineColor="64,64,64,64" IsLabelAutoFit="false">
17                         <LabelStyle />
18                         <MajorGrid LineColor="64,64,64,64" />
19                     </AxisY2>
20                 </asp:ChartArea>
21             </ChartAreas>
22         </asp:Chart>

后台代码:

后台代码
 1  this.Chart1.DataSource = dt;
 2         this.Chart1.Series[0].YAxisType = System.Web.UI.DataVisualization.Charting.AxisType.Primary;
 3         this.Chart1.Series[0].XAxisType = System.Web.UI.DataVisualization.Charting.AxisType.Primary;
 4         this.Chart1.Series[0].XValueMember = "supplyname";
 5         this.Chart1.Series[0].YValueMembers = "cgsumprice";
 6         this.Chart1.Series[0]["PointWidth"] = "0.2";
 7         this.Chart1.Series[1]["PointWidth"] = "0.2";
 8         this.Chart1.Series[0]["DrawingStyle"] = "Cylinder";
 9         this.Chart1.Series[1]["DrawingStyle"] = "Cylinder";
10         this.Chart1.ChartAreas[0].AxisY.Title = "采购金额(元)";
11         this.Chart1.ChartAreas[0].AxisY2.Title = "交易次数(次)";
12         this.Chart1.Series[1].XAxisType = System.Web.UI.DataVisualization.Charting.AxisType.Primary;
13         this.Chart1.Series[1].YAxisType = System.Web.UI.DataVisualization.Charting.AxisType.Secondary;
14         this.Chart1.Series[1].YValueMembers = "jylcount";
15         this.Chart1.DataBind();

 

posted on 2012-12-17 08:58  梦里故乡  阅读(4054)  评论(0编辑  收藏  举报