demo D175
Colour schemes
Built-in palettes, the default colour-blind safe
scheme: 'default' · 'bright' · 'earth' · 'mono'
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">
<style>
#charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
#charts > div { height: 200px; }
#grid { margin-top: 14px; }
#grid > div { height: 340px; }
</style>
<div id="app"></div>
<script type="module">
import * as Vue from 'https://esm.sh/vue@3';
import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
import createLatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/vue.esm.min.js';
import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';
const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });
Vue.createApp({
components: { LatticeGrid },
data() {
return {
config: {
rowKey: 'id',
columns: [
{ field: 'circuit', title: 'Circuit', layout: { width: 180 } },
{ field: 'region', title: 'Region', filter: { type: 'set' } },
{ field: 'status', title: 'Status', filter: { type: 'set' } },
{ field: 'bandwidth', title: 'Bandwidth', type: 'number' },
{ field: 'charge', title: 'Monthly charge', type: 'number',
format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
],
rows,
},
};
},
mounted() {
// The component exposes the live grid via a template ref. Every chart reads
// that one instance and paints it in a different palette.
const grid = this.$refs.grid.grid();
// The default scheme is the colour-blind-safe palette.
createChart({ grid, container: '#default', type: 'pie', x: 'region', y: 'charge', scheme: 'default' });
createChart({ grid, container: '#bright', type: 'pie', x: 'region', y: 'charge', scheme: 'bright' });
createChart({ grid, container: '#earth', type: 'pie', x: 'region', y: 'charge', scheme: 'earth' });
createChart({ grid, container: '#mono', type: 'pie', x: 'region', y: 'charge', scheme: 'mono' });
},
template: `
<div id="charts">
<div id="default"></div>
<div id="bright"></div>
<div id="earth"></div>
<div id="mono"></div>
</div>
<div id="grid"><lattice-grid ref="grid" v-bind="config" /></div>
`,
}).mount('#app');
</script>