触发图表行为,例如图例开关legendToggleSelect, 数据区域缩放dataZoom,显示提示框showTip等等,更多见 action 和 events 的文档。
//示例代码
myChart.dispatchAction({
type: 'dataZoom',
start: 20,
end: 30
});
// 可以通过 batch 参数批量分发多个 action
myChart.dispatchAction({
type: 'dataZoom',
batch: [{
// 第一个 dataZoom 组件
start: 20,
end: 30
}, {
// 第二个 dataZoom 组件
dataZoomIndex: 1,
start: 10,
end: 20
}]
})
一、highlight 高亮指定的数据图形
// 如果要高亮系列:
dispatchAction({
type: 'highlight',
// 用 index 或 id 或 name 来指定系列。
// 可以使用数组指定多个系列。
seriesIndex?: number | number[],
seriesId?: string | string[],
seriesName?: string | string[],
// 数据项的 index,如果不指定也可以通过 name 属性根据名称指定数据项
dataIndex?: number | number[],
// 可选,数据项名称,在有 dataIndex 的时候忽略
name?: string | string[],
});
// 如果要高亮 geo 组件(从 `v5.1.0` 开始支持):
dispatchAction({
type: 'highlight',
// 用 index 或 id 或 name 来指定 geo 组件。
// 可以用数组指定多个 geo 组件。
geoIndex?: number | number[],
geoId?: string | string[],
geoName?: string | string[],
// geo 组件中 region 名称。
// 可以是一个数组指定多个名称。
name?: string | string[],
});
二、downplay 取消高亮指定的数据图形
// 如果要取消高亮系列:
dispatchAction({
type: 'downplay',
// 用 index 或 id 或 name 来指定系列。
// 可以使用数组指定多个系列。
seriesIndex?: number | number[],
seriesId?: string | string[],
seriesName?: string | string[],
// 数据项的 index,如果不指定也可以通过 name 属性根据名称指定数据项
dataIndex?: number | number[],
// 可选,数据项名称,在有 dataIndex 的时候忽略
name?: string | string[],
})
// 如果要取消高亮 geo 组件(从 `v5.1.0` 开始支持):
dispatchAction({
type: 'downplay',
// 用 index 或 id 或 name 来指定 geo 组件。
// 可以用数组指定多个 geo 组件。
geoIndex?: number | number[],
geoId?: string | string[],
geoName?: string | string[],
// geo 组件中 region 名称。
// 可以是一个数组指定多个名称。
name?: string | string[],
});
三、select 选中指定的数据。选中数据会使用 select 配置的样式。
dispatchAction({
type: 'select',
// 用 index 或 id 或 name 来指定系列。
// 可以使用数组指定多个系列。
seriesIndex?: number | number[],
seriesId?: string | string[],
seriesName?: string | string[],
// 数据项的 index,如果不指定也可以通过 name 属性根据名称指定数据项
dataIndex?: number | number[],
// 可选,数据项名称,在有 dataIndex 的时候忽略
name?: string | string[],
})
四、unselect 取消选中指定的数据。
dispatchAction({
type: 'unselect',
// 用 index 或 id 或 name 来指定系列。
// 可以使用数组指定多个系列。
seriesIndex?: number | number[],
seriesId?: string | string[],
seriesName?: string | string[],
// 数据项的 index,如果不指定也可以通过 name 属性根据名称指定数据项
dataIndex?: number | number[],
// 可选,数据项名称,在有 dataIndex 的时候忽略
name?: string | string[],
})
五、toggleSelect 切换选中状态
dispatchAction({
type: 'toggleSelect',
// 用 index 或 id 或 name 来指定系列。
// 可以使用数组指定多个系列。
seriesIndex?: number | number[],
seriesId?: string | string[],
seriesName?: string | string[],
// 数据项的 index,如果不指定也可以通过 name 属性根据名称指定数据项
dataIndex?: number | number[],
// 可选,数据项名称,在有 dataIndex 的时候忽略
name?: string | string[],
})
六、 dataZoom 数据区域缩放组件相关的行为,必须引入数据区域缩放组件后才能使用。
//数据区域缩放。
dispatchAction({
type: 'dataZoom',
// 可选,dataZoom 组件的 index,多个 dataZoom 组件时有用,默认为 0
dataZoomIndex: number,
// 开始位置的百分比,0 - 100
start: number,
// 结束位置的百分比,0 - 100
end: number,
// 开始位置的数值
startValue: number,
// 结束位置的数值
endValue: number
})
//启动或关闭 toolbox 中 dataZoom 的刷选状态。
myChart.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect',
// 启动或关闭
dataZoomSelectActive: true
});
七、legend 图例组件相关的行为,必须引入图例组件后才能使用。
// legendSelect选中图例
dispatchAction({
type: 'legendSelect',
// 图例名称
name: string
})
// legendUnSelect取消选中图例
dispatchAction({
type: 'legendUnSelect',
// 图例名称
name: string
})
// legendToggleSelect切换图例的选中状态。
dispatchAction({
type: 'legendToggleSelect',
// 图例名称
name: string
})
// legendAllSelect将图例全选。
dispatchAction({
type: 'legendAllSelect',
// 下列参数自 v5.6.0 起开始支持
// 图例组件ID
legendId?: string | string[],
// 图例组件索引
legendIndex?: number | number[]
})
// legendInverseSelect将图例反选。
dispatchAction({
type: 'legendInverseSelect',
// 下列参数自 v5.6.0 起开始支持
// 图例组件ID
legendId?: string | string[],
// 图例组件索引
legendIndex?: number | number[]
})
//控制图例的滚动。当 legend.type 为 'scroll' 时有效。
dispatchAction({
type: 'legendScroll',
// 要滚动到的目标图例项索引
scrollDataIndex: number,
// 图例组件ID
legendId?: string | string[],
// 图例组件索引
legendIndex?: number | number[]
})
八、tooltip 提示框组件相关的行为,必须引入提示框组件后才能使用。
//隐藏提示框 hideTip
dispatchAction({
type: 'hideTip'
})
//显示提示框 showTip
//1 指定在相对容器的位置处显示提示框,如果指定的位置无法显示则无效。
dispatchAction({
type: 'showTip',
// 屏幕上的 x 坐标
x: number,
// 屏幕上的 y 坐标
y: number,
// 本次显示 tooltip 的位置。只在本次 action 中生效。
// 缺省则使用 option 中定义的 tooltip 位置。
position: number[] | string | Function,
})
//2 指定系列中的数据图形,根据 tooltip 的配置项显示提示框。
dispatchAction({
type: 'showTip',
// 系列的 index,在 tooltip 的 trigger 为 axis 的时候可选。
seriesIndex?: number,
// 数据项的 index,如果不指定也可以通过 name 属性根据名称指定数据项
dataIndex?: number,
// 可选,数据项名称,在有 dataIndex 的时候忽略
name?: string,,
// 本次显示 tooltip 的位置。只在本次 action 中生效。
// 缺省则使用 option 中定义的 tooltip 位置。
position: number[] | string | Function,
})
//3 指定 geo 组件中的 region 名,根据 tooltip 的配置项显示提示框。
dispatchAction({
type: 'showTip',
// 用 index 或 id 或 name 来指定 geo 组件。
// 可以用数组指定多个 geo 组件。
geoIndex?: number | number[],
geoId?: string | string[],
geoName?: string | string[],
// geo 组件中 region 名称。
name?: string,
// 本次显示 tooltip 的位置。只在本次 action 中生效。
// 缺省则使用 option 中定义的 tooltip 位置。
position: number[] | string | Function,
})
九、visualMap 视觉映射组件相关的行为,必须引入视觉映射组件后才能使用。
......
十、timeline 时间轴组件相关的行为,必须引入时间轴组件后才能使用。
......
十一、toolbox 工具栏组件相关的行为,必须引入工具栏组件后才能使用。
......
十二、geo 地图组件相关的行为,必须引入地图组件后才能使用。
......
十三、brush 区域选择相关的行为。
......
十四、treemap 矩形树图相关的行为。
......
427




被折叠的 条评论
为什么被折叠?



