Lattice Grid Buy a licence

demo D204

Statistical process control in Svelte

Control limits against spec limits, which are not the same thing

type: 'control', y, baseline

This draws a statistical process control chart with control limits set against spec limits, which are not the same thing. It shows when a process is drifting out of its own normal behaviour, distinct from whether it meets the spec, so you catch a change early.

Building…
Loading a live grid…

This is the Svelte version. A use action attaches the grid to a plain element, so no framework runtime is passed in and the component stays small, while the configuration is ordinary Svelte state.

The configuration

<script>
  import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.esm.min.js';
  import createLatticeAction from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/svelte.esm.min.js';
  import { createChart } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/charts.esm.min.js';

  const lattice = createLatticeAction({ createGrid });

  let chartEl;

  const config = {
    rowKey: 'id',
    columns: [
      { field: 'part', title: 'Part', layout: { width: 110 } },
      // The spec declares the tolerance; the control chart reads it.
      { field: 'bore', title: 'Bore', type: 'number',
        spec: { lower: 9.5, upper: 10.8, target: 10 } },
    ],
    rows,  // machined bore measurements
    // onGrid hands over the live grid the moment it is created. baseline sets the
    // control limits over the first readings, and the chart follows the grid's
    // filters and sort from then on.
    onGrid: (grid) => {
      createChart({ grid, container: chartEl, type: 'control', y: 'bore', baseline: 20 });
    },
  };
</script>

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

<div bind:this={chartEl} style="height: 340px"></div>
<div use:lattice={config} style="height: 320px; margin-top: 14px"></div>