Without seeing your code, my assumption is that the dataZoom component is being updated along with the data. By default, it should not reset.
The standard slider behavior involves applying a relative dataZoom (using the start
/end
properties) to adjust the slider when new data is added. However, if you apply an absolute dataZoom (using the startValue
/endValue
properties), the slider will maintain the selected zoom window.
To modify the text color, utilize the dataZoom.textStyle.color
property.
Check out this example:
const hour = 1000 * 60 * 60;
let counter = 0;
function makeData() {
const data = Array.from([0,1,2,3,4,5], x => [(counter * 6 + x) * hour, Math.random() * 100]);
counter++;
return data;
}
let data = makeData();
option = {
xAxis: {
type: 'time'
},
yAxis: {},
dataZoom: {textStyle: {color: 'red'}},
series: [
{
type: 'line',
data: data,
}
]
};
// set absolute dataZoom
setTimeout(function() {
myChart.dispatchAction({
type: 'dataZoom',
dataZoomIndex: 0,
startValue: 0,
endValue: 4* hour
})
}, 1000);
// append data
setInterval(function() {
data = data.concat(makeData());
myChart.setOption({series: [{data: data}]});
}, 2000);