美文网首页
Ant Design Pro系列快速入门(八)-- 使用echa

Ant Design Pro系列快速入门(八)-- 使用echa

作者: 子木话 | 来源:发表于2019-10-29 23:13 被阅读0次
  1. 安装echarts和react的echarts模块
npm install --save echarts
  1. 导入echarts
// 引入 ECharts 主模块
 import echarts from 'echarts/lib/echarts';
 // 引入柱状图
 import 'echarts/lib/chart/bar';
 // 引入提示框和标题组件
 import 'echarts/lib/component/tooltip';
 import 'echarts/lib/component/title';
 // 使用样式
 import 'echarts/theme/macarons'
  1. 声明一个echarts节点
getEchartsOfFollowUp() {
     return (<div id="charts" className={styles.followUpCharts}></div>);
 }
  1. 组件完成装载后初始化图表
componentDidMount() {
 // 基于准备好的dom,初始化echarts实例
 var myChart = echarts.init(document.getElementById('charts'), "macarons");
 // 绘制图表
     myChart.setOption({
     title: { text: 'ECharts 入门示例' },
     tooltip: {},
     xAxis: {
         data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
     },
     yAxis: {},
     series: [{
         name: '销量',
         type: 'bar',
         data: [5, 20, 36, 10, 10, 20]
     }]
     });
 }
  1. 使用
content={this.getEchartsOfFollowUp()}

相关文章

网友评论

      本文标题:Ant Design Pro系列快速入门(八)-- 使用echa

      本文链接:https://www.haomeiwen.com/subject/nlsnvctx.html