demo D188
Rules that describe the data in React
The outliers, found in the data, beside a threshold you typed
when: { op: 'outlier' }
This grid highlights the outliers found in the data itself, shown beside a fixed threshold you typed, so you can compare the two. It lets a rule describe the shape of the data rather than a hard-coded cutoff, so unusual values surface even when you did not know the number in advance.
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.108.0/lattice-grid.min.css">
<div id="grid"></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.108.0/lattice-grid.esm.min.js';
import createLatticeGrid from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/modules/react.esm.min.js';
const LatticeGrid = createLatticeGrid({ React, createGrid });
// Two columns of the same field: a threshold you type, and a rule that finds
// the outliers in the data itself.
const formatting = {
charge: [{ when: { op: 'gt', value: 3000 }, style: { background: '#fff4e5' } }],
'charge-outlier': [{ when: { op: 'outlier' }, style: { background: '#fbeceb' } }],
};
const columns = [
{ field: 'circuit', title: 'Circuit', layout: { pin: 'start', width: 180 } },
{ field: 'region', title: 'Region', filter: { type: 'set' } },
{ field: 'charge', title: 'Charge · gt 3000', type: 'number' },
{ field: 'charge', id: 'charge-outlier', title: 'Charge · outlier', type: 'number' },
];
const rows = [/* circuit records */];
function App() {
return (
<LatticeGrid
rowKey="id"
columnDefaults={{ filter: true }}
formatting={formatting}
columns={columns}
rows={rows}
style={{ height: '500px' }}
/>
);
}
createRoot(document.getElementById('grid')).render(<App />);
</script>