Echarts 常用API之action行为

一、Echarts中的action

echarts中支持的图表行为,通过dispatchAction触发。

1.highlight 高亮指定的数据图形

dispatchAction({
    type: 'highlight',
    // 可选,系列 index,可以是一个数组指定多个系列
    seriesIndex?: number|Array,
    // 可选,系列名称,可以是一个数组指定多个系列
    seriesName?: string|Array,
    // 可选,数据的 index
    dataIndex?: number,
    // 可选,数据的 名称
    name?: string
})

2.downplay 取消高亮指定的数据图形

dispatchAction({
    type: 'downplay',
    // 可选,系列 index,可以是一个数组指定多个系列
    seriesIndex?: number|Array,
    // 可选,系列名称,可以是一个数组指定多个系列
    seriesName?: string|Array,
    // 可选,数据的 index
    dataIndex?: number,
    // 可选,数据的 名称
    name?: string
})

3.图例相关的行为,必须引入图例组件之后才能使用

1)legendSelect(选中图例)

dispatchAction({
    type: 'legendSelect',
    // 图例名称
    name: string
})

2)legendUnSelect(取消选中图例)

dispatchAction({
    type: 'legendUnSelect',
    // 图例名称
    name: string
})

3)legendToggleSelect(切换图例的选中状态)

dispatchAction({
    type: 'legendToggleSelect',
    // 图例名称
    name: string
})

4)legendScroll(控制图例的滚动),当legend.type是scroll的时候有效

dispatchAction({
    type: 'legendScroll',
    scrollDataIndex: number,
    legendId: string
})

4. 提示框组件相关行为,必须引入提示框组件之后才能引用

1)showTip(显示提示框)
有两种使用方式
A:指定在相对容器的位置处显示提示框,如果指定的位置无法显示则无效。

dispatchAction({
    type:'showTip',
    //屏幕上的x坐标
    x: number,
    //屏幕上的y坐标
    y: number,
    //本次显示tooltip的位置,只在本次action生效。缺省则使用option中定义的tooltip位置
    position: Array.<number> | String | Function
})

B: 指定数据图形,根据tooltip的配置项进行显示提示框

dispatch({
    type: 'showTip',
    // 系列的 index,在 tooltip 的 trigger 为 axis 的时候可选。
    seriesIndex?: number,
    // 数据的 index,如果不指定也可以通过 name 属性根据名称指定数据
    dataIndex?: number,
    // 可选,数据名称,在有 dataIndex 的时候忽略
    name?: string,
    // 本次显示 tooltip 的位置。只在本次 action 中生效。
    // 缺省则使用 option 中定义的 tooltip 位置。
    position: Array.<number>|string|Function,
})

2)hideTip 隐藏提示框

dispatchAction({
    type:'hideTip'
})

5.数据区域缩放组件、视觉映射组件、时间轴组件、工具栏组件相关行为

  1. 数据区域缩放组件,必须引入数据区域缩放组件之后才能使用(dataZoom)
dispatchAction({
    type: 'dataZoom',
    // 可选,dataZoom 组件的 index,多个 dataZoom 组件时有用,默认为 0
    dataZoomIndex: number,
    // 开始位置的百分比,0 - 100
    start: number,
    // 结束位置的百分比,0 - 100
    end: number,
    // 开始位置的数值
    startValue: number,
    // 结束位置的数值
    endValue: number
})

2.关闭或启动toolbox中的dataZoom的刷选状态(takeGlobalCursor)

myChart.dispatchAction({
    type: 'takeGlobalCursor',
    key: 'dataZoomSelect',
    // 启动或关闭
    dataZoomSelectActive: true
});

3.视觉映射组件,只能在引入视觉映射组件之后才能使用(visualMap)
选取映射的数值范围:selectDataRange

dispatchAction({
    type: 'selectDataRange',
    // 可选,visualMap 组件的 index,多个 visualMap 组件时有用,默认为 0
    visualMapIndex: number,
    // 连续型 visualMap 和 离散型 visualMap 不一样
    // 连续型的是一个表示数值范围的数组。
    // 离散型的是一个对象,键值是类目或者分段的索引。值是 `true`, `false`
    selected: Object|Array
})

4.时间轴组件,同理引入之后才能使用
1)设置当前的时间点:timelineChange

dispatchAction({
    type: 'timelineChange',
    // 时间点的 index
    currentIndex: number
})

2)切换时间轴的播放状态:timelinePlayChange

dispatchAction({
    type: 'timelinePlayChange',
    // 播放状态,true 为自动播放
    playState: boolean
})

5.工具栏组件相关行为,同理引入之后才能使用
重置option:restore

dispatchAction({
    type: 'restore'
})

6.饼图、地图组件、地图图表、关系图、区域选择相关行为
1)饼图

  • 选中指定的饼图扇形(pieSelect)
  • 取消选中指定的饼图扇形(pieUnSelect)
  • 切换指定的选中的饼图扇形状态(pieToggleSelect)
