1.0.132 • Published 3 years ago

qf-taro-echarts v1.0.132

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Qf-Taro-Echarts

适用于Taro项目的ECharts图表组件,基于项目echarts-for-weixin封装

安装

npm i -S qf-taro-echarts

配置

修改Taro项目的配置config/index

  1. copy
copy: {
  patterns: [
    // 需添加如下配置
    {
      from: 'node_modules/qf-taro-echarts/components/ec-canvas/',
      to: 'dist/npm/qf-taro-echarts/components/ec-canvas'
    }
  ],
  options: {
    ignore: ['*.js']
  }
}
  1. h5.esnextModules
h5: {
  // 需添加如下配置
  esnextModules: ['qf-taro-echarts'],
  ...
}

使用

引入

import Echarts from 'qf-taro-echarts'

示例代码:以折线图为例

<Echarts
  option={{
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
      type: 'value'
    },
    series: [{
      data: [820, 932, 901, 934, 1290, 1330, 1320],
      type: 'line'
    }]
  }}
/>

API

属性名说明类型默认值
width图表的宽string100%
height图表的高string200px
optionECharts的option配置object-
onBeforeSetOption在echarts首次调用setOption前执行该方法,该方法会返回echarts的引用,可以在该方法中注册地图注册主题(echarts)=>void-
customStyle自定义容器样式string-
loading是否显示loading效果boolfalse
loadingConfloading效果的样式配置object-

支持度

h5微信小程序ReactNative支付宝小程序百度小程序字节跳动小程序
××

微信小程序获取图片示例代码

import Taro, { Component } from '@tarojs/taro'
import { View, Button } from '@tarojs/components'
import Echarts from 'qf-taro-echarts'

export default class Page extends Component {

  setChartRef = node => this.chartRef = node

  preview = async () => {
    // 获取到临时图片地址
    const path = await this.chartRef.getImagePath()
    Taro.previewImage({ current: path, urls: [path] })
  }

  render() {
    return (
      <View>
        <Button onClick={this.preview}>查看生成图片</Button>
        <Echarts
          ref={this.setChartRef}
          loadingConf={{ textColor: 123 }}
          option={{
            xAxis: {
              type: 'category',
              data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
              type: 'value'
            },
            series: [{
              data: [820, 932, 901, 934, 1290, 1330, 1320],
              type: 'line'
            }]
          }}
        />
      </View>
    )
  }
}

License

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.69

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.132

3 years ago

1.0.131

3 years ago

1.0.130

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.70

3 years ago

1.0.77

3 years ago

1.0.76

3 years ago

1.0.75

3 years ago

1.0.74

3 years ago

1.0.78

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.40

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.49

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.101

3 years ago

1.0.100

3 years ago

1.0.107

3 years ago

1.0.106

3 years ago

1.0.109

3 years ago

1.0.108

3 years ago

1.0.103

3 years ago

1.0.102

3 years ago

1.0.105

3 years ago

1.0.104

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.121

3 years ago

1.0.120

3 years ago

1.0.123

3 years ago

1.0.122

3 years ago

1.0.129

3 years ago

1.0.128

3 years ago

1.0.125

3 years ago

1.0.124

3 years ago

1.0.127

3 years ago

1.0.126

3 years ago

1.0.80

3 years ago

1.0.84

3 years ago

1.0.83

3 years ago

1.0.82

3 years ago

1.0.81

3 years ago

1.0.88

3 years ago

1.0.87

3 years ago

1.0.86

3 years ago

1.0.85

3 years ago

1.0.89

3 years ago

1.0.110

3 years ago

1.0.112

3 years ago

1.0.111

3 years ago

1.0.118

3 years ago

1.0.117

3 years ago

1.0.119

3 years ago

1.0.114

3 years ago

1.0.113

3 years ago

1.0.116

3 years ago

1.0.115

3 years ago

1.0.91

3 years ago

1.0.90

3 years ago

1.0.95

3 years ago

1.0.94

3 years ago

1.0.93

3 years ago

1.0.92

3 years ago

1.0.99

3 years ago

1.0.98

3 years ago

1.0.97

3 years ago

1.0.96

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.19

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago