2
我試圖使用PieceLabel插件來顯示圖形內的標籤,但它不工作。該圖形顯示OK,這裏是我的代碼:如何在Angular 4上使用ChartJS插件4
TS
import * as Chart from 'chart.js'
import * as ChartPiece from 'chart.piecelabel.js'
ngAfterViewInit() {
this.canvas2 = document.getElementById('myChartPie');
this.ctx2 = this.canvas2.getContext('2d');
let myChartPie = new Chart(this.ctx2, {
type: 'pie',
data: {
labels: ["one", "two", "three", "four"],
datasets: [{
label: '# of Score',
data: [11,21,31,41],
backgroundColor: [
'red',
'blue',
'orange',
'green'
]
}]
},
options: {
responsive: false,
display:true,
pieceLabel: {
mode: 'value'
}
}
});
}
我安裝了chart.js之和Chart.piecelabel.js與故宮安裝--save。我嘗試添加到.angular-cli.json文件,這一點,但它似乎並沒有產生任何影響:
"scripts": [
"../node_modules/chart.piecelabel.js/build/Chart.PieceLabel.min.js"
]
HTML
<canvas id="myChartPie" width="650px"></canvas>
它看起來像我的PieceLabel.min。 JS不會被調用/認可,我不知道爲什麼
它的工作,謝謝先生! – Gustavo