I am making a pie chart, also called a pie chart, developing in web form asp.net c# with Highcharts .Net, using a webService
tool that extracts a dataSet and converts it into a dataTable
.
So far everything is going well for me, the only mishap is that instead of the name of each section on the cake, it comes out as "Slice". I would like that instead of that word the names that are stored in my DataTable are shown.
DSet = Revi.B_Sp_Rev_IngresarObservaciones(19, Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd").ToString()), Session["username"].ToString(), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd").ToString()), txtfechainicio.Text, txtfechafin.Text,"","","","","","","","","","","","","","","","","","");
DSet = Revi.B_Sp_RevCatalogo(74, "", "");
DataTable DT = new DataTable();
DT = DSet.Tables[0];
String[] Browsername = new String[DT.Rows.Count];
String[] Total = new String[DT.Rows.Count];
for (int i = 0; i < DT.Rows.Count; i++)
{
Browsername[i] = Convert.ToString(DT.Rows[i]["browsername"].ToString());
Total[i] = Convert.ToString(DT.Rows[i]["total"].ToString());
}
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
.SetTitle(new DotNet.Highcharts.Options.Title {
Text = "GRÁFICO PASTEL",
X = -20
})
.SetSubtitle(new DotNet.Highcharts.Options.Subtitle {
X = -20
})
.SetXAxis(new DotNet.Highcharts.Options.XAxis {
Categories = Browsername.ToArray()
})
.SetSeries(new Series {
Type = ChartTypes.Pie,
Data = new Data(Total.Select(x => (object)x).ToArray())
});
grafpastelasesor.Text = chart.ToHtmlString();
Data from my Webservice that it returns to me.
Thank you..!!
Well I hope it helps you solved the problem. what happened is the part of:
It only sent the value but not the name and since I had the value in a datatable I had to insert it into a list and place it this way.
in the series part.
and so it graphed me and showed the value.
I leave the complete code I hope it can help someone.