【发布时间】:2018-07-08 17:44:30
【问题描述】:
我正在尝试显示图表的信息,而无需用户将鼠标悬停在图表的任何部分上。我正在使用 Chart.js 和 Angular.js
我的疑惑和这个question here!是一样的
html 代码:
<div class="wrapper-chart" >
<canvas
id="pie"
class="chart chart-pie"
chart-data="data"
chart-labels="labels"
chart-options="options"
chart-colors="colors"
legend = "true"
chart-series="series">
</canvas>
</div>
角度代码:
angular
.module('myBeeApp.controllers')
.controller('chartHome', chartHome);
chartHome.$inject = [
'$scope'
];
function chartHome(
$scope
){
$scope.labels = ["Primavera", "Verão", "Outono", "Inverno"];
$scope.data = [32, 53, 14, 79];
$scope.options = {
showToolTips: true,
tooltipEvents: [],
onAnimationComplete: function() {
this.showTootip(this.datasets[0].bars,true);
},
title: {
display: true,
text: 'Quantidade por Estação',
fontColor: '#ff8c1b',
fontFamily: 'HelveticaNeue',
fontSize: 26,
},
legend: {
display: true
},
cutoutPercentage: 50,
};
$scope.colors = ["#FF7400", "#C85B00", "#FFB77B", "#E3831E"];
}
图表已正确生成,但尚未显示任何信息。
生成的图表(我的图表):
我希望它是怎样的(带标签):
我已经尝试过这段代码,但没有对我有用!
$scope.options = {
tooltipEvents: [],
showTooltips: true,
tooltipCaretSize: 0,
onAnimationComplete: function () {
this.showTooltip(this.segments, true);
},
};
我也试过following these steps! 根本没用!(这就是为什么我认为这不是重复的问题)
版本:角度 - v1.6.6 ;角度图 - v1.1.1; chart.js - v2.7.1
感谢一切!
【问题讨论】:
标签: javascript html angularjs chart.js angular-chart