我正在使用谷歌電子表格來提供給我的柱形圖。爲了讓單列成爲不同的顏色,我使用了圖表中每列的電子表格中相對列上的值爲0的方法。這給了我在圖表中每列所需的顏色差異。我現在遇到的問題是工具提示不適用於每列,並且想知道如何實現在我的代碼中正確工作。Google圖表工具提示
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
var visualization;
function drawVisualization() {
var query = new google.visualization.Query(
'http://spreadsheets.google.com/tq?key=0AjlSK7_zXoNHdDhrU2xiaHVIQmR1WldYZm1yMTNkM3c&pub=1');
// Apply query language statement.
// Send the query with a callback function.
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
// set the 3rd column to the "tooltip" role
data.setColumnProperty(3, 'role', 'tooltip');
visualization = new google.visualization.ColumnChart(document.getElementById('visualization'));
visualization.draw(data, {legend: 'none', colors:['blue','red'],is3D:'True', isStacked:'true'});
}
google.setOnLoadCallback(drawVisualization);
如果以下答案適用於您,請點擊答案中向上/向下箭頭下方的複選標記,以便其他人可以看到這解決了您的問題。如果我的回答不夠清楚,或者您仍然有問題,請在答案中添加評論,以解釋哪些問題/哪些問題不明確。 – jmac