Lattice Grid Buy a licence

demo D206

A fitted line: JavaScript Data Grid Demo

Least squares per series, with R², agreeing with the API

fit: true

This draws a least-squares line through each series in a scatter, with R squared shown and matching the API. It puts a trend and its goodness of fit on the picture, so the strength of a relationship reads directly off the chart.

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.103.2/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';

  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.
  // fit: true draws a least-squares line per series with its R-squared beside
  // it. Only where x is numeric; on a category axis a slope has no meaning.
  createChart({
    grid,
    container: document.getElementById('chart'),
    type: 'scatter',
    x: 'volume',
    y: 'notional',
    fit: true,
    title: 'Notional against volume, fitted',
  });
</script>