我试图在用户点击特定栏时触发使用Google的Chart API创建新的BarChart.我想我理解这些概念,并希望至少让getSelection()函数工作并显示用户点击的栏.但每次,当你点击栏时,它只是冻结了显示屏而没有java警报.有什么想法吗?
这是代码:
<script type="text/javascript">
google.setOnLoadCallback(drawChart);
function drawChart() {
var visualization = new google.visualization.BarChart(document.getElementById('acctmeta'));
var json_data = new google.visualization.DataTable({{acctmeta_json}});
visualization.draw(json_data, {width: 850, height: 600, title: 'Collection Level Populated Metadata Fields',
chartArea: {width:"50%"},
vAxis: {title: 'Collection Title/ID', titleTextStyle: {color: 'green'}},
hAxis: {logScale:false, title:'Fields Populated', titleTextStyle: {color: 'green'}}
});
// Add our selection handler.
google.visualization.events.addListener(visualization, 'select', selectHandler);
// The selection handler.
// Loop through all items in the selection and concatenate
// a single message from all of them.
function selectHandler() { …Run Code Online (Sandbox Code Playgroud)