I want to take a very large number that looks like this:
123456789
And make it so it looks like this in the tooltip when I click in my line graph:
$123,456,789
I have this function to add the commas:
function addCommas(str)
{
var amount = new String(str);
amount = amount.split(“”).reverse();
var output = “”;
for (var i = 0; i <= amount.length – 1; i++)
{
output = amount[i] + output;
if ((i + 1) % 3 == 0 && (amount.length – 1) !== i)
output = ',' + output;
}
return output;
}
My tooltipFormatFunction looks like this:
toolTipFormatFunction : function(value)
{
var newValue = addCommas(value);
return "$" + newValue;
}
Nothing changes in my tooltip. Please help? Thanks.