demo D230
An SPC study: control, range, capability in Vue
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.
This is the Vue 3 version. A createLatticeGrid component takes the configuration through v-bind, and reactive data flows straight into the grid, so it updates the way the rest of your Vue app does.
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">
<style>
#tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
#control { height: 220px; margin-top: 14px; }
#pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
#pair > div { height: 200px; }
#grid { margin-top: 12px; }
#grid > div { height: 320px; }
</style>
<div id="app"></div>
<script type="module">
import * as Vue from 'https://esm.sh/vue@3/dist/vue.esm-browser.prod.js';
import { createGrid, createStat } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.esm.min.js';
import createLatticeGrid from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/vue.esm.min.js';
import { createChart } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/charts.esm.min.js';
const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });
Vue.createApp({
components: { LatticeGrid },
data() {
return {
config: {
rowKey: 'id',
toolPanel: { side: 'left', panels: ['columns', 'statistics'] },
columns: [
{ field: 'n', title: '#', type: 'number', layout: { width: 80 } },
// 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 } },
],
rows, // measured parts, in the order they were made
},
};
},
mounted() {
// The component exposes the live grid via a template ref. All three charts and
// the capability tiles read that one instance.
const grid = this.$refs.grid.grid();
// Three figures read from the live grid: Cpk against the tolerance, the
// mean bore, and the count. baseline fixes the control limits on the
// first thirty readings, so the later drift breaks a rule.
const tiles = document.getElementById('tiles');
createStat({ grid, container: tiles.appendChild(document.createElement('div')), title: 'Cpk',
value: (g) => g.statistics.capability('bore', { rules: 'nelson', baseline: 30 })?.cpk,
goodWhen: 'up', baseline: 1.33, decimals: 2, footer: '1.33 is the usual floor' });
createStat({ grid, container: tiles.appendChild(document.createElement('div')), title: 'Mean bore', of: 'bore', fn: 'avg' });
createStat({ grid, container: tiles.appendChild(document.createElement('div')), title: 'Readings', fn: 'count', footer: 'the first 30 set the limits' });
// baseline fixes the limits on the first 30 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', title: 'Control chart, limits fixed on the first 30 readings' });
createChart({ grid, container: '#mr', type: 'movingRange', y: 'bore', title: 'Moving range' });
createChart({ grid, container: '#cap', type: 'capability', y: 'bore', title: 'Capability against the tolerance' });
},
template: `
<div id="tiles"></div>
<div id="control"></div>
<div id="pair">
<div id="mr"></div>
<div id="cap"></div>
</div>
<div id="grid"><lattice-grid ref="grid" v-bind="config" /></div>
`,
}).mount('#app');
</script>