私のデータ:
Product_C ====== Product_B ====== product_A ======月
124=========== 101=============== 60 =============
123年2月============99=============== 59===== =========
130年3月=========== 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>
下の画像のようになると思います
が、空の空白のチャートが表示されます!
メソッドmyDataset = myObj.GetCompareSalesByMonths(firstMonth,lastMonth);
は目的のデータを返します。