vishr opened a new issue, #21602:
URL: https://github.com/apache/echarts/issues/21602
### 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:
1. Re-map every bar from \`[open, high, low, close]\` to \`[open, close,
low, high]\` before passing it in, and
2. 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:
\`\`\`js
{
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:
\`\`\`js
{
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]