首页 技术 正文
技术 2022年11月10日
0 收藏 861 点赞 2,754 浏览 1461 个字

一个webview封装的图表组件。基于百度echarts4,相比native-echarts有echarts自带对象支持,例如渐变色等,用法与官网相同用法。

echarts version 4.2.0-rc.2

注:react-native 0.56 版本以上,webview改版, https://reactnative.cn/docs/webview/ 本组件分为0.56以上(包含), 0.56以下, 请阅读以下安装步骤。

安装步骤

  1. 安装依赖
  • react-native >= 0.56

  • yarn add react-native-secharts

或者

npm install react-native-secharts –save

react-native < 0.56

yarn add react-native-secharts@1.4.5或者npm install react-native-secharts@1.4.5 –save

  1. 修复android release bug
  • 在你的项目创建此路径的文件夹 $yourProject/android/app/src/main/assets/echarts
  • 创建完成后请在你的项目根目录(`$yourProject/) 文件夹下使用命令
  • 以下是 mac && linux
  • cp node_modules/react-native-secharts/main/dist/index.html android/app/src/main/assets/echarts/ && cp node_modules/react-native-secharts/main/dist/Bmap.html android/app/src/main/assets/echarts/

  • 以下是 windows
  • copy node_modules/react-native-secharts/main/dist/index.html android/app/src/main/assets/echarts/ && copy node_modules/react-native-secharts/main/dist/Bmap.html android/app/src/main/assets/echarts/

  1. 引用组件

import {Echarts, echarts} from ‘react-native-secharts’;

  • 大写开头的Echarts是组件
  • 小写开头的echarts是echarts对像
  1. 使用组件

<Echarts option={{}} height={400}/>

请看example文件夹中示例代码

链接:https://github.com/shifeng1993/react-native-secharts/tree/master/example

运行示例

$ cd example
$ yarn
$ react-native run-ios 或者 $ react-native run-android

option具体配置请参考echarts官网api http://echarts.baidu.com/api.html

官方示例 http://echarts.baidu.com/examples/

RN集成echarts4图表组件react-native-secharts(转载)

RN集成echarts4图表组件react-native-secharts(转载)

setOption (option: Object, notMerge?: boolean, lazyUpdate?: boolean) 参数参考:http://echarts.baidu.com/api.html

转载自 https://blog.csdn.net/sf542674656/article/details/80109884

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,565
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905