我想知道如何更改传递到图表的数据数组和基于 java 脚本下拉的标题。
我想要一个在 ConsultingSales 和 Lifesciences 之间切换的下拉菜单,并且还需要更改标题。一直在胡思乱想,无法弄清楚。请帮忙。
谢谢
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
var LifeSciencesSales = [ ['Month', 'Sales', 'Expenses'],
['Jan-12',1500,464.0070717],
['Feb-12',800,578.2656461],
['Mar-12',900,220.8059709],
['Apr-12',1000,534.1582816],
['May-12',505,768.0671543],
['Jun-12',958,181.6553778],
['Jul-12',2000,436.6480464],
['Aug-12',1300,108.9466581],
['Sept-12',1500,930.5872168],
['Oct-12',800,902.2438355],
['Dec-12',958,621.7321969]
]
var ConsultingSales = [ ['Month', 'Sales', 'Expenses'],
['Jan-12',455,44.0070717],
['Feb-12',800,578.2656461],
['Mar-12',545,220.8059709],
['Apr-12',1000,534.1582816],
['May-12',505,768.0671543],
['Jun-12',876,181.6553778],
['Jul-12',875,436.6480464],
['Aug-12',1300,108.9466581],
['Sept-12',1000,930.5872168],
['Oct-12',1345,902.2438355],
['Dec-12',895,621.7321969]
]
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
google.setOnLoadCallback(drawChart1);
function drawChart() {
var data = google.visualization.arrayToDataTable(LifeSciencesSales);
var options = {
title: "Sales"
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<div id="chart_div" style="width: 1200px; height: 400px;"></div>
<div id="chart_div1" style="width: 1200px; height: 400px;"></div>
</body>
</html>