Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hiii... actually i put all the code to make the bar chart but the barchart column do not showing up. i think i got problem on the chart series @@
below is my aspx code

ASP.NET
<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>


this is my c# code

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();
}}


what should i do so i the chart series can be seen? please help me thank you in advance :)
Posted

1 solution

Try to separate the database logic.Please see the below link it will help you

Bar Chart
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900