Lattice Grid Buy a licence

demo D175

Colour schemes

Built-in palettes, the default colour-blind safe

scheme: 'default' · 'bright' · 'earth' · 'mono'

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.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.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
  import createLatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/react.esm.min.js';
  import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';

  const LatticeGrid = createLatticeGrid({ React, createGrid });

  const columns = [
    { field: 'circuit', title: 'Circuit', layout: { width: 180 } },
    { field: 'region', title: 'Region', filter: { type: 'set' } },
    { field: 'status', title: 'Status', filter: { type: 'set' } },
    { field: 'bandwidth', title: 'Bandwidth', type: 'number' },
    { field: 'charge', title: 'Monthly charge', type: 'number',
      format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
  ];

  const rows = [/* circuit records */];

  function App() {
    const gridRef = React.useRef(null);

    // scheme picks the palette. The default is the colour-blind-safe one. Each
    // chart reads the live grid through the ref, so a filter redraws them together.
    React.useEffect(() => {
      const grid = gridRef.current.grid;
      createChart({ grid, container: '#default', type: 'pie', x: 'region', y: 'charge', scheme: 'default', title: 'default' });
      createChart({ grid, container: '#bright',  type: 'pie', x: 'region', y: 'charge', scheme: 'bright',  title: 'bright' });
      createChart({ grid, container: '#earth',   type: 'pie', x: 'region', y: 'charge', scheme: 'earth',   title: 'earth' });
      createChart({ grid, container: '#mono',    type: 'pie', x: 'region', y: 'charge', scheme: 'mono',    title: 'mono' });
    }, []);

    return (
      <>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '14px', height: '210px' }}>
          <div id="default" />
          <div id="bright" />
          <div id="earth" />
          <div id="mono" />
        </div>
        <LatticeGrid
          ref={gridRef}
          rowKey="id"
          columns={columns}
          rows={rows}
          style={{ height: '340px', marginTop: '14px' }}
        />
      </>
    );
  }

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