0
我有一個ChartJS(v2)氣泡圖,具有三個維度:x,y和r(氣泡半徑)。ChartJS v2定製工具提示rLabel
繼this answer,我有一個自定義工具提示驗證碼:
tooltips: {
callbacks: {
label: function (tooltipItem, data) {
var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
return datasetLabel + ' : ' + tooltipItem.rLabel + '% har pris på ca. ' + tooltipItem.yLabel + ' kr.';
}
}
}
它幾乎工作,除了tooltipItem.rLabel
顯示爲undefined
。如果我輸入tooltipItem.xLabel
,則工具提示將正確顯示,其值爲x
。但是,我想顯示r
的值。
有沒有人知道這個解決方案?
謝謝!奇蹟般有效。一個小東西rLabel顯示17位小數。我有一種方法來限制小數位數? – Wessi
@Wessi你可以用'Math.round(num)'來循環num的值,或者在stackoverflow上有另外一個帖子來圓整數字,最多兩個地方.http://stackoverflow.com/questions/11832914/round-to-在最-2十進制地方 –