我的问题可能有点混乱,所以我会解释一下。
我使用Google Charts制作了一个简单的饼图。它工作得很好。我需要知道的是能够链接饼图的所有部分/部分以显示 jquery 模式/对话框弹出窗口。
我搜索了很长时间,但仍然找不到任何接近的东西。
感谢大家的阅读,希望有人可以帮助我:)
这是我的代码来显示我的图表
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Clan');
data.addColumn('number', 'Vampire');
data.addRows([
<? foreach($this->toDisplay as $oClan)
{
echo "['".$oClan->getName()."', ".count($oClan->getMembers()).']';
echo ", ";
} ?>
]);
var options = {'title':'Effectif des clans',
'width':600,
'height':600};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<body>
<div id="chart_div"></div>
</body>
这里的代码与监听器做我想要的:)
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Clan');
data.addColumn('number', 'Vampire');
data.addRows([
<? foreach($this->toDisplay as $oClan)
{
echo "['".$oClan->getName()."', ".count($oClan->getMembers()).']';
echo ", ";
} ?>
]);
var options = {'title':'Effectif des clans',
'width':600,
'height':600};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
function selectHandler() {
var selectedItem = chart.getSelection()[0];
if (selectedItem) {
var topping = data.getValue(selectedItem.row, 0);
alert('The user selected ' + topping);
}
}
google.visualization.events.addListener(chart, 'select', selectHandler);
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>