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

Number of decimal places on category axis

2 Answers 1205 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Henrik
Top achievements
Rank 1
Henrik asked on 10 Aug 2018, 07:49 AM

Hi,

I have a histogram chart with very small values on the category axle, see attached image. I want the chart to display the values with 2 decimal places, but I can't find the correct way of doing this.

This is my code for the category axle:

categoryAxis: [{
    name: 'categoryAxis',                        
    categories: this.getEmptyCategories()
    ,
    labels: {                                                 
        visible: false                            
    },
    majorGridLines: {
        visible: true
    },
    justified:false
}],

How should I specify that I want more decimals?

Best regards,

Henrik

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 14 Aug 2018, 09:37 AM
Hello, Henrik,

The Kendo UI Chart does not round the categories by default so I would guess that the result of this.getEmptyCategories() is an array of strings, which are already formatted as we see see them in the screenshot. 

If the categories are numbers, you may use the categoryAxis.labels format option to format them, for example:

https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart/configuration/categoryaxis.labels#categoryAxis.labels.format

categoryAxis: [{
  labels: {
    format: "{0:n3}"
  },
  categories: [1.3,2.555,3.343]
}],

Alternatively, if no format is provided, they will be shown as is, no rounding will occur:

https://dojo.telerik.com/ukatOkOz

Finally, in the configuration, I can see that the labels are set to be not visible, yet they are visible in the screenshot. Could you modify one of the provided runnable examples above to better demonstrate the chart in your application in case further questions arise?

Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Henrik
Top achievements
Rank 1
answered on 15 Aug 2018, 01:51 PM

Thanks for the answer.

I had completely misunderstood how the axis values are calculated - they are calculated and positioned in a separate part of the code.

Problem has been solved.

Thanks and best regards,

Henrik

Tags
Charts
Asked by
Henrik
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Henrik
Top achievements
Rank 1
Share this question
or