我正在尝试使用 Data URI 方法获取图表 URI。我见过很多使用 Apexchart Js从 ApexChart获取 pdf 的示例,当尝试在 React 上重现它时,我得到了 TypeError: Cannot read property 'type' of undefined
这是我的组件安装看起来像这样:
componentDidMount() {
console.log(this.state.loading);
if (this.state.loading === false) {
const {options} = this.state;
const node = ReactDOM.findDOMNode(this);
if (node instanceof HTMLElement) {
var chart = new ApexCharts(node.querySelector('.charty'), options);
chart.render().then(() => {
setTimeout(function() {
chart.dataURI().then(uri => {
console.log(uri);
});
}, 4000);
});
}
} else {
return;
}
}
Run Code Online (Sandbox Code Playgroud)
类型也在我的状态和渲染中定义,如下所示:
<div className='rfe'>
<div className='rfea'>
From {this.state.AxisMonth[0]} to{' '}
{this.state.AxisMonth[this.state.AxisMonth.length - …Run Code Online (Sandbox Code Playgroud)