echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] datazoom不能通过触发dispatchAction实现自动选中状态

Open ycyucan opened this issue 4 years ago • 3 comments

Version

5.2.2

Link to Minimal Reproduction

No response

Steps to Reproduce

let base = +new Date(1988, 9, 3); let oneDay = 24 * 3600 * 1000; let data = [[base, Math.random() * 300]]; for (let i = 1; i < 20000; i++) { let now = new Date((base += oneDay)); data.push([+now, Math.round((Math.random() - 0.5) * 20 + data[i - 1][1])]); } option = { tooltip: { trigger: 'axis', position: function (pt) { return [pt[0], '10%']; } }, title: { left: 'center', text: 'Large Ara Chart' }, toolbox: { feature: { dataZoom: { yAxisIndex: 'none' }, restore: {}, saveAsImage: {} } }, xAxis: { type: 'time', boundaryGap: false }, yAxis: { type: 'value', boundaryGap: [0, '100%'] }, dataZoom: [ { type: 'inside', start: 0, end: 20 }, { start: 0, end: 20 } ], series: [ { name: 'Fake Data', type: 'line', smooth: true, symbol: 'none', areaStyle: {}, data: data } ] }; myChart.dispatchAction({ type: 'takeGlobalCursor', key: 'dataZoomSelect', // 启动或关闭 dataZoomSelectActive: true });

Current Behavior

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

Expected Behavior

可以正常通过触发事件来激活datazoom

Environment

- OS:
- Browser:chrome
- Framework:

Any additional comments?

No response

ycyucan avatar Jan 19 '22 08:01 ycyucan

@ycyucan It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

[Bug] Datazoom cannot achieve an automatically selected state by triggering a sessionAction

echarts-bot[bot] avatar Jan 19 '22 08:01 echarts-bot[bot]

a year. v5.4.1版本同样有这个问题:(

sanmao3 avatar Mar 16 '23 03:03 sanmao3

Hi @pissang @Ovilia

As above, dispatching this action:

myChart.dispatchAction({
    type: 'takeGlobalCursor',
    key: 'dataZoomSelect',
    dataZoomSelectActive: true // activate or inactivate
})

Does not activate the zoom select feature of the chart. However, using the toolbox button does work. It is expected that this should work via actions, from the documentation: https://echarts.apache.org/en/api.html#action.dataZoom.takeGlobalCursor

This means that it is broken for anyone using a customised toolbox which triggers the zoom selection via actions. This is broken in each version of ECharts, at least from 5.2.2 onwards (more than 1 year), maybe further back.

Are you able to help with this?

Many thanks!

zac18992 avatar Feb 22 '24 17:02 zac18992

@zac18992 A pull request is appreciated. Please check out the wiki to learn how to contribute.

Ovilia avatar Feb 26 '24 07:02 Ovilia