javascript - 删除图例 ChartsJS 2.8.0
问题描述
对不起我的英语不好。我是巴西人。我需要删除 chartJS 2.8.0 上的条形图图例。
这是我的代码:
<div style="height:250px; width:520px;">
<canvas id="myChartBar"></canvas>
</div>
<script type="text/javascript">
var ctx = document.getElementById('myChartBar');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['<?php echo implode("','", $resultadoSaldo["label"]) ?>'],
datasets: [{
label: '# of Votes',
data: [<?php echo implode(',', $resultadoSaldo['value'])?>],
backgroundColor: ['<?php echo implode("','", $resultadoSaldo["color"]) ?>'],
borderColor: ['<?php echo implode("','", $resultadoSaldo["color"]) ?>'],
borderWidth: 3
}]
},
options: {
responsive: true,
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
我认为代码会起作用:图例:{显示:假},
但我的 grafh 也是如此:
我需要删除这个:
解决方案
Those labels aren't the legend, they are the X Axis labels. Try this:
options: {
scales: {
xAxes: [{
ticks: {
display: false
}
}]
}
}
推荐阅读
- php - 无法使用 PHP 在 MySQLi 准备好的语句中进行方法链接
- python - Lucas-Kanade 光流无法跨帧跟踪特征点
- powershell - 本地到 Sharepoint 数据迁移
- java - Agora 一对一通话 - Android 原生
- unity3d - Unity 3d 粒子未在游戏视图中显示
- verification - Yosys 和 JasperGold 如何比较?
- java - 如何通过 Swagger UI 为所有 API 发送请求标头(Origin)
- react-native - 如何在 react native 项目中解决此问题 - “npm ERR!Invalid tag name ">=^16.8.1"” 这个问题?
- flask - 烧瓶应用程序中未显示 Flash 消息
- mongodb - 对集合进行分片的正确方法以及如何解释结果