You must be logged in to post your query.
Home › Forums › Chart Support › Adding the decimal places to the Y-axis
Tagged: Decimal Places, valueFormatString, Y axis
Hi Team,
I am trying to add decimal places to the y-axis according to the y-axis value. For example, 0-1 –> two decimal places, 1 – 10 –> one decimal place and 10 >= 100 –> no decimal places. I tried to add it but faced few issues. Attached the sample JSFiddle and image for your reference.
JSFiddle- https://jsfiddle.net/p3vqnc0b/27/ Image- https://prnt.sc/z1CkAIvHGSzv
@elanchezhiyan,
You can use labelFormatter function instead of valueFormatString and set the label format using the formatNumber() method. Please take a look at the code snippet below.
labelFormatter: function(e) { if(e.value >= 0 && e.value <= 1) return CanvasJS.formatNumber(e.value, "0.00"); else if (e.value >= 1 && e.value <=10 ) return CanvasJS.formatNumber(e.value, "0.0"); else return CanvasJS.formatNumber(e.value, "0"); }
Please check this updated JSFiddle for a working example.
— Thangaraj Raman Team CanvasJS
You must be logged in to reply to this topic. Login/Register