Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoChart Error: Must draw chart before calling getImageURI #22

Open
51yu opened this issue Jan 15, 2024 · 1 comment
Open

GeoChart Error: Must draw chart before calling getImageURI #22

51yu opened this issue Jan 15, 2024 · 1 comment

Comments

@51yu
Copy link

51yu commented Jan 15, 2024

Reproduce

(async () => {
  const drawChart = `
  var container = document.getElementById('chart_div');const data = google.visualization.arrayToDataTable([['Country', 'Popularity'],['Germany', 200],['United States', 300],['Brazil', 400],['Canada', 500],['France', 600],['RU', 700]
]);var options={};var chart = new google.visualization.GeoChart(container);chart.draw(data, options);
  `;
  const image = await GoogleChartsNode.render(drawChart, {
    width: 400,
    height: 300,
    package: 'geochart'
  });

  fs.writeFileSync('/tmp/google-chart.png', image);
})();
@lastcoolnameleft
Copy link

@typpo Any thoughts on this? I'm experiencing the same issue

Python example, inspired by: https://developers.google.com/chart/interactive/docs/gallery/geochart

import requests
code = '''
var container = document.getElementById('geochart');
var chart = new google.visualization.GeoChart(container);
        var data = google.visualization.arrayToDataTable([
          ['Country', 'Popularity'],
          ['Germany', 200],
          ['United States', 300],
          ['Brazil', 400],
          ['Canada', 500],
          ['France', 600],
          ['RU', 700]
        ]);
var options = {}
chart.draw(data, options);
'''
resp = requests.post('https://quickchart.io/google-charts/render', json={
    'width': 600,
    'height': 300,
    'packages': 'geochart', # optional
    'code': code,
    'mapsApiKey': '<MY GMAPS API KEY; however, it gives the same error regardless>',

})

with open('chart.png', 'wb') as f:
    f.write(resp.content)

Execution

$ python quickchart.py
$ cat chart.png                         
Error: Evaluation failed: Error: Must draw chart before calling getImageURI.
    at gvjs_E_.gvjs_.ah (https://www.gstatic.com/charts/51/js/jsapi_compiled_geochart_module.js:81:133)
    at __puppeteer_evaluation_script__:5:25%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants