我正在编写一个程序,该程序通过 Google API 获取生成的数据集并在 PHP 中显示它。这非常好并且已经实现,但是我希望将缩略图添加到显示同一数据集的不同图表的代码中(以缩略图形式)。
我正在使用 Google API 生成数据并显示它,但我不确定如何让它更改可视化类型(当前使用 Pie 作为主图表),以便用户能够查看不同的可视化该数据集。
这是有问题的代码:
加载 AJAX API
<script type="text/javascript" src='https://www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1","packages":["corechart","table"]}]}'></script>
数据:
var data = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Number of Crimes');
data.addRows([
['Cardiff', 300],
['London', 900],
['Manchester', 500],
['Dublin', 400],
['Liverpool', 600]
]);
绘制图形:
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
以下是缩略图:
<div id="left">
<p>Bar chart</p>
<a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
<p>Another chart</p>
<a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
<p>Another chart</p>
<a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
</div>
<div id="right">
<p>Scatter Chart</p>
<a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
<p>Another chart</p>
<a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
<p>Another chart</p>
<a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
</div>
所以基本上,我如何将 google.visualization.BarChart (和其他)放入缩略图的 img src 中?
这甚至可能吗?
谢谢