可以在同一页面上插入两个图表吗?我从数据库中提取数据,然后在页面上绘制图表。这是我用于绘制图形的伪代码,我更改了 id 元素但我只显示了第一个图形,而第二个不起作用。
<? $res_app = mysql_query("SELECT ... ")
...
?>
<div id="graph"></div>
<pre id="code" class="prettyprint linenums">
Morris.Donut({
element: 'graph',
data: [
{value: 70, label: 'foo'},
{value: 15, label: 'bar'},
{value: 10, label: 'baz'},
{value: 5, label: 'A really really long label'}
],
formatter: function (x) { return x + "%"}
});
</pre>
<? $res_app = mysql_query("SELECT ... ")
...
?>
<div id="graph1"></div>
<pre id="code" class="prettyprint linenums">
Morris.Donut({
element: 'graph1',
data: [
{value: 50, label: 'foo', formatted: 'at least 50%' },
{value: 25, label: 'bar', formatted: 'approx. 25%' },
{value: 20, label: 'baz', formatted: 'approx. 20%' },
{value: 5, label: 'A really really long label', formatted: 'at most 5%' }
],
formatter: function (x, data) { return data.formatted; }
});
</pre>