Profile Picture

Percentage data labels displayed incorrectly

Posted By Lucy Clarke 12 Years Ago
Author
Message
Lucy Clarke
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 5, Visits: 1
I have a line series displayed on a chart with the y axis set to display percentages.The y axis and the data appears correctly. 
However the labels display the percentage values wrongly e.g. 3 is plotted correctly as 300 % but the label says 33.33%. 
Any way of getting the data labels to display correctly would be much appreciated.
Thanks
Lucy
 
NCartesianChart barChart = new NCartesianChart();            
barChart.Margins = new NMarginsL(10, 0, 0, 10);            
barChart.Dock = winforms.DockStyle.Fill;            
barChart.BoundsMode = BoundsMode.Stretch;            
 _chartControl.Charts.Add(barChart);            
_currentChart = barChart;             
NStandardScaleConfigurator yScale = (NStandardScaleConfigurator)barChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;            
yScale.LabelValueFormatter = new NNumericValueFormatter(NumericValueFormat.Percentage);                    
NLineSeries lineSeries = (NLineSeries)barChart.Series.Add(SeriesType.Line);                
lineSeries.DataLabelStyle.Format = "<percent>";            
lineSeries.Values.Add(3);            
lineSeries.Values.Add(4);            
lineSeries.Values.Add(2);                     
barChart.Refresh();             
_chartControl.Refresh();
 
 


Lucy Clarke
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 5, Visits: 1

Hi,

I found a way around this problem using custom labels thanks, so I don't need any help.

Thanks

Lucy



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hello Lucy,

The format string that you specified:

lineSeries.DataLabelStyle.Format = "<percent>";

instructs the label to display the data point's value as percent of the total for the series. So in this case the chart automatically sums all the values in the data series (3 + 4 + 2 = 9) and displays the value (3) as percent of the sum (9), so 33.33% is correct.


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic