Skip to main content
The demo above is what you’ll have by the end of this guide. It’s built with Apache ECharts and the NGN Market API’s format=ohlcv option, which returns data in exactly the shape charting libraries expect. Endpoint used:

Live demo

Hover over any candle to see the OHLCV breakdown. This demo runs on generated sample data so it works without an API key. The code below swaps that out for real NGX prices.

What the data looks like

When you request format=ohlcv, each entry in the data array is a compact array in this order:
The timestamp is in Unix milliseconds. ECharts works with milliseconds natively, so you can pass it straight to a Date constructor — no conversion needed. One thing to watch: ECharts candlestick series expects data in [open, close, lowest, highest] order, which is different from the API’s [open, high, low, close] order. The mapping section below handles this.

Handling missing OHLC data

close is the only value guaranteed on every entry. For some dates, typically when you request a long history (period=5y, period=all, or an old from date), a company’s intraday range wasn’t tracked that far back. When that happens, open, high, low, and volume come back as null while close is still populated: [1583020800000, null, null, null, 12.5, null]. Filter these out before handing data to a candlestick series. A candle can’t be drawn without all four OHLC values:
JavaScript
If you’d rather keep the full close-price history visible instead of dropping those points, render two series: candlesticks for the rows with full OHLC, and a thin line plotting every row’s close price underneath for continuity. The examples below use the simple filter.

Vanilla JavaScript

You can load ECharts from a CDN with no build step required.
HTML
JavaScript

React component

If you’re working in React, here’s a reusable component that handles fetching, rendering, and cleaning up the chart when the component unmounts. It also responds to container resizes automatically.
React
Drop it anywhere in your app:
React

Adding a volume panel

Volume is the sixth value in each array (index 5). ECharts supports multiple grids in a single chart instance, so you can stack a volume bar chart directly beneath the candlesticks and link their x-axes so zoom and pan stay in sync.
JavaScript

A few things worth knowing

The data order mismatch. The API returns [timestamp, open, high, low, close, volume]. ECharts candlestick expects [open, close, lowest, highest]. Always map [open, close, low, high] — swapping high and low will render wicks upside down. Pick a period that fits your use case. 7d and 30d are good for a focused recent view. 1y works well for trend analysis. 5y is what you want for a long-term research screen. Shorter periods load faster and render more smoothly. The symbol lookup is case-insensitive. DANGCEM, dangcem, and DangCem all resolve to the same company. Switching symbols without rebuilding the chart. If you’re building a stock picker where users switch between companies, call chart.setOption({ series: [{ data: newCandles }] }) on the existing instance rather than disposing and reinitialising. The transition is smoother and you keep the zoom and scroll position.

Chart endpoint reference

All parameters for GET /companies/{symbol}/chart

Company profile reference

Pair this with company data for a full stock detail page