Home forums Using CanvasJS How to preserve zeros after decimal point in tooltip?

This topic contains 20 replies, has 3 voices, and was last updated by  Vishwas R 5 months, 1 week ago.

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #22977

    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?

    #22982

    I neglected to include the link to the JSFiddle: https://jsfiddle.net/canvasjs/h41e85dv/8/

    #22989

    @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

    #22997

    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?

    #22998

    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”) + ““;
    }

    #23010

    @ethicalsector,

    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.


    Vishwas R
    Team CanvasJS

Viewing 6 posts - 16 through 21 (of 21 total)

You must be logged in to reply to this topic.