I use Chart.js for making charts.(我使用Chart.js制作图表。)
I discovered today new plugin for the original Chart.js.(今天,我发现了原始Chart.js的新插件。)
Plugin(插入)
After i added <script>
tags with the plugin, it applied automatically values to all my charts.(在使用插件添加<script>
标签之后,它会自动将值应用于所有图表。) It looks great, but it shows number values.(看起来不错,但显示数字值。) How do i make it show labels instead of values on the pieces of the pie?(如何使其显示标签而不是饼图上的值?) I have found some posts about the subject, but they contain different commands, and i tried all i could but it didn't change anything.(我已经找到了一些有关该主题的帖子,但是它们包含不同的命令,我尽了我所能,但没有任何改变。) Also for the future, tell me please how to turn off showing values for specific chart :)(另外为了将来,请告诉我如何关闭显示特定图表的值:))
fillPie()
{
// Three arrays have same length
let labelsArr = []; // Array with some names
let values = []; // Array with values
let randomColor = [];
var ctx = document.getElementById('pie-chart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'pie',
// The data for our dataset
data: {
labels: labelsArr, // I want it to show these labels
datasets: [{
backgroundColor: randomColor,
data: values, // It shows these values
hoverBackgroundColor: "#fba999"
}]
},
// Configuration options go here
options: {
legend: {
display: false
}
}
});
}
ask by Nar Jovan translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…