dispatchAction({
    type: 'pieSelect | pieUnSelect | pieToggleSelect',
    // 可选,系列 index,可以是一个数组指定多个系列
    seriesIndex?: number|Array,
    // 可选,系列名称,可以是一个数组指定多个系列
    seriesName?: string|Array,
    // 数据的 index,如果不指定也可以通过 name 属性根据名称指定数据
    dataIndex?: number,
    // 可选,数据名称,在有 dataIndex 的时候忽略
    name?: string
})

2)地图组件

  • 选中指定的地图区域(geoSelect)
  • 取消选中的指定地图区域(geoUnSelect)
  • 切换指定的地图区域的选中状态(geoToggleSelect)
dispatchAction({
    type: 'geoSelect | geoUnSelect | geoToggleSelect',
    // 可选,系列 index,可以是一个数组指定多个系列
    seriesIndex?: number|Array,
    // 可选,系列名称,可以是一个数组指定多个系列
    seriesName?: string|Array,
    // 数据的 index,如果不指定也可以通过 name 属性根据名称指定数据
    dataIndex?: number,
    // 可选,数据名称,在有 dataIndex 的时候忽略
    name?: string
})

3)地图图表组件
同地图组件类似,也有三个行为,如下:

  • 选中指定的地图区域(mapSelect)
  • 取消选中的指定地图区域(mapUnSelect)
  • 切换指定的地图区域的选中状态(mapToggleSelect)
dispatchAction({
    type: 'mapToggleSelect',
    // 可选,系列 index,可以是一个数组指定多个系列
    seriesIndex?: number|Array,
    // 可选,系列名称,可以是一个数组指定多个系列
    seriesName?: string|Array,
    // 数据的 index,如果不指定也可以通过 name 属性根据名称指定数据
    dataIndex?: number,
    // 可选,数据名称,在有 dataIndex 的时候忽略
    name?: string
})

4)关系图
关系图行为使用,也得引入关系图

  • focusNodeAdjacency 将指定的节点以及其周边相邻的节点高亮
  • unFocusNodeAdjacency 将指定的节点以及其周边相邻的节点取消高亮

5)区域选择相关的行为

  • brush:触发此action可设置或删除chart中的选框
  • takeGlobalCursor:刷选模式的开关。使用此Action可将当前鼠标变为刷选状态
dispatchAction({
    type: 'takeGlobalCursor',
    // 如果想变为“可刷选状态”,必须设置。不设置则会关闭“可刷选状态”。
    key: 'brush',
    brushOption: {
        // 参见 brush 组件的 brushType。如果设置为 false 则关闭“可刷选状态”。
        brushType: string,
        // 参见 brush 组件的 brushMode。如果不设置,则取 brush 组件的 brushMode 设置。
        brushMode: string
    }
});

转载于:https://www.cnblogs.com/sminocence/p/11230730.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CompletableFuture是Java 8中引入的一个类,用于支持异步编程和并发操作。它提供了丰富的API来处理异步任务的结果和操作。以下是CompletableFuture的一些常用API: 1. `CompletableFuture.supplyAsync(Supplier<U> supplier)`:创建一个CompletableFuture对象,该对象会在异步执行给定的Supplier任务后返回结果。 2. `CompletableFuture.runAsync(Runnable runnable)`:创建一个CompletableFuture对象,该对象会在异步执行给定的Runnable任务后返回结果。 3. `CompletableFuture.thenApply(Function<? super T,? extends U> fn)`:对CompletableFuture的结果应用给定的函数,并返回一个新的CompletableFuture对象。 4. `CompletableFuture.thenAccept(Consumer<? super T> action)`:对CompletableFuture的结果应用给定的消费者函数,不返回任何结果。 5. `CompletableFuture.thenRun(Runnable action)`:在CompletableFuture完成后执行给定的Runnable任务。 6. `CompletableFuture.thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)`:将两个CompletableFuture的结果进行组合,并将结果应用给定的函数。 7. `CompletableFuture.thenCompose(Function<? super T,? extends CompletionStage<U>> fn)`:对CompletableFuture的结果应用给定的函数,并返回一个新的CompletableFuture对象。 8. `CompletableFuture.exceptionally(Function<Throwable,? extends T> fn)`:在CompletableFuture发生异常时,应用给定的函数处理异常,并返回一个新的CompletableFuture对象。 9. `CompletableFuture.whenComplete(BiConsumer<? super T,? super Throwable> action)`:在CompletableFuture完成后,应用给定的函数处理结果或异常。 10. `CompletableFuture.allOf(CompletableFuture<?>... cfs)`:返回一个CompletableFuture对象,该对象在所有给定的CompletableFuture对象都完成后完成。 以上是CompletableFuture的一些常用API,你可以根据具体的需求选择适合的方法来处理异步任务。如果你有具体的问题或需要更多的示例,请告诉我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值