Home Forums Chart Support How to preserve zeros after decimal point in tooltip?

How to preserve zeros after decimal point in tooltip?

Viewing 15 posts - 1 through 15 (of 21 total)
  • #22833

    Hi there, pulling figures from a CSV and some values have a zero after the decimal point, but these are lost in the tooltips. So “4.0” in the csv becomes “4” in the tooltip. How can I preserve the decimal point? I tried inserted this in the tooltip but it doesn’t do anything: valueFormatString: “#,###.#0”,

    #22837

    @ethicalsector,

    valueFormatString defines how values must be formatted before they appear on axisX, only. To format x-value and y-value that appear in toolTip or indexLabel, you can use xValueFormatString or yValueFormatString respectively.

    __
    Priyanka M S
    Team CanvasJS

    #22845

    I can’t get this to work, I’m not sure why. I’m going to try to find the previous jsfiddle you were helping with.

    #22870

    @ethicalsector,

    Please take a look at this updated jsfiddle.

    __
    Priyanka M S
    Team CanvasJS

    #22881

    Great, thanks!

    • This reply was modified 6 years, 2 months ago by ethicalsector.
    #22883

    no, it doesn’t work for me. Please see this updated JSFiddle. Did you do anything else apart from add the lines: yValueFormatString:”##.0″,

    https://jsfiddle.net/h41e85dv/

    #22887

    @ethicalsector,

    In the JSFiddle that you have shared, you are using toolTip contentFormatter where you need to format y-value accordingly – which you can do using formatNumber. Please take a look at this updated JSFiddle.


    Vishwas R
    Team CanvasJS

    #22922

    THANK YOU!

    #22950

    Hi again, in this solution: https://jsfiddle.net/h41e85dv/, if a value is less than 1, e.g. 0.9, the “0” before the dot does not display. Is there a way to fix this? i.e. The tooltip shows “.9” but it should show “0.9”

    #22953

    @ethicalsector,

    When you use “#” in the format-string, it replaces the “#” symbol with the corresponding digit if one is present; otherwise, no digit appears in the result string whereas when you use “0” in format-string it replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string. According to the options / documentation, setting yValueFormatString to “#,##0.0” should let you display 0.9 instead of .9 in toolTip/indexLabel.

    Please refer yValueFormatString for all available options.


    Vishwas R
    Team CanvasJS

    #22958

    No, that doesn’t work unfortunately. Any other way?

    #22959

    Correction, it does work, thanks!

    #22960

    Hi, if you change some of the values to ‘null’ in this jsfiddel: https://jsfiddle.net/h41e85dv/ for “country 6′ the line doesn’t connect between the remaining values. How can you make sure, even if there are only two datapoints for one of the lines, that the line still displays? I’ve tried adding “connectNullData: true” but it doesn’t work.

    #22963

    @ethicalsector,

    Parsing values from CSV properly for null values should work fine in your case. Please take a look at this updated JSFiddle.


    Vishwas R
    Team CanvasJS

    #22970

    thanks very much!

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic.