使用asp.net 3.5绑定数据与三维圆柱图

时间:2012-05-02 17:55:58

标签: c# asp.net charts asp.net-3.5 mschart

我的数据:

  

Product_C ====== Product_B ====== product_A ====== 月< / strong>
124 =========== 101 =============== 60 ============= 2月
  123 ============ 99 =============== 59 ============== 3月号130 ===========   100 ============= 70 ============== 4月号

很清楚 ;-) *?**
aspx代码:

<asp:CHART id="Chart1" runat="server">
<series>
    <asp:Series ChartArea="ChartArea1" Name="product_A" >
</asp:Series>
<asp:Series ChartArea="ChartArea1" Name="product_B">
    </asp:Series>
    <asp:Series ChartArea="ChartArea1" Name="product_C">
    </asp:Series>
    </series>
<chartareas>
  <asp:ChartArea Name="ChartArea1" > </asp:ChartArea> </chartareas>
</asp:CHART>

绑定代码:

        private void BindMyChart(int firstMonth,int lastMonth )
        {
      dsDataset myDataset = new dsDataset();
      bsHelper myObj =   new   bsHelper();
      myDataset = myObj.GetCompareSalesByMonths(firstMonth,lastMonth);
      if(myDataset.myTable.Rows.Count>0)
        {
            Chart1.DataSource = myDataset.myTable;// 
            DataView dv = myDataset.myTable.DefaultView;
            Chart1.Series["product_A"].Points.DataBindXY(dv,"Product_A",dv, "month");
            Chart1.Series["product_B"].Points.DataBindXY(dv, "Product_B",dv, "month");
            Chart1.Series["product_C"].Points.DataBindXY(dv, "Product_C",dv, "month" );
            Chart1.DataBind();
         }
      }

protected void Page_Load(object sender, EventArgs e)
{


            if (!IsPostBack)
            {
         BindMyChart(Convert.ToInt32(ddlfirstMonth.SelectedValue),
               Convert.ToInt32(ddllastMonth.SelectedValue));//drop down lists
            }
}


web.config:

    <assemblies><add assembly="System.Web.DataVisualization, 
     Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>
   <httpHandlers>
    <add path="ChartImg.axd" verb="GET,HEAD"      type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,      System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral,     PublicKeyToken=31bf3856ad364e35"   validate="false"/>
  </httpHandlers>
  <handlers>
  <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd"   type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization,   Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>  </handlers>

它假设如下图所示: chart_required
但是,我得到一张空白的空白图表! 方法myDataset = myObj.GetCompareSalesByMonths(firstMonth,lastMonth);返回所需的数据。

0 个答案:

没有答案