Skip to content

Instantly share code, notes, and snippets.

@andregardi
Created September 28, 2018 20:17
Show Gist options
  • Save andregardi/64650705baabd6a1db579567a3c7332f to your computer and use it in GitHub Desktop.
Save andregardi/64650705baabd6a1db579567a3c7332f to your computer and use it in GitHub Desktop.
function float2dollar(value){
return "U$ "+(value).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
function renderChart(data, labels) {
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'This week',
data: data,
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
callback: function(value, index, values) {
return float2dollar(value);
}
}
}]
}
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment