谷歌图表如何从我的谷歌表格中获得2个图表

时间:2015-03-06 10:58:18

标签: charts

我有一张纸: https://docs.google.com/spreadsheets/d/1TXQ-PAfRS5vnRlaO34fYVp4LhyMBHp7MTr2emcSawhk/pubhtml

我需要在我的网页上创建2个图表吗?解决办法是什么 ?可能吗 ? 图1组合图表范围A1:C5
b2到b5:列 c2到c5:行

图2组合图表范围A11:C16 b13至b16:列 c13至c16:行

我的代码:

<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(initialize);

        function initialize() {
            // removed the `var opts...` line
            var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1TXQ-PAfRS5vnRlaO34fYVp4LhyMBHp7MTr2emcSawhk/edit#gid=1941533272');

            query.send(handleQueryResponse);
        }

        function handleQueryResponse(response) {
            if (response.isError()) {
                alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
                return;
            }

            var data = response.getDataTable();
            var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
            //var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
            chart.draw(data, {width: 400, height: 240, is3D: true});
        }
    </script>
</head>
<body>
    <div id="chart_div"></div>
</body>

非常感谢你的帮助

0 个答案:

没有答案