Lattice Grid Buy a licence

demo D255

Dumbbell chart in React

Two dots joined by a bar per row, so the distance from before to after is the picture

type: 'dumbbell', x, start, end

This draws two dots joined by a bar per row, so the distance from a before value to an after value is the picture. It shows change per item at a glance, so the size of each move reads as the length of its bar.

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.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.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.71.0/lattice-grid.esm.min.js';
  import { createLatticeReact } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.0/modules/react.esm.min.js';
  import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.0/modules/charts.esm.min.js';
  import 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.0/modules/chart-dumbbell.esm.min.js';  // opt in to the dumbbell type

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

  const columns = [
      { field: 'route', title: 'Route' },
      { field: 'before', title: 'Before (ms)', type: 'number', total: 'avg' },
      { field: 'after', title: 'After (ms)', type: 'number', total: 'avg' },
  ];

  const rows = [/* one row a route: route, before, after */];

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

    return (
      <>
        {grid && (
          <LatticeChart grid={grid} type="dumbbell" x="route" start="before" end="after" title="Load time, before and after" style={{ height: '320px' }} />
        )}
        <LatticeGrid
          rowKey="id"
          columns={columns}
          rows={rows}
          onGridReady={setGrid}
          style={{ height: '320px', marginTop: '14px' }}
        />
      </>
    );
  }

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