1.安装
npm install highcharts --save
npm install highcharts-react-offical
也可以这样:
npm install highcharts highcharts-react-official
2.导入
import Highcharts from 'highcharts/highstock';
import HighchartsReact from 'highcharts-react-official';
3.调用
<HighchartsReact
highcharts={Highcharts}
options={getOption1()} // 注意这里是options
constructorType='stockChart' // 这里必须要写,否则不能使用stock chart!!
style={{ height: '500px' }} />
最主要的就是要加上:constructorType='stockChart', 否则无法使用stockchart!!
国内的百度搜了又搜,都没有搜出来答案,好伤心。
最后还是谷歌解决的
好好学下英语吧
补充:其实react为highcharts封装一个库,用起来也很方便,但是和我的项目冲突,但是就放弃了,so sad...
如果需要使用,安装即可:
npm install react-highcharts --save or
yarn add react-highcharts --save
导入的方法类似,找不到的话,就去依赖包里面找就好了~
主要就是用这个:ReactHighstock