简体   繁体   中英

How to develop Stacked Column Chart

I want to create Stacked Column Chart using ASP.NET, C#.

Can you give me examples to develop stacked column bar chart. And the series values are shown in bar, count at the top side of the bar. I am new to develop chart in dotnet.

Can anyone suggest me, how can I achieve this.

Would appreciate url's where can I find the demo to do this completely.

This may help you also see for more info

Or see this

you may use following code First add chart in aspx page as following:

  <asp:Chart ID="Chart1" runat="server" Width="500px">
                            <Series>
                                <asp:Series Name="Series1" ChartType="StackedBar"></asp:Series>
                            </Series>
                            <Series>
                                <asp:Series Name="Series2" ChartType="StackedBar"></asp:Series>
                            </Series>
                            <ChartAreas>
                                <asp:ChartArea Name="ChartArea1"></asp:ChartArea>
                            </ChartAreas>
                        </asp:Chart>

Then write following code:

 using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString))
        {
            cnn.Open();
            SqlDataAdapter da = new SqlDataAdapter("select MonthName,TotalTruck,Item from table1", cnn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            Chart1.DataSource = dt;
            Chart1.Series[0].XValueMember = "MonthName";
            Chart1.Series[0].YValueMembers = "TotalTruck";
            Chart1.Series[1].XValueMember = "Item";
            Chart1.Series[1].YValueMembers = "TotalTruck";
            Chart1.DataBind();
           }
        }

It will stack Item in the bars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM