I’m trying to integrate google-charts
with Stimulus.
I used, as a starting point, https://www.npmjs.com/package/google-charts#quick-start and I have looked at https://glitch.com/edit/#!/stimulus-highcharts?path=src/controllers/chart_controller.js
My controller looks like
import { Controller } from "stimulus"
import { GoogleCharts } from 'google-charts'
export default class extends Controller {
connect() {
GoogleCharts.load(this.drawChart())
}
drawChart() {
const data = GoogleCharts.api.visualization.arrayToDataTable([
['Chart thing', 'Chart amount'],
['Lorem ipsum', 60],
['Dolor sit', 22],
['Sit amet', 18]
])
const pie_1_chart = new GoogleCharts.api.visualization.PieChart(document.getElementById('chart_div'))
pie_1_chart.draw(data)
}
}
But I get TypeError: "__WEBPACK_IMPORTED_MODULE_1_google_charts__.a.api is undefined"
Am I missing anything here?
Thanks.