Nevron Forum

Calculate/convert axis labels

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

By Yonatan Doron - Thursday, January 28, 2016

Hi,

I'm using a NTriangulatedSurfaceSeries, and I would like to change the values displayed near the axis ticks.
For example, instead of the X axis ticks display values of -10000,0,10000, I would like to display -5,0,5.
Is there a way to supply something like a conversion function to convert the original value to the value I want to display?

What is the best way to accomplish this without changing the data supplied to the chart?
By Nevron Support - Friday, February 12, 2016

Hi Yonatan,

The following code shows how to apply a value scale to axis labels:

 NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;    
linearScale.LabelStyle.ValueScale = 0.0001;

Using this code labels that would normally show as 1000, 2000, will display as 1,2 etc.

Alternatively you can create a custom label value formatter:

        class CustomValueFormatter : NValueFormatter
        {
            public override string FormatValue(double value)
            {
                return (value / 1000).ToString();
            }

            public override string FormatValue(object value)
            {
                return FormatValue((double)value);
            }
        }

// somewhere in code
            NChart chart = nChartControl1.Charts[0];

            NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
            linearScale.LabelValueFormatter = new CustomValueFormatter();

Let us know if you meet any problems.