我正在尝试创建一个基本组件,从道具中获取数据并使用React Highcharts呈现图表。代码如下所示:
import React from 'react';
import Highcharts from 'highcharts';
import ReactHighcharts from 'react-highcharts';
export default class Graph extends React.Component {
render() {
var config = {
xAxis: {
categories: this.props.data.map((tuple) => {
return tuple[0];
})
},
series: [{
data: this.props.data.map((tuple) => {
return tuple[1];
})
}]
}
return (
<div className="graph-container">
<ReactHighcharts config={ config } >
</ReactHighcharts>
</div>
)
}
}
打开应用程序时,我得到了未被捕获的TypeError。以下是几行描述。
Uncaught TypeError: a.setAttribute is not a function
P @ highcharts.js?:formatted:65
gb.getContainer @ highcharts.js?:formatted:5525
gb.firstRender @ highcharts.js?:formatted:5863
gb.init @ highcharts.js?:formatted:5313
gb.getArgs @
查看highcharts中的错误,看起来当一个方法在期望DOM节点时传递一个React组件。