我有图表,我想始终显示数据值(工具提示)。
我试过这段代码:https://github.com/chartjs/Chart.js/issues/1861 但总是不行。
这是我的代码:
var PieData = [
{
value: <?php echo $sumguide; ?>,
color:"#0a0fff",
label: "Guide"
},
{
value: <?php echo $sumvisit; ?>,
color:"#53ff28",
label: "Visit"
},
{
value: <?php echo $sumremote; ?>,
color:"#ff0d00",
label: "Remote"
}];
var pieOptions = {
segmentShowStroke: true,
segmentStrokeColor: "#fff",
segmentStrokeWidth: 1,
percentageInnerCutout: 50,
animationSteps: 100,
animationEasing: "easeOutBounce",
animateRotate: true,
animateScale: true,
responsive: true,
maintainAspectRatio: false
};
var pieChartCanvas = $("#pieChart2").get(0).getContext("2d");
var pieChart2 = new Chart(pieChartCanvas).Doughnut(PieData, pieOptions);
document.getElementById('js-legend2').innerHTML = pieChart2.generateLegend();