Open butters16 opened 7 years ago
Same problem since Ionic 2.
could you solve this problem?
Short answer: no, I could not solve the problem so I am not using angular2-google-chart.
Long answer: I'm turned off to using projects that wrap existing javascript functionality for angular consumption. There seems to be this constant cat-and-mouse game of waiting for support after each release and then having to debug the inconsistencies myself. Even if everything works, libraries like Google Charts already have tons of great documentation with examples, but I can't use any of it until I figure out how to translate it for the wrapper library. I see some value in the wrappers, but if they don't work right away or impose too much deviation from the original library, I just fallback to using the straight javascript as I did in this case. I've included the snippets below for how to do that.
index.html
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
</script>
some-component.html
<div id="some-unique-id"></div>
some-component.ts
declare var google;
let chart = new google.visualization.ComboChart(document.getElementById('some-unique-id'));
chart.draw(data, options);
Admittedly, this could use some error handling for if Google Charts does not load in time (or ever).
I am able to get it working with a new Angular4 application, but cannot get it to work with a new Ionic3 applications (using Angular4). I've created a repo to demonstrate: https://github.com/butters16/google-chart-using-ionic3
Steps to reproduce
Error looks like this