demo D267
Ridgeline: JavaScript Data Grid Demo
A distribution per category, stacked on a shared scale so the shapes line up to compare
type: 'ridgeline', x, y
This draws a distribution per category, stacked on a shared scale so the shapes line up. It lets you compare how the spread of a value differs across many groups at once, shape against shape.
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.js"></script>
<div id="grid" style="height: 340px"></div>
<div id="chart" style="height: 340px"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-ridgeline'; // opt in to the ridgeline type
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'symbol', title: 'Symbol' },
{ field: 'desk', title: 'Desk', filter: { type: 'set' } },
{ field: 'price', title: 'Price', type: 'number', format: { decimals: 4 } },
{ field: 'bid', title: 'Bid', type: 'number', format: { decimals: 4 } },
{ field: 'ask', title: 'Ask', type: 'number', format: { decimals: 4 } },
{ field: 'volume', title: 'Volume', type: 'number', format: { notation: 'compact' } },
{ field: 'notional', title: 'Notional', type: 'number',
format: { style: 'currency', currency: 'USD' }, total: 'sum' },
],
rows, // instruments: symbol, desk, price, bid, ask, volume, notional
});
// A chart reads the grid's filtered rows and redraws when the grid changes.
// x names the category for each ridge; series names the rows behind it, so a
// ridge is a real spread rather than one figure. The ridges share a scale.
createChart({
grid,
container: document.getElementById('chart'),
type: 'ridgeline',
x: 'desk',
series: 'symbol',
y: 'price',
title: 'Price by desk',
});
</script>