echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] candlestick chart combined with markLine exception

Open xmatthias opened this issue 3 months ago • 6 comments

Version

latest / playground

Link to Minimal Reproduction

reproduction

Steps to Reproduce

  • Use a candlestick chart with endoce, where x is not 0
  • add markLine within view
  • observe nothing is shown
  • open browser console in devtools
  • Look at the rendered error.

Current Behavior

Crash, no candle is shown

Logs in the browser console:

VM2393 about:srcdoc:1 failed to run code TypeError: Cannot read properties of undefined (reading 'ordinalMeta')
    at t.getOrdinalMeta (echarts.min.js:45:151210)
    at t._getCategory (echarts.min.js:45:245774)
    at D_ (echarts.min.js:45:251026)
    at P_ (echarts.min.js:45:251677)
    at t._doInit (echarts.min.js:45:245079)
    at t.initData (echarts.min.js:45:243066)
    at echarts.min.js:45:895623
    at e.renderSeries (echarts.min.js:45:895756)
    at echarts.min.js:45:889914
    at e.<anonymous> (echarts.min.js:45:126314)

Expected Behavior

Candlechart renders with lines drawn on top.

That's already the case in the following example - which has only a couple lines different, namely the timestamp is generated at position 0 - and all X encodings are consequently set to 0, too.

working sample

Environment

- OS:linux
- Browser: chromium
- Framework: echarts playground

Any additional comments?

This kindof negates the possibility to have encode - if we're forced to have certain parameters at certain locations in a chart.

xmatthias avatar Oct 02 '25 18:10 xmatthias

obvious bug, apparently limited to candlestick series with a markLine. Problem is not with encode since it works fine without a markLine. So the bug comes from markLine. Parent series candlestick Y-data consists of four values instead of just one. So I suspect a confusion on how to interpret the markLine Y value leads to the ordinalMeta error. Workaround - add an invisible scatter series and attach all markLines to it - Demo.

helgasoft avatar Oct 03 '25 04:10 helgasoft

I'm also getting this error on barchart series using datasets. Link to reproduction: https://codesandbox.io/p/sandbox/6q4d69

Note, you'll have to set renderMarkline to true (in the sandbox) in order to see the error.

kateEcobb avatar Oct 07 '25 16:10 kateEcobb

@kateEcobb, I see the bug showing up in your bar series. I could not identify the reason, but same workaround with scatter works - Demo. In simpler scenarios bars with markLine display correctly - Demo, an enigma 🔮

helgasoft avatar Oct 07 '25 20:10 helgasoft

We had this bug also show up on a Multiseries chart with 2 lines and a bar series, the workaround is also to add an invisible scatter series to the configuration but feels more like a hack

mikkurogue avatar Oct 31 '25 19:10 mikkurogue

I've done some preliminary low effort debugging and testing, and it seems to somehow only throw the error when using series.encode as an option. as soon as I remove series.encode the error doesn't throw - though the markline is still not there (likely due to some reason that the dimension it's meant to be on doesnt parse properly)

I'm still looking into it to see if theres any fix I can potentially provide, even as just a starting point for a maintainer to look into.

mikkurogue avatar Nov 03 '25 07:11 mikkurogue

Another workaround is to set the X axis data as first column - Demo

helgasoft avatar Dec 08 '25 20:12 helgasoft