npm i install worker-echarts --save-dev or yarn add worker-echarts --save-devYou can use Echarts(4.3.2) API
import WorkerEcharts from "worker-echarts"
let workerEchart = new WorkerEcharts()
workerEchart.init(dom)
workerEchart.setOptions(options)- WorkerECharts
- new WorkerECharts()
- workerECharts.registerTheme(name, theme) ⇒
- workerECharts.resizeAxisUnit(point) ⇒
- workerECharts.on(type, listener, isMust) ⇒
Object - workerECharts.off(indicator) ⇒
- workerECharts.init(div, theme)
- workerECharts.callMethod(methodName, ...args) ⇒
- workerECharts.setOption(option, ...args) ⇒
- workerECharts.getOption() ⇒
- workerECharts.getAxisGrid() ⇒
- workerECharts.getEchartXInterval() ⇒
- workerECharts.getEchartYInterval() ⇒
- workerECharts.enlargeZoom() ⇒
- workerECharts.restoreZoom() ⇒
- workerECharts.chartDataZoom() ⇒
- workerECharts.dispatchAction(payload) ⇒
- workerECharts.resize(opts) ⇒
- workerECharts.clean() ⇒
- workerECharts.dispose()
- workerECharts.postMessage(message) ⇒
WorkerEcharts Class
注册主题
Returns: Promise对象
| Param | Type | Description |
|---|---|---|
| name | string |
light or dark |
| theme | Object |
options |
重置x轴单位
Returns: Promise对象
| Param | Type |
|---|---|
| point | number |
绑定事件
Returns: Object - - {type,lisenter}对象
| Param | Type | Description |
|---|---|---|
| type | String |
监听echart类型 |
| listener | function |
监听事件回调 |
| isMust | Boolean |
是否重置 |
解绑事件
Returns: null
| Param | Type | Description |
|---|---|---|
| indicator | Object |
- { type:String,listener:function} |
初始化
| Param | Type | Description |
|---|---|---|
| div | dom | canvas |
dom对象或者canvas对象 |
| theme | string |
echart 主题 |
调用echart方法
Returns: Promise对象
| Param | Type | Description |
|---|---|---|
| methodName | string |
echart方法名 resize、dispatchAction |
| ...args | object |
配置参数options |
调用echart的setOption
Returns: Promise对象
| Param | Type | Description |
|---|---|---|
| option | Object |
echart 配置参数options |
| ...args | Object |
其他配置 { notMerge?: boolean;replaceMerge?: string |
获取当前echart的options
获取当前坐标数据开始点起始点
Returns: Promise对象
获取当前横坐标数据
获取当前纵坐标数据
启动或关闭 toolbox 中 dataZoom 的刷选状态。
重置坐标轴
重置坐标轴 params {Object}- {type: String,dataZoomIndex: Number, start: Number,end: Number,startValue: Number,endValue: Number}
调用echart 的dispatchAction
Returns: promise对象
| Param | Type | Description |
|---|---|---|
| payload | Object |
配置参数 |
调用echart的resize方法
Returns: Promise对象
| Param | Type | Description |
|---|---|---|
| opts | Object |
配置参数 |
清除echart
清除worker
将消息发送到工作线程;返回的承诺在onmessage消息返回时被解析
Returns: Promise对象
| Param | Type | Description |
|---|---|---|
| message | Object |
message对象 {type:String,args: Array} |