为什么条形图列不显示

时间:2014-06-03 13:26:38

标签: c# sql asp.net visual-studio-2010 charts

我把所有代码都放在条形图上,但条形图列没有出现。我想我在图表系列@@

上遇到了问题

下面是我的aspx代码:

<asp:Chart ID="Chart1" runat="server" BackColor="Gray" EnableViewState="True" 
        Width="502px">
        <Series>
            <asp:Series Name="Series1" BackImageTransparentColor="Gray" 
                BackSecondaryColor="RosyBrown" BorderColor="Transparent" 
                BorderDashStyle="NotSet" ChartArea="ChartArea1" Color="Purple" 
                LabelBackColor="255, 128, 0" MarkerBorderColor="Lime" MarkerColor="Blue" 
                ShadowColor="BlueViolet">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1" BackColor="Khaki" 
                BorderColor="MediumAquamarine">
            </asp:ChartArea>
        </ChartAreas>
        <Titles>
            <asp:Title BackColor="White" BackImageAlignment="Top" ForeColor="Maroon" 
                Name="Forecast result" Text="Forecast result">
            </asp:Title>
        </Titles>
    </asp:Chart>

这是我的c#代码

protected void Button5_Click(object sender, EventArgs e)
{
    int i = int.Parse(DropDownList1.SelectedValue);
    SqlConnection connection = new SqlConnection("Data Sourceaaa;Initial Catalog=System;Integrated Security=True");
    connection.Open();

    SqlDataAdapter fdm = new SqlDataAdapter("select (case when [Month] = 1 then 'January' when [Month] = 2 then 'February'when [Month] = 3 then 'March' when [Month] = 4 then 'April'when [MONTH] = 5 then 'May'when [MONTH] = 6 then 'June' when [MONTH] = 7 then 'July' when [MONTH] = 8 then 'August' when [MONTH] = 9 then 'September' when [MONTH] = 10 then 'October' when [MONTH] = 11 then 'November' when [MONTH] = 12 then 'December' end) as Month, sum(demand) as Result  from reorder where id ='" + i + "' and [Month] in (1, 2, 3, 4,5,6,7,8,9,10,11,12) group by [Month] order by [Month];", connection);
    DataSet ds = new DataSet();
    fdm.Fill(ds);
    Chart1.DataSource = fdm;

    Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Month";
    // here i am giving the title of the y-axis
    Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Result";
    // here i am binding the x-axisvalue with the chart control
    Chart1.Series["Series1"].XValueMember = "Month";
    // here i am binding the y-axisvalue with the chart control
    Chart1.Series["Series1"].YValueMembers = "result";

    Chart1.DataBind();


    fdm.Dispose();
    connection.Close();
}

我该怎么办才能看到图表系列?

0 个答案:

没有答案