Lattice Grid Buy a licence

demo D214

Candlestick in React

Open, high, low and close, one row a day

type: 'candlestick', measures: [open, high, low, close]

This draws a candlestick chart, one candle a day from open, high, low and close, with a price axis on the right, zoom and pan, and a drawing rail for trend lines, channels, Fibonacci retracements and measuring a range. It shows a market's daily range and direction in the form traders read, straight from the grid's rows.

Building…
Loading a live grid…

This is the React version. The grid mounts through the createLatticeGrid adapter, which takes its configuration as ordinary props and hands back the live grid through a ref. The grid below is the same one every other tab runs.

The configuration

<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">

<div id="app"></div>

<script type="module">
  import React from 'https://esm.sh/react@18';
  import { createRoot } from 'https://esm.sh/react-dom@18/client';
  import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.esm.min.js';
  import { createLatticeReact } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/react.esm.min.js';
  import { createChart } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/charts.esm.min.js';

  const { LatticeGrid, LatticeChart } = createLatticeReact({ React, createGrid, createChart });

  const columns = [
    { field: 'day', title: 'Day', type: 'date', layout: { width: 120 } },
    { field: 'open',  title: 'Open',  type: 'number', format: { decimals: 2 } },
    { field: 'high',  title: 'High',  type: 'number', format: { decimals: 2 } },
    { field: 'low',   title: 'Low',   type: 'number', format: { decimals: 2 } },
    { field: 'close', title: 'Close', type: 'number', format: { decimals: 2 } },
  ];

  // e.g. [{ id: 1, day: '2026-01-02', open: 100, high: 101.2, low: 99.3, close: 100.8 }, ...]
  const rows = [/* one row a day */];
  const measures = [{ col: 'open' }, { col: 'high' }, { col: 'low' }, { col: 'close' }];

  function App() {
    const [grid, setGrid] = React.useState(null);

    return (
      <>
        {/* Candlestick takes four measures, in open, high, low, close order. */}
        {grid && <LatticeChart grid={grid} type="candlestick" x="day" measures={measures} title="Daily range" style={{ height: '320px' }} />}
        <LatticeGrid
          rowKey="id"
          columns={columns}
          rows={rows}
          onGridReady={setGrid}
          style={{ height: '320px', marginTop: '14px' }}
        />
      </>
    );
  }

  createRoot(document.getElementById('app')).render(<App />);
</script>