我正在使用谷歌电子表格来输入我的柱形图。为了使单列具有不同的颜色,我使用了一种 hack,方法是将图表中每一列的电子表格中相对列的值设置为 0。这给了我图表中每一列所需的颜色差异。我现在遇到的问题是工具提示不适用于每一列,并且想知道如何实现以在我的代码中正常工作。
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);