我需要处理标尺上的onclick事件。我没有在Google图表文档中找到Gauges上注册事件的示例。如何将onclick事件添加到Google Chart的Gauge?
我曾尝试以下:
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart","gauge"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'LABEL');
data.addColumn('number', 'TOTAL');
data.addRows(1);
data.setValue(0, 0, 'Speed');
data.setValue(0, 1, 240);
var gaugeOptions = {min: 0, max: 280, yellowFrom: 200, yellowTo: 250, title: 'Company Performance', redFrom: 250, redTo: 280, minorTicks: 5};
var gauge = new google.visualization.Gauge(document.getElementById('gauge_div'));
gauge.draw(data, gaugeOptions);
google.visualization.events.addListener(gauge, 'select', function() {
alert("Here");
});
}
</script>
</head>
<body>
<div id="gauge_div"></div>
</body>
</html>
此外,我试图用jQuery添加onclick事件格“gauge_div”但如果我点击div的边界,而不是在计它只。
是这个作品,如果你只有一个计,但是当你有使许多计我想要得到的onclick事件并识别发件人。 –
在这种情况下,您可能想了解如何从iframe捕获点击事件。 http://stackoverflow.com/questions/1609741/how-to-add-click-event-to-a-iframe-with-jquery – chris