1.2.2 • Published 1 year ago

taro-react-echarts v1.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

taro-react-echarts

基于Taro3、React的H5和微信小程序多端图表组件

  • 兼容H5、微信小程序

  • 开箱即用,快速开发图表,满足在移动端各种可视化需求

  • 支持自定义构建echarts

npm.io

安装

npm install taro-react-echarts

导入组件

import Echarts from 'taro-react-echarts'

参数说明

Echarts

参数描述类型必传默认值
本身参数参考Canvas 【微信小程序】
echartsecharts对象,可自定义构建echarts
option参考setOptionobject
classNameecharts类名stringkey
styleecharts样式对象object{height: '300px'}
classNameecharts类名string
themeecharts 的主题string
notMerge默认为true,不跟之前设置的option合并,保证每次渲染都是最新的optionbooleantrue
lazyUpdatesetOption 时,延迟更新数据booleanfalse
showLoading图表渲染时,是否显示加载状态boolean
loadingOption参考loading配置项object
opts参考echarts. initstring
onEvents绑定 echarts 事件object
isPage表示是否是顶层页面级别 【1、注意嵌套在Popup 、Dialog 、Picker等弹出层都不是页面级别,需要设置为false,否则可能会不显示 2、以及嵌套在Tabs标签页中如果出现显示不正常,可设置isPage为false, 因为都有可能不触发useReady】booleantrue

Events

事件名描述类型必传默认值
onChartReady当图表准备好时,将使用 echarts 对象作为参数回调函数Function

使用

import { useRef } from 'react'
import Echarts, { EChartOption, EchartsHandle } from 'taro-react-echarts'
import echarts from '@/assets/js/echarts.js'

export default function Demo() {
 const echartsRef = useRef<EchartsHandle>(null)
 const option: EChartOption = {
    legend: {
      top: 50,
      left: 'center',
      z: 100
    },
    tooltip: {
      trigger: 'axis',
      show: true,
      confine: true
    },
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: [150, 230, 224, 218, 135, 147, 260],
        type: 'line'
      }
    ]
  }

  return (
      <Echarts
        echarts={echarts}
        option={option}
        ref={echartsRef}
      ></Echarts>
  );
}

友情推荐

项目描述
taro-react-table基于 taro3、react 的 H5 和微信小程序多端表格组件
1.2.2

1 year ago

1.2.0

1 year ago

1.2.1

1 year ago

1.1.1

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago