Lattice Grid Buy a licence

demo D180

Profiling a column

Count, spread, quartiles and outliers from the API, into a panel of your own

grid.statistics.profile(col)

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';

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

  const columns = [
    { field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
    { field: 'desk', title: 'Desk', filter: { type: 'set' } },
    { field: 'price', title: 'Price', type: 'number' },
    { field: 'bid', title: 'Bid', type: 'number' },
    { field: 'volume', title: 'Volume', type: 'number' },
    { field: 'notional', title: 'Notional', type: 'number',
      format: { style: 'currency', currency: 'USD' }, total: 'sum' },
  ];

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

  function App() {
    const gridRef = React.useRef(null);
    const [out, setOut] = React.useState('');

    // profile() reads a full summary of one column over the filtered rows, so
    // every figure follows the filters.
    const report = () => {
      const grid = gridRef.current && gridRef.current.grid;
      if (grid) setOut(JSON.stringify(grid.statistics.profile('notional'), null, 2));
    };

    React.useEffect(report, []);

    return (
      <>
        <LatticeGrid
          ref={gridRef}
          rowKey="id"
          toolPanel={{ side: 'left', panels: ['filters', 'columns'] }}
          columns={columns}
          rows={rows}
          onFilterChanged={report}
          style={{ height: '460px' }}
        />
        <pre style={{ marginTop: '12px' }}>{out}</pre>
      </>
    );
  }

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