I am using DotNetHighCharts and playing around with the various chart formats. The Pie Chart labels show “Slice” for each slice of the pie. What parameter is used to change this to the actual name of the slice?
0
votes
1 Answers
0
votes
I got this figured out. I was using the PlotOptions like this
.SetPlotOptions(new PlotOptions
{
Pie = new PlotOptionsPie
{
DataLabels = new PlotOptionsPieDataLabels
{
Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
}
}
})
However, I wasn’t passing in the names of the datapoint. So I created a namesAndVals object array that was passed into the Data element of the .SetSeries method.
object[] names = new object[] { “Val1", “Val2", “Val3", “Val4" };
object[] vals = new object[] { 11, 12, 13, 14 };
object[,] namesAndVals = new object[4,2];
for (int i = 0; i < names.Count(); i++)
{
namesAndVals[i, 0] = names[i];
namesAndVals[i, 1] = vals[i];
}
If there is a better way to create the final array I’m open to suggestions. Eventually, the gals and names will be driven by a database.