0

我的数据:

Product_C ====== Product_B ====== product_A ======第 124 个
=========== 101============== 60 ============= 2 月
123=============99================ 59===== =========3月
130============ 100============= 70============= =四月

是否清楚 ;-) *?**
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);返回所需的数据。

4

0 回答 0