在react中引用echarts

如何在react中引用echarts?请往下看:

首先在项目终端去安装

npm install echarts --save


然后在import里面输入
import echarts from 'echarts/lib/echarts';
import 'echarts/lib/chart/bar';
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/title';

进行引用

之后写入项目中,可以去echarts官方文档里去复制粘贴
 

var myChart = echarts.init(document.getElementById('main')); var option =({ title: { text: 'ECharts 入门示例' }, tooltip: {}, legend: { data:['销量'] }, xAxis: { data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"] }, yAxis: {}, series: [{ name: '销量', type: 'bar', data: [5, 20, 36, 10, 10, 20] }] }); }; myChart.setOption(option);

你可能感兴趣的:(react.js,echarts,javascript)