Lattice Grid Buy a licence

demo D214

Candlestick

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

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

Building…
Loading a live grid…

The configuration

<script>
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
  import createLatticeAction from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/svelte.esm.min.js';
  import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';

  const lattice = createLatticeAction({ createGrid });

  let chartEl;

  const config = {
    rowKey: 'id',
    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 } },
    ],
    rows,  // e.g. [{ id: 1, day: '2026-01-02', open: 100, high: 101.2, low: 99.3, close: 100.8 }, ...]
    // onGrid hands over the live grid the moment it is created. Candlestick takes
    // four measures, in open, high, low, close order, and follows the grid.
    onGrid: (grid) => {
      createChart({ grid, container: chartEl, type: 'candlestick', x: 'day',
        measures: [{ col: 'open' }, { col: 'high' }, { col: 'low' }, { col: 'close' }] });
    },
  };
</script>

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">
</svelte:head>

<div bind:this={chartEl} style="height: 320px"></div>
<div use:lattice={config} style="height: 320px; margin-top: 14px"></div>