Skip to content

Instantly share code, notes, and snippets.

@donma
Created January 4, 2019 06:50
Show Gist options
  • Save donma/1746c142070722086a107eedfc234c78 to your computer and use it in GitHub Desktop.
Save donma/1746c142070722086a107eedfc234c78 to your computer and use it in GitHub Desktop.
Chart.js Line Chart Y Axis Comma Sign
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: '垂直軸的資料名稱'
},
ticks: {
beginAtZero: false,
callback: function (value, index, values) {
return value.toLocaleString();
}
}
}]
},
tooltips: {
mode: 'label',
label: 'mylabel',
callbacks: {
label: function (tooltipItem, data) {
return tooltipItem.yLabel.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment