What problem does this feature solve?
ECharts' candlestick series expects values in the order [open, close, low, high] (OCLH). Every other major charting library, financial data API (Alpaca, Polygon, IEX, Yahoo, FRED, Tradier, Binance, IBKR, etc.), and convention in trading/finance uses OHLC (or OHLCV with volume).
This means everyone integrating echarts has to:
- Re-map every bar from
[open, high, low, close] to [open, close, low, high] before passing it in, and
- Re-map again in tooltip / dataset / event handlers when reading values back.
Both are easy to get wrong silently (the chart still renders "correctly-ish" because it auto-detects up vs. down from open/close, but high/low end up swapped on edge cases or labeled wrong in tooltips). Search any echarts integration repo and you'll find a comment explaining the order to the next reader.
What does the proposed API look like?
Add an opt-in valueFormat (or valueLayout) option on candlestick series:
{
type: 'candlestick',
valueFormat: 'ohlc', // 'ohlc' | 'oclh' (default — backwards compatible)
data: [[open, high, low, close], ...]
}
Or, if a string option feels too coarse, an explicit indexer:
{
type: 'candlestick',
valueIndices: { open: 0, high: 1, low: 2, close: 3 },
data: [[open, high, low, close], ...]
}
The default stays OCLH so existing charts are unaffected. Internally, the layout step normalizes to whatever shape the renderer wants, and the tooltip / events expose values via named keys (data.open, data.high, …) regardless of the user-supplied order.
Alternatives considered
- Document the order more loudly in the candlestick docs — helps, but doesn't remove the silent-mistake risk.
- Use
encode with dataset — already supported, but only when you're using the dataset API. Plain series.data arrays still force OCLH.
Anything else?
Happy to send a PR if there's interest in landing this. Filing first to check whether maintainers would accept the option before investing the time.
What problem does this feature solve?
ECharts' candlestick series expects values in the order
[open, close, low, high](OCLH). Every other major charting library, financial data API (Alpaca, Polygon, IEX, Yahoo, FRED, Tradier, Binance, IBKR, etc.), and convention in trading/finance uses OHLC (or OHLCV with volume).This means everyone integrating echarts has to:
[open, high, low, close]to[open, close, low, high]before passing it in, andBoth are easy to get wrong silently (the chart still renders "correctly-ish" because it auto-detects up vs. down from open/close, but high/low end up swapped on edge cases or labeled wrong in tooltips). Search any echarts integration repo and you'll find a comment explaining the order to the next reader.
What does the proposed API look like?
Add an opt-in
valueFormat(orvalueLayout) option oncandlestickseries:Or, if a string option feels too coarse, an explicit indexer:
The default stays OCLH so existing charts are unaffected. Internally, the layout step normalizes to whatever shape the renderer wants, and the tooltip / events expose values via named keys (
data.open,data.high, …) regardless of the user-supplied order.Alternatives considered
encodewithdataset— already supported, but only when you're using the dataset API. Plainseries.dataarrays still force OCLH.Anything else?
Happy to send a PR if there's interest in landing this. Filing first to check whether maintainers would accept the option before investing the time.