有人可以帮助我,为什么工具提示不可见?我尝试使用“工具提示:{isHtml:true}”,但无法正常工作。任何帮助表示赞赏。
<script>
google.charts.load('current', {'packages':['treemap']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Customer', 'Region', 'Sales', 'Score'],
['America', null, 0, 0],
['Apple', 'America', 0, 0],
['VW', 'America', 0, 0],
['Costco', 'America', 0, 0],
['Amazon', 'America', 0, 0],
['1-Apple', 'Apple', 115.5, 0.70],
['2-Apple', 'Apple', 115.5, 0.70],
['3-Apple', 'Apple', 52.5, 0.70],
['1-VW', 'VW', 49, 0.45],
['2-VW', 'VW', 9.4, 0.39],
['3-VW', 'VW', 7.4, 0.35]
['1-Costco', 'Costco', 5.2, 0.3],
['1-Amazon', 'Amazon', 4.8, 0.3],
]);
var options = {
headerColor: '#dfe4e9',
highlightOnMouseOver: true,
maxDepth: 1,
maxPostDepth: 4,
minHighlightColor: '#FF8B30',
midHighlightColor: '#FFC03C',
maxHighlightColor: '#FFE730',
minColor: '#29ECB4',
midColor: '#00ACED',
maxColor: '#09F6A9',
headerHeight: 25,
showScale: false,
useWeightedAverageForAggregation: true,
showTooltips: true,
generateTooltip: showFullTooltip
};
var tree = new google.visualization.TreeMap(document.getElementById('grph'));
tree.draw(data, options);
}
</script>
这是工具提示的功能:
function showFullTooltip(row, size, value) {
return
'<div style="z-index:1000000; background:#9daab6; padding:10px;">' +
'<span><b>' + dataT.getValue(row, 0) + '</b>, ' + dataT.getValue(row, 1) +
', ' + dataT.getValue(row, 2) + ', ' + dataT.getValue(row, 3) + '</span>' +
'<br>' +
'Datatable row: ' + row +
'<br>' +
dataT.getColumnLabel(2) + ' Sales: ' + size +
'<br>' +
dataT.getColumnLabel(3) + ': ' + value +
' </div>';
}
如果问题是浮点数,则为idk,但是是“数字”值,似乎在配置中接受。
我唯一能确定的是html字符串的第一行,需要与return
语句在同一行...