在chartJS中悬停索引时是否可以添加一些阴影?
Somethink like in this answer在点悬停时添加一条线,但我会将它与条形图一起使用并使其看起来像这样:
这是我的实际图表jsfiddle
<div class="chart-area chart-reparti">
<canvas id="chartReparti" width="1600" height="250"></canvas>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.js"></script>
var optionsReparti = {
maintainAspectRatio: false,
legend: {
display: true
},
tooltips: {
backgroundColor: '#f5f5f5',
titleFontColor: '#333',
bodyFontColor: '#666',
displayColors: true,
mode: 'index',
intersect: 0
},
responsive: true,
scales: {
yAxes: [{
id: 'importo',
gridLines: {
drawBorder: false,
borderDash: [4, 8],
color: 'rgba(0,132,255,0.4)',
},
ticks: {
beginAtZero: true,
userCallback: function (value, index, values) {
return "€" + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
}
}, {
id: 'qta',
gridLines: {
drawBorder: false,
borderDash: [4, 8],
color: 'rgba(247,136,0,0.4)',
},
ticks: {
beginAtZero: true
}
},
],
xAxes: [{
categoryPercentage: 1,
barPercentage: 0.4,
gridLines: {
drawBorder: false,
color: 'rgba(225,78,202,0.1)',
zeroLineColor: "transparent",
}
}]
}
};
实际上,从这个答案中得到的修改插件的代码不包括在内,因为它根本不起作用。
慕神8447489
相关分类