How to show the values in each bar of a chart

2

Buenos Dias, I would like to know if you can help me, I'm doing a statistical chart with asp.net c #, so I got the graph but what does not come out is that I want the actual number in each bar to appear for example as well as the image

Currently I get it but without those numbers above and that's what I would like

Currently this is my html code.

<asp:Chart ID="Chart1" runat="server" Width="600px">
                        <Titles>
                            <asp:Title Text="Costo Mensual"></asp:Title>
                        </Titles>
                        <Series>
                            <asp:Series Name="Series1" XValueMember="0" YValueMembers="2">
                            </asp:Series>
                        </Series>
                        <ChartAreas>
                            <asp:ChartArea Name="ChartArea1">
                            </asp:ChartArea>
                        </ChartAreas>
                    </asp:Chart>

and in the code:

DataSet ds = new DataSet();
                SqlConnection cn = new SqlConnection(ObtenerCadenaConexion());
                cn.Open();
                SqlCommand cmd2 = new SqlCommand("GenerarBarraLineal", cn);
                cmd2.CommandType = CommandType.StoredProcedure;
                cmd2.Parameters.Add("@opt", SqlDbType.Int);
                cmd2.Parameters.Add("@anio", SqlDbType.VarChar);
                cmd2.Parameters.Add("@suministro", SqlDbType.VarChar);

                cmd2.Parameters["@opt"].Value = 1;
                cmd2.Parameters["@anio"].Value = cboPeriodo.SelectedItem.Text;
                cmd2.Parameters["@suministro"].Value = "";

                cmd2.ExecuteNonQuery();

                SqlDataAdapter da = new SqlDataAdapter(cmd2);
                da.Fill(ds);
                Chart1.DataSource = ds;
                cn.Close();
    
asked by PieroDev 07.12.2017 в 18:22
source

1 answer

2

I think you're looking for this:

IsValueShownAsLabel="true"

inside the series tag, with which you would stay like this:

<asp:Series Name="Series1" XValueMember="0" YValueMembers="2" IsValueShownAsLabel="true">
    
answered by 07.12.2017 / 18:28
source