Doubt of how to format value using Chart Chart JS

2

I'm using a Jquery plugin called Chart JS.

asked by anonymous 19.04.2016 / 18:32

2 answers

2

This is possible through graph options (existing but not very clear in documentation ), using tooltipTemplate and scaleLabel to change the text within the graph and the Y axis respectively.

In practice it could be done like this:

var formatedString = '<%= "R$ " + value.toString().split(".").join(",") %>';

var options = {
    scaleFontFamily: "'Verdana'",
    scaleFontSize: 13,
    animation: false,
    scaleFontColor: "#484848",
    responsive: true,
    tooltipTemplate: formatedString,
    scaleLabel: formatedString
};

jsFiddle: link

If you want, you can also use a function to format the string. The function receives an object as the first argument and the value is in the .value property. For example: link

    
19.04.2016 / 20:15
0

When working with more than dataset , you should use the option multiTooltipTemplate instead of tooltipTemplate .

Ex.

multiTooltipTemplate: function(data) {
    return formatar(data.value);
  }

I've updated your example this way and it's working.

link

    
08.09.2016 / 03:52