我正在使用Chart.js,遇到一个需要帮助的问题。
甜甜圈已正确创建并显示了我需要的信息,但是,当我将鼠标悬停在图表的一个方面时,它仅显示填充文本值。
这是我正在使用的代码
options = {
cutoutPercentage: 75,
rotation: Math.PI,
//circumference: Math.PI * values[0],
//segmentShowStroke: false,
animation: {
animateScale: true,
onComplete: function () {
var width = this.chart.width,
height = this.chart.height;
var fontSize = (height / 114).toFixed(2);
this.chart.ctx.font = fontSize + "em Verdana";
this.chart.ctx.textBaseline = "middle";
var text = "82%",
textX = Math.round((width - this.chart.ctx.measureText(text).width) / 2),
textY = height / 2;
console.log(RpData);
this.chart.ctx.fillText(RpData.datasets[0].data[0] + "%", textX, textY);
}
},
legend: {
display: false,
},
tooltips: {
enabled: false,
},
};
$('#riskFactorChartLoading').hide("fast");
var ctx = $("#riskFactorChart").get(0).getContext("2d");
var riskFactorChart = new Chart(ctx, {
type: 'doughnut',
data: RpData,
options: options
});
看起来像这样;
我想要实现的是看到鼠标悬停的结果,而不必将鼠标悬停在它上面以查看我的值。
谢谢
请提供您的完整代码。因为在代码中没有给出“ RpData”。
这是jsfiddle链接,可以正常工作,但是由于您未获得指向完整代码段或代码的任何链接,因此我们无法检查问题所在...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句