echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] Candlestick width not increasing on zoom with time xAxis and 'empty' filterMode

Open xpatinyo opened this issue 1 year ago • 4 comments

Version

5.5.1

Link to Minimal Reproduction

https://codepen.io/xpatt/pen/RwzZwYR

Steps to Reproduce

set xAxis type to 'time' set dataZoom filterMode to 'empty' use series type 'candlestick'

Current Behavior

Candlesticks do not widen on zoom: image

Expected Behavior

Candlesticks should widen on zoom: image

Environment

- OS: Windows 11
- Browser:Chrome & Mozilla
- Framework: JS

Any additional comments?

No response

xpatinyo avatar Aug 10 '24 13:08 xpatinyo

Is there a reason to try filterMode:'empty' or it's just an experiment ? Obviously chart does not look good. Also note that default data order is OCLH, not OHLC. And the colors might need adjustment:

const upColor = '#26a69a';
const downColor = '#ef5350'; //red
itemStyle= {
  color: upColor, // bull
  borderColor: upColor, // bull
  color0: downColor, // bear
  borderColor0: downColor // bear
}

helgasoft avatar Aug 10 '24 20:08 helgasoft

Alright, just changed it to OCLH. Yes, I want to keep the filterMode: empty because it is important for my use case that when zooming in horizontally the vertical height stays the same.

xpatinyo avatar Aug 12 '24 12:08 xpatinyo

important for my use case that when zooming in horizontally the vertical height stays the same.

Another way of doing this is yAxis.max - Demo 📌 please close issue if problem solved.

helgasoft avatar Aug 12 '24 18:08 helgasoft

Yes, but I also have a vertical zoom slider.

xpatinyo avatar Aug 13 '24 18:08 xpatinyo

You can insert a hook function into the dataZoom event, where you can query the current data of the chart.

// Listening to the zoom event and dynamically change the candlestick width
myChart.on('dataZoom', function(params) {
  // Calculate new width with your logic...
  // Update the candlestick width
  myChart.setOption({
    series: [{
      type: 'candlestick',
      barWidth: newBarWidth // Set new candlestick width
    }]
  });
});

Source: ECharts: Candlestick width not increasing on zoom with time xAxis and 'empty' filterMode - StackOverflow answer

rozsazoltan avatar Sep 07 '24 11:09 rozsazoltan