dataZoom with rangeMode: 'value' is broken
See original GitHub issueVersion
4.5.0
Steps to reproduce
When dataZoom is used with rangeMode: ‘value’, zoom gets reset immediately when data is added or changed. When rangeMode is left to the default value, it works. But rangeMode: ‘value’ is required since we need the chart to stay still when zoomed in and new data is added. This worked correctly in v4.2.1.
This is a slight adaptation of the dynamic data example that shows the problem. Just execute in the try editor, zoom in with the mouse wheel. When the next data updated is added, zoom, resets immediately.
function randomData() {
now = new Date(+now + oneDay);
value = value + Math.random() * 21 - 10;
return {
name: now.toString(),
value: [
[now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
Math.round(value)
]
}
}
var data = [];
var now = new Date(1997, 9, 3);
var oneDay = 24 * 3600 * 1000;
var value = Math.random() * 1000;
for (var i = 0; i < 1000; i++) {
data.push(randomData());
}
option = {
xAxis: {
type: 'time',
},
yAxis: {
type: 'value',
},
series: [{
name: 'test',
type: 'line',
showSymbol: false,
hoverAnimation: false,
data: data
}],
dataZoom: [{
type: 'inside',
rangeMode: 'value'
}]
};
setInterval(function () {
for (var i = 0; i < 5; i++) {
data.shift();
data.push(randomData());
}
myChart.setOption({ series: [{ data: data }] });
}, 1000);
What is expected?
current zoom should remain unchanged
What is actually happening?
zoom is reset when data is added/changed
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
apache/echarts - dataZoom with rangeMode: 'value' is broken
Version 4.5.0 Steps to reproduce When dataZoom is used with rangeMode: 'value', zoom gets reset immediately when data is added or changed.
Read more >echarts/pyecharts: dataZoom starts at 0 - python - Stack Overflow
AxisOpts( type_='value' ) datazoom_opts = opts.DataZoomOpts( type_='slider', start_value=1596705336000, end_value=1596706538000, ) ...
Read more >Changelog - Apache ECharts
... [Fix] [dataZoom] Fallback to extent start/end when value or percent is invalid. ... [log] Fix log axis breaks a single data whose...
Read more >[incubator-echarts] 08/16: feature: (1) support axis id reference ...
(except toolbox dataZoom) (3) enhance dataZoom to enable axis and dataZoom removal ... Possible values: 'filter' or 'empty' or 'weakFilter'.
Read more >Python Figure Reference: layout.xaxis - Plotly
See `rangemode` for more info. If `range` is provided, then `autorange` is set to "False". autotypenumbers. Code: fig.update_xaxes(autotypenumbers=<VALUE>)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dr-itz
I think
rangeMode: 'value'
is not broken, but is a break change that I didn’t noticed. The previous behavior supports your usage but it is buggy in some cases. So I fixed it in the subsequent version, and clarified the definition of dataZoom.rangeMode. That makes your code work in the previous version but probably logically incorrect in the current definition.Please try this code. I hope it can match your requirement:
And next, we should think of whether to add an option to support your case instead of the code above.
This issue is closed due to not being active. Please feel free to open it again (for the author) or create a new one and reference this (for others) if you have further questions.