Lattice Grid Buy a licence

demo D189

Quantile colour scales in Vue

A scale that ignores the outlier flattening it

scale: { from: 'quantile' }

This grid shades a column by quantile rather than by raw range, so one extreme value does not flatten the colour for everything else. It keeps a heat map readable when the data is skewed, spreading colour by rank so the middle of the distribution still shows contrast.

Building…
Loading a live grid…

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.108.0/lattice-grid.min.css">
<style>
  #grid > div { height: 460px; }
</style>
<div id="grid"></div>

<script type="module">
  import * as Vue from 'https://esm.sh/vue@3/dist/vue.esm-browser.prod.js';
  import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.esm.min.js';
  import createLatticeGrid from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/modules/vue.esm.min.js';

  const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });

  Vue.createApp({
    components: { LatticeGrid },
    data() {
      return {
        config: {
          rowKey: 'id',
          // The same skewed column, two scales. A min-max scale is flattened by one
          // large value; a quantile scale spans the 5th to 95th percentile instead.
          formatting: {
            'v-minmax':   [{ scale: { from: 'minmax', colours: ['#f5f7fa', '#1a6bc7'] } }],
            'v-quantile': [{ scale: { from: 'quantile', low: 5, high: 95, colours: ['#f5f7fa', '#1a6bc7'] } }],
          },
          columns: [
            { field: 'node', title: 'Node', layout: { pin: 'start', width: 150 } },
            { field: 'value', id: 'v-minmax', title: 'min-max scale', type: 'number' },
            { field: 'value', id: 'v-quantile', title: 'quantile scale', type: 'number' },
            { field: 'value', title: 'value', type: 'number' },
          ],
          rows,
        },
      };
    },
    template: '<lattice-grid v-bind="config" />',
  }).mount('#grid');
</script>