This is a migrated thread and some comments may be shown as answers.

Numerical Axis: LabelFormat documentation?

3 Answers 370 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 20 Oct 2016, 09:35 AM

Hi, 

Is there any documentation on setting up custom label formats? the .net formats don't seem to work, and I am supporting some dynamic configuration which will mean i need to 'translate' from the .net format to something that will work for the ios and android renderers.

 

Thanks

Phil

3 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 20 Oct 2016, 09:36 PM
Hello Phillip,

We have this section in the documentation that has an example of applying a NumericalAxis LabelFormat depending platform.

Here's the snippet (notice the WinPhone platform target can use the .NET "N2" numerical string format):

axis.LabelFormat = Xamarin.Forms.Device.OnPlatform("%.2f","%.2f", "N2");

For the Xamarin side of things, here is their documentation for the topic.

Please let us know if you have any further questions.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Philip
Top achievements
Rank 1
answered on 21 Oct 2016, 07:52 AM

Hi,

I had already found that stuff, the specific issue i am trying to work out at the moment is that i have a value of 510000, which if i dont specify a format displays as 510,000 - including the cultures formatting to add the , in the appropriate place. However i want to display to 2dp and keep the formatting, I have tried setting (for ios) "%.2f" and the display value becomes 510000.00 - if i try "%.2n" - i get nothing displayed as the axis values at all. Please advise how i can build a format to display the 510,000.00?

Thanks

0
Lance | Manager Technical Support
Telerik team
answered on 21 Oct 2016, 04:19 PM
Hello Philip,

I am not able to reproduce the problem you're having, see the attached screenshot. I've also attached the demo application you see in the screenshot, as you can see I'm setting the LabelFormat with the values I showed in my last reply. The axis labels properly display the 2 decimal points.

I tried with both XAML and C#, since I showed you the C# approach in my last reply, here is the XAML approach

<telerikChart:RadCartesianChart.VerticalAxis>
      <telerikChart:NumericalAxis x:Name="numericalAxis">
        <OnPlatform x:TypeArguments="x:String" Android="%.2f" WinPhone="N2" iOS="%.2f"/>
      </telerikChart:NumericalAxis>
</telerikChart:RadCartesianChart.VerticalAxis>


Just to make sure this wasn't related to an underlying value issue, I used both a value with a fractional value and one without:

// In StartPageViewModel.cs
new ChartData { Category = "Apples", Value = 510000.25 },
new ChartData { Category = "Oranges", Value = 125000 }


If you're still having an issue, please provide us with a reproducible example so that we can investigate further. You can also just update my demo so that it replicates the issue and send that back instead.  Note that you'll need to open a support ticket because you can't attach zip folders to public forum posts. You can open a ticket from your Support Tickets Page

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Philip
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Philip
Top achievements
Rank 1
Share this question
or