import * as d3 from 'd3';
import { createD3Plugin } from 'lumagrid/plugins';
const bubblePlugin = createD3Plugin({
id: 'bubble',
dataAdapter: (data) => data.rows,
mount(el, data, theme, w, h) {
const svg = d3.select(el).append('svg').attr('width', w).attr('height', h);
svg.selectAll('circle')
.data(data)
.join('circle')
.attr('cx', (d) => Number(d['x'] ?? 0))
.attr('cy', (d) => Number(d['y'] ?? 0))
.attr('r', 6)
.attr('fill', theme.colors[0] ?? 'steelblue');
},
update(el, data, theme, w, h) {
// d3 update pattern
},
destroy(el) {
d3.select(el).selectAll('*').remove();
},
});
registerPlugin(bubblePlugin);
Creates a ChartPlugin backed by a D3 imperative lifecycle. The D3Theme is derived automatically from the Lumagrid ThemeDefinition.