【发布时间】:2017-09-28 04:22:03
【问题描述】:
我正在使用最新版本的 Chart Js。我需要始终在图表中显示标签(没有鼠标悬停)。是否可以?如果是,请帮助我提供工作示例代码。
谢谢。
我当前的 Chartjs 代码:
var ctx = $("#myChart");
var label = ctx.data('clabel').split(',');
var val = ctx.data('cval').split(',');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: label,
datasets: [{
label: 'Daily Capital',
data: val,
backgroundColor: [
'rgba(0, 153, 34, 0.5)',
],
borderColor: [
'rgba(0, 153, 34, 1);',
],
borderWidth: 2
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
legend: {
display: false,
},
animation: {
duration: 0, // general animation time
},
hover: {
animationDuration: 0,
},
responsiveAnimationDuration: 0, // animation duration after a resize
elements: {
line: {
tension: 0, // disables bezier curves
},
},
tooltips: {
callbacks: {
label: function(tooltipItem, data){
return '£' + tooltipItem.yLabel;
},
title: function(tooltipItem, data){
return '';
},
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
我希望有人可以提供帮助。提前谢谢你
【问题讨论】:
标签: javascript charts chart.js