google.charts.load('current', {
callback: function() {
drawChart();
window.addEventListener('resize', drawChart, false);
},
packages:['corechart']
});
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Pizza');
data.addColumn('number', 'Populartiy');
data.addRows([
['Pepperoni', 33],
['Hawaiian', 26],
['Mushroom', 22],
['Sausage', 10],
['Anchovies', 9]
]);
var dataPepperoni = new google.visualization.DataTable();
dataPepperoni.addColumn('string', 'Pepperoni');
dataPepperoni.addColumn('number', 'Type');
dataPepperoni.addRows([
['Spicy', 2],
['Mild', 3],
['Hot', 4]
]);
var options = {
height: 400
};
var tooltip = document.getElementById('chart_div_tooltip');
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
google.visualization.events.addListener(chart, 'onmouseover', function (gglEvent) {
if (gglEvent.row === 0) {
tooltip.className = 'tooltip';
new google.visualization.PieChart(tooltip).draw(dataPepperoni);
}
});
google.visualization.events.addListener(chart, 'onmouseout', function (gglEvent) {
tooltip.className = 'hidden';
tooltip.innerHTML = '';
});
chart.draw(data, options);
}
.tooltip {
border: 1px solid #e0e0e0;
height: 320px;
padding: 12px 12px 12px 12px;
width: 320px;
}
.hidden {
display: none;
visibility: collapse;
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
<div class="hidden" id="chart_div_tooltip"></div>
【この例](https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#placing-charts-in-tooltips)は、チャートを配置する方法を示してツールチップで - またはあなたは[''onmouseover''イベント](https://developers.google.com/chart/interactive/docs/gallery/piechart#events)を聞いて自分の_modal_を表示することができます - > 'tooltip:{trigger: 'none'}' – WhiteHat