Lattice Grid Buy a licence

demo D230

An SPC study: control, range, capability in htmx

A drifting process with limits fixed on the first thirty readings, so the drift breaks a rule rather than being absorbed

chart type: control · movingRange · capability

This grid runs an SPC study, control, moving range and capability, with limits fixed on the first thirty readings so a later drift breaks a rule rather than being absorbed. It shows a process going out of control being caught, not smoothed over.

Building…
Loading a live grid…

This is the htmx version. A server-rendered table is upgraded in place, so the page is readable before any script runs and gains the full grid when the module loads, which suits a progressively enhanced app.

The configuration

<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">

<div id="control" style="height: 220px"></div>
<div style="display: flex; gap: 12px; margin-top: 12px">
  <div id="mr" style="flex: 1; height: 200px"></div>
  <div id="cap" style="flex: 1; height: 200px"></div>
</div>
<!-- A real, server-rendered table: readable with JavaScript off. data-field on
     each header names the column that cell becomes, and data-id on each row is
     the key the grid carries it under. -->
<table id="spc-charts-table" data-lattice-grid>
  <thead>
    <tr>
      <th data-field="n">#</th>
      <th data-field="bore">Bore</th>
    </tr>
  </thead>
  <tbody>
    <tr data-id="1"><td>1</td><td>10.004</td></tr>
    <tr data-id="2"><td>2</td><td>9.996</td></tr>
    <tr data-id="3"><td>3</td><td>10.011</td></tr>
    <!-- the rest of the rows, rendered by your server -->
  </tbody>
</table>

<script type="module">
  import { hydrateTable } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/htmx.esm.min.js';
  import { createChart } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/charts.esm.min.js';

  // The markup carries the rows; a server-rendered table's column types are
  // declared in the config hydrateTable takes. The grid replaces the table
  // where it stood.
  const grid = hydrateTable(document.getElementById('spc-charts-table'), {
    columns: [
      { field: 'n', title: '#', type: 'number' },
      // The tolerance is declared once, on the column; every SPC figure reads it.
      { field: 'bore', title: 'Bore', type: 'millimetres', spec: { lower: 9.95, upper: 10.05, target: 10 } },
    ],
  });

  // baseline fixes the limits on the first readings, so a later drift breaks a
  // rule rather than widening the limits to absorb it.
  createChart({ grid, container: '#control', type: 'control',     y: 'bore', baseline: 30, rules: 'nelson' });
  createChart({ grid, container: '#mr',      type: 'movingRange', y: 'bore' });
  createChart({ grid, container: '#cap',     type: 'capability',  y: 'bore' });

  // The capability index against the declared tolerance, with the rule set applied.
  const c = grid.statistics.capability('bore', { rules: 'nelson', baseline: 30 });
  console.log(c.cpk, c.violations);
</script>