Lattice Grid Buy a licence

demo D211

Analytical chemistry in ESM

Molarity, ppb and dose types, with a contaminated batch the rules find

type: molarity · ppb · doseRate

This is an analytical chemistry sheet with molarity, parts-per-billion and dose-rate types, and a contaminated batch that the rules find. It shows domain units and inline rules catching a real problem in scientific data.

Building…
Loading a live grid…

This is the ES module version. The grid is imported straight from a CDN as a module, the same configuration as the vanilla tab without a global script tag, so it drops into any bundler or a bare module script.

The configuration

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

<div id="grid" style="height: 480px"></div>

<script type="module">
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.0/lattice-grid.esm.min.js';

  const grid = createGrid(document.getElementById('grid'), {
    rowKey: 'id',
    columnDefaults: { filter: true },
    toolPanel: { side: 'left', panels: ['columns', 'filters', 'statistics'] },
    columns: [
      { field: 'sample', title: 'Sample', layout: { pin: 'start', width: 120 } },
      { field: 'batch', title: 'Batch', filter: { type: 'set' } },
      // Each reading is its own unit type: molarity, parts per billion,
      // temperature, radioactivity and dose rate, all sortable and totalled.
      { field: 'concentration', title: 'Concentration', type: 'molarity', total: 'median' },
      { field: 'contaminant', title: 'Contaminant', type: 'ppb', total: 'p95' },
      { field: 'temperature', title: 'Temp', type: 'celsius', total: 'avg' },
      { field: 'activity', title: 'Activity', type: 'radioactivity' },
      { field: 'doseRate', title: 'Dose rate', type: 'doseRate', total: 'max' },
    ],
    formatting: {
      // The z-score and outlier rules read the whole column, so a contaminated
      // batch is flagged whatever the sort order.
      contaminant: [
        { id: 'c-z', when: { op: 'zAbove', value: 3 }, style: { background: '#fbeceb', color: '#a4262c' } },
        { id: 'c-out', when: { op: 'outlier' }, style: { background: '#fff4e5' } },
      ],
    },
    rows,  // lab samples: sample, batch, concentration, contaminant, temperature, activity, doseRate
  });
</script>