Installations
npm install echarts-for-scooper
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
10.15.2
NPM Version
6.4.1
Score
53.6
Supply Chain
95.8
Quality
74.8
Maintenance
50
Vulnerability
99.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (92.58%)
JavaScript (7.42%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
592
Last Day
1
Last Week
3
Last Month
14
Last Year
94
GitHub Statistics
MIT License
4,621 Stars
22 Commits
638 Forks
64 Watchers
5 Branches
15 Contributors
Updated on Feb 14, 2025
Bundle Size
9.64 kB
Minified
2.88 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.0
Package Id
echarts-for-scooper@1.0.0
Unpacked Size
39.68 kB
Size
9.21 kB
File Count
12
NPM Version
6.4.1
Node Version
10.15.2
Total Downloads
Cumulative downloads
Total Downloads
592
Last Day
0%
1
Compared to previous day
Last Week
-50%
3
Compared to previous week
Last Month
100%
14
Compared to previous month
Last Year
-39.7%
94
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
3
Dev Dependencies
44
echarts-for-react
A very simple echarts(v3.0 & v4.0) wrapper for react.
1. install
1npm install --save echarts-for-react 2 3# `echarts` is the peerDependence of `echarts-for-react`, you can install echarts with your own version. 4npm install --save echarts
Then use it.
1import ReactEcharts from 'echarts-for-react'; 2 3// render echarts option. 4<ReactEcharts option={this.getOption()} />
You can run demo by:
1git clone git@github.com:hustcc/echarts-for-react.git 2 3npm install 4 5npm start
then open http://127.0.0.1:8080/ in your browser. or see http://git.hust.cc/echarts-for-react/
GL
Install and import echarts-gl
module when you want to create a GL instance
Install
1npm install --save echarts-gl
Import
1import 'echarts-gl' 2import ReactEcharts from "echarts-for-react"; 3 4<ReactEcharts 5 option={GL_OPTION} 6/> 7
2. usage
Code of a simple demo code showed below. For more example can see: http://git.hust.cc/echarts-for-react/
javascript
1import React from 'react'; 2import ReactEcharts from 'echarts-for-react'; // or var ReactEcharts = require('echarts-for-react'); 3 4<ReactEcharts 5 option={this.getOption()} 6 notMerge={true} 7 lazyUpdate={true} 8 theme={"theme_name"} 9 onChartReady={this.onChartReadyCallback} 10 onEvents={EventsDict} 11 opts={} />
typescript
1import * as React from "react"; 2import ReactEcharts from "echarts-for-react"; 3 4<ReactEcharts 5 option={this.getOption()} 6 notMerge={true} 7 lazyUpdate={true} 8 theme={"theme_name"} 9 onChartReady={this.onChartReadyCallback} 10 onEvents={EventsDict} 11 opts={} />
Import ECharts.js modules manually to reduce bundle size
1import React from 'react'; 2// import the core library. 3import ReactEchartsCore from 'echarts-for-react/lib/core'; 4 5// then import echarts modules those you have used manually. 6import echarts from 'echarts/lib/echarts'; 7// import 'echarts/lib/chart/line'; 8import 'echarts/lib/chart/bar'; 9// import 'echarts/lib/chart/pie'; 10// import 'echarts/lib/chart/scatter'; 11// import 'echarts/lib/chart/radar'; 12 13// import 'echarts/lib/chart/map'; 14// import 'echarts/lib/chart/treemap'; 15// import 'echarts/lib/chart/graph'; 16// import 'echarts/lib/chart/gauge'; 17// import 'echarts/lib/chart/funnel'; 18// import 'echarts/lib/chart/parallel'; 19// import 'echarts/lib/chart/sankey'; 20// import 'echarts/lib/chart/boxplot'; 21// import 'echarts/lib/chart/candlestick'; 22// import 'echarts/lib/chart/effectScatter'; 23// import 'echarts/lib/chart/lines'; 24// import 'echarts/lib/chart/heatmap'; 25 26// import 'echarts/lib/component/graphic'; 27// import 'echarts/lib/component/grid'; 28// import 'echarts/lib/component/legend'; 29import 'echarts/lib/component/tooltip'; 30// import 'echarts/lib/component/polar'; 31// import 'echarts/lib/component/geo'; 32// import 'echarts/lib/component/parallel'; 33// import 'echarts/lib/component/singleAxis'; 34// import 'echarts/lib/component/brush'; 35 36import 'echarts/lib/component/title'; 37 38// import 'echarts/lib/component/dataZoom'; 39// import 'echarts/lib/component/visualMap'; 40 41// import 'echarts/lib/component/markPoint'; 42// import 'echarts/lib/component/markLine'; 43// import 'echarts/lib/component/markArea'; 44 45// import 'echarts/lib/component/timeline'; 46// import 'echarts/lib/component/toolbox'; 47 48// import 'zrender/lib/vml/vml'; 49 50// The usage of ReactEchartsCore are same with above. 51<ReactEchartsCore 52 echarts={echarts} 53 option={this.getOption()} 54 notMerge={true} 55 lazyUpdate={true} 56 theme={"theme_name"} 57 onChartReady={this.onChartReadyCallback} 58 onEvents={EventsDict} 59 opts={} />
3. component props
option
(required, object)
the echarts option config, can see http://echarts.baidu.com/option.html#title.
notMerge
(optional, object)
when setOption
, not merge the data, default is false
. See http://echarts.baidu.com/api.html#echartsInstance.setOption.
lazyUpdate
(optional, object)
when setOption
, lazy update the data, default is false
. See http://echarts.baidu.com/api.html#echartsInstance.setOption.
style
(optional, object)
the style
of echarts div. object
, default is {height: '300px'}.
className
(optional, string)
the class
of echarts div. you can setting the css style of charts by class name.
theme
(optional, string)
the theme
of echarts. string
, should registerTheme
before use it (theme object format: https://github.com/ecomfe/echarts/blob/master/theme/dark.js). e.g.
1// import echarts 2import echarts from 'echarts'; 3... 4// register theme object 5echarts.registerTheme('my_theme', { 6 backgroundColor: '#f4cccc' 7}); 8... 9// render the echarts use option `theme` 10<ReactEcharts 11 option={this.getOption()} 12 style={{height: '300px', width: '100%'}} 13 className='echarts-for-echarts' 14 theme='my_theme' />
onChartReady
(optional, function)
when the chart is ready, will callback the function with the echarts object
as it's paramter.
loadingOption
(optional, object)
the echarts loading option config, can see http://echarts.baidu.com/api.html#echartsInstance.showLoading.
showLoading
(optional, bool, default: false)
bool
, when the chart is rendering, show the loading mask.
onEvents
(optional, array(string=>function) )
binding the echarts event, will callback with the echarts event object
, and the echart object
as it's paramters. e.g:
1let onEvents = { 2 'click': this.onChartClick, 3 'legendselectchanged': this.onChartLegendselectchanged 4} 5... 6<ReactEcharts 7 option={this.getOption()} 8 style={{height: '300px', width: '100%'}} 9 onEvents={onEvents} />
for more event key name, see: http://echarts.baidu.com/api.html#events
opts
(optional, object)
the opts
of echarts. object
, will be used when initial echarts instance by echarts.init
. Document here.
1<ReactEcharts 2 option={this.getOption()} 3 style={{height: '300px'}} 4 opts={{renderer: 'svg'}} // use svg to render the chart. 5/>
4. Component API & Echarts API
the Component only has one API
named getEchartsInstance
.
getEchartsInstance()
: get the echarts instance object, then you can use anyAPI of echarts
.
for example:
1// render the echarts component below with rel 2<ReactEcharts ref={(e) => { this.echarts_react = e; }} 3 option={this.getOption()} /> 4 5// then get the `ReactEcharts` use this.echarts_react 6 7let echarts_instance = this.echarts_react.getEchartsInstance(); 8// then you can use any API of echarts. 9let base64 = echarts_instance.getDataURL();
About API of echarts, can see http://echarts.baidu.com/api.html#echartsInstance.
You can use the API to do:
binding / unbinding
event.dynamic charts
with dynamic data.- get the echarts dom / dataURL / base64, save the chart to png.
release
the charts.
5. Q & A
- How to render the chart with svg when using echarts 4.x
Use the props opts
of component with renderer = 'svg'
. For example:
1<ReactEcharts 2 option={this.getOption()} 3 style={{height: '300px'}} 4 opts={{renderer: 'svg'}} // use svg to render the chart. 5/>
- How to resolve Error
Component series.scatter3D not exists. Load it first.
Install and import echarts-gl
first
6. LICENSE
MIT@hustcc.

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 13/22 approved changesets -- score normalized to 5
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/hustcc/echarts-for-react/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/hustcc/echarts-for-react/build.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/hustcc/echarts-for-react/build.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/build.yml:16
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 19 are checked with a SAST tool
Score
4.3
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More