Hi,
I'm trying to export a chart and got:
Uncaught TypeError: Cannot read property 'capture' of undefined
I have a project bootstrapped with Create React App.
Here's what I have in package.json:
"react": "^16.4.1", "react-dom": "^16.4.1", "@amcharts/amcharts3-react": "^3.0.0", "amcharts3": "^3.21.13",
Here's how I perform export:
`import 'amcharts3'
import AmCharts from '@amcharts/amcharts3-react'
let chart = React.createElement(AmCharts.React, {
style: {
width: "100%",
height: "500px"
},
options: {
"type": "pie",
"theme": "light",
"dataProvider": [{
"country": "Lithuania",
"litres": 501.9
}, {
"country": "Czech Republic",
"litres": 301.9
}],
"valueField": "litres",
"titleField": "country",
"export": {
"enabled": true,
"menu": []
}
}
})
chart["export"].capture({}, function() {
this.toPNG({}, function(base64) {
console.log(base64)
})
})
`
I didn't add any amcharts-related scripts to index.html. I've tried but it didn't help.
Here's the codepen with plain js where export is working: https://codepen.io/team/amcharts/pen/e487525e17e43a9d2de41d71f525b721
But I can't adopt it to my react app.
Hi,
I'm trying to export a chart and got:
Uncaught TypeError: Cannot read property 'capture' of undefinedI have a project bootstrapped with Create React App.
Here's what I have in
package.json:"react": "^16.4.1", "react-dom": "^16.4.1", "@amcharts/amcharts3-react": "^3.0.0", "amcharts3": "^3.21.13",Here's how I perform export:
`import 'amcharts3'
import AmCharts from '@amcharts/amcharts3-react'
let chart = React.createElement(AmCharts.React, {
style: {
width: "100%",
height: "500px"
},
options: {
"type": "pie",
"theme": "light",
"dataProvider": [{
"country": "Lithuania",
"litres": 501.9
}, {
"country": "Czech Republic",
"litres": 301.9
}],
"valueField": "litres",
"titleField": "country",
"export": {
"enabled": true,
"menu": []
}
}
})
chart["export"].capture({}, function() {
this.toPNG({}, function(base64) {
console.log(base64)
})
})
`
I didn't add any amcharts-related scripts to index.html. I've tried but it didn't help.
Here's the codepen with plain js where export is working: https://codepen.io/team/amcharts/pen/e487525e17e43a9d2de41d71f525b721
But I can't adopt it to my react app.