demo D214
Candlestick in Vue
Open, high, low and close, one row a day
type: 'candlestick', measures: [open, high, low, close]
This draws a candlestick chart, one candle a day from open, high, low and close, with a price axis on the right, zoom and pan, and a drawing rail for trend lines, channels, Fibonacci retracements and measuring a range. It shows a market's daily range and direction in the form traders read, straight from the grid's rows.
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>
#chart { height: 320px; }
#grid { margin-top: 14px; }
#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 } 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',
columns: [
{ field: 'day', title: 'Day', type: 'date', layout: { width: 120 } },
{ field: 'open', title: 'Open', type: 'number', format: { decimals: 2 } },
{ field: 'high', title: 'High', type: 'number', format: { decimals: 2 } },
{ field: 'low', title: 'Low', type: 'number', format: { decimals: 2 } },
{ field: 'close', title: 'Close', type: 'number', format: { decimals: 2 } },
],
rows, // e.g. [{ id: 1, day: '2026-01-02', open: 100, high: 101.2, low: 99.3, close: 100.8 }, …]
},
};
},
mounted() {
// The component exposes the live grid via a template ref, which the chart draws from.
const grid = this.$refs.grid.grid();
// Candlestick takes four measures, in open, high, low, close order.
createChart({ grid, container: '#chart', type: 'candlestick', x: 'day',
measures: [{ col: 'open' }, { col: 'high' }, { col: 'low' }, { col: 'close' }] });
},
template: `
<div id="chart"></div>
<div id="grid"><lattice-grid ref="grid" v-bind="config" /></div>
`,
}).mount('#app');
</script>