I 'm using Chart.js to draw pie chart.
To draw graph I used
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: #{raw @labels.to_json},
datasets: [{
backgroundColor: #{raw @colors.to_json},
data: #{@followers}
}]
}
});
To clarify this data thing is like this
data: {
labels: ["FAISAL","muhammadfaisali","faisaliqbal3699"],
datasets: [{
backgroundColor: ["#00b638","#efaa30","#50c8ea"],
data: [500000, 75000, 100000]
}]
}
I need to show these data: [500000, 75000, 100000]
as thousand separator like ["500,000", "75,000", "100,000"]
I tried different
things including writing this method
function separator(numbers)
{ data = []
for (i = 0; i < numbers.length; ++i) {
data.push(numbers[i].toLocaleString())
}
data
}
and tried to use it like this
data: separator(#{@followers})
it format data as I want but gives error like Cannot read property 'custom' of undefined
What is the way to show data in thousand separator here