Calculate/convert axis labels


Author
Message
Yonatan Doron
Yonatan Doron
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)
Group: Forum Members
Posts: 2, Visits: 20
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?
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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.


Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search