简体   繁体   中英

two google charts on one page with super proxy

How can I have two google charts on one page? I'm using super proxy to get JSON table from google analytics API.

Currently, only the first chart (Table) is shown. Missing the second chart.

My code is attached below. I'm not so familiar with the API things. I checked some solutions, but all have data locally instead of from online sources, eg, spreadsheet, JSON table.

Any help would be appreciated.

<html>
<head>
    <!--Load the AJAX API-->
    <script type="text/javascript"
    src='https://www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1"}]}'>
    </script>

    <script type="text/javascript">
        google.load('visualization', '1', {packages: ['table','geochart']});
        google.setOnLoadCallback(drawVisualization);

        function drawCountriesTable() {
            var CountriesTableWrapper = new google.visualization.ChartWrapper({
            "containerId": "CountriesTable_div",
            "dataSourceUrl": "https://top3dapp.appspot.com/query?id=agpzfnRvcDNkYXBwchULEghBcGlRdWVyeRiAgICAgICACgw&format=data-table-response",
            "refreshInterval": 43200,
            "chartType": "Table",
            "options": {
                "showRowNumber" : true
                }
            });

            CountriesTableWrapper.draw();
        }

        function drawRegionsMap() {
            var RegionsMapWrapper = new google.visualization.ChartWrapper({
            "containerId": "RegionsMap_div",
            "dataSourceUrl": "https://top3dapp.appspot.com/query?id=agpzfnRvcDNkYXBwchULEghBcGlRdWVyeRiAgICAvKGCCgw&format=data-table-response",
            "refreshInterval": 43200,
            "chartType": "GeoChart",
            "options": {
                "displayMode": 'markers',
                "colorAxis": { "colors": ['#A9DEF2', '#048DC7'] }
                }
            });

            RegionsMapWrapper.draw();
        }

        function drawVisualization() {
            drawCountriesTable();
            drawRegionsMap();
        }
    </script>
</head>
<body>
    <h2>Countries</h2>
    <div id="CountriesTable_div" style="margin:auto;width:630px;"></div>
    <h2>Regions</h2>
    <div id="RegionsMap_div" style="margin:auto;width:630px;"></div>
</body>

The is a bug of super proxy. Bug report see: https://github.com/googleanalytics/google-analytics-super-proxy/issues/17

Following the steps as suggested on github:

  1. Open query_helper.py
  2. Go to the method 'GetPublicEndpointResponse'
  3. In line 395, you should see

    transformed_response_content = response.get('transformed_content')

Change that line to:

transformed_response_content = transform.Transform(response_content)
  1. Test/Deploy updates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM