1.安装typings及echarts

npm install typings echarts --global

2.安装 ECharts 的 TypeScript 定义文件

npm install @types/echarts --save

3.在使用echarts的页面ts文件中引用echarts

import * as echarts from 'echarts'; 

4.在html页面添加div

<ion-content> 
    <div ></div> 
</ion-content> 

5.在scss中配置样式

page-home { 
    #chart { 
        position: absolute;
        width: 100%; 
        height: 100%; 
    }
} 

6.在ts文件中初始化

ionViewDidEnter() {
    const ec = echarts as any;
    const container = document.getElementById('chart');
    const chart = ec.init(container);
    chart.setOption({
      series: {
        type: 'pie',
        data: [{
          name: 'A', value: 10
        }, {
          name: 'B', value: 20
        }, {
          name: 'C', value: 30
        }]
      }
    });
  }

 

相关文章:

  • 2021-09-30
  • 2021-12-26
  • 2021-10-13
  • 2022-12-23
猜你喜欢
  • 2021-03-30
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案