You must be logged in to post your query.
Home › Forums › Chart Support › How to preserve zeros after decimal point in tooltip?
Hi again, I’m trying to add “cultureinfo” so that the decimal is displayed as a comma instead of a point. However, following these instructions: https://canvasjs.com/docs/charts/chart-options/culture/ , it doesn’t work for some reason?
I neglected to include the link to the JSFiddle: https://jsfiddle.net/canvasjs/h41e85dv/8/
@ethicalsector,
Tooltip’s contentFormatter overrides the culture-info in the JSFiddle that you have shared. Instead you can use toolTipContent in dataSeries to customize the toolTip content and apply culture aswell. Please take a look at this updated JSFiddle.
— Vishwas R Team CanvasJS
Hi, this works, but now we have lost the ‘zero’ after the decimal place for whole numbers. Is it possible to have both? A zero after the decimal place for whole numbers, and also a comma for the decimal place?
all these rules are still required: contentFormatter: function (e) { var content = ” “; for (var i = 0; i < e.entries.length; i++) {
if( e.entries[i].dataPoint.y <= 1.24 ) return “” + CanvasJS.formatNumber(e.entries[i].dataPoint.y, “#,##0.0”) + ““; else if( e.entries[i].dataPoint.y <= 1.25 ) return “<2.5“; else return “” + CanvasJS.formatNumber(e.entries[i].dataPoint.y, “#,##0.0”) + ““; }
formatNumber accepts optional culture parameter aswell. If you like to use contentFormatter and apply cultureInfo, you can pass the culture to formatNumber and format according to your requirements. Please take a look at this updated JSFiddle.
You must be logged in to reply to this topic. Login/Register