taro 项目中接入EChart图表库

本文介绍了如何在Taro项目中接入ECharts图表库,通过使用物料市场提供的封装组件以及自定义封装折线图组件的方式,展示了在小程序中使用ECharts的步骤,并给出了实际效果图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、使用物料市场提供的封装好的组件

https://taro-ext.jd.com/plugin/view/5f648e4c0dd8313026e0942d

npm i echarts-taro3-react   or yarn add echarts-taro3-react

2、使用、封装折线图组件:

lineChart.js

import React, { Component } from 'react'
import { View } from '@tarojs/components'
import { EChart } from 'echarts-taro3-react'
import PropTypes from 'prop-types'
import './index.less'

/**
|--------------------------------------------------
| #Component
| 折线图组件
|--------------------------------------------------
*/

class Line extends Component {
  static defaultProps = {
    xData: [],
    yData: [],
  }

  componentDidMount() {
    setTimeout(() => {
      this.refresh()
    }, 10)

    // this.props.onRef(this)
  }

  refresh() {
    const { xData, yData } = this.props
    // 更多关于option的参数配置参考Echart
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值