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