Nevron Forum

How to show the percentage in axis Y?

https://www.nevron.com/Forum/Topic5045.aspx

By Jacky zhang - Wednesday, March 30, 2011

Hi,

How to show the percentage in axis Y?

I have a 3D bar chart and I want to show axis Y value as percentage just like Gallery - XY Scatter Bubble chart.

Can you give a sample code?

thanks again,

-Jacky

 

 

By Nevron Support - Thursday, March 31, 2011

Hi Jacky,

If the values on displayed on the axis are ready for percentage formatting - that is all values are rescaled to the range [0, 1] then you can simply change the formatting to percentage - for example:

NChart chart = nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();
bar.Values.Add(0.1);
bar.Values.Add(0.2);
bar.Values.Add(0.3);
chart.Series.Add(bar);

NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
scale.LabelValueFormatter = new NNumericValueFormatter("P");

Otherwise you can use the ValueScale property of the scale label style:

NChart chart = nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(30);
chart.Series.Add(bar);

NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
scale.LabelStyle.ValueScale = 0.01;
scale.LabelValueFormatter = new NNumericValueFormatter("P");

Hope this helps - let us know if you meet any problems.