-
-
Notifications
You must be signed in to change notification settings - Fork 96
Closed as not planned
Closed as not planned
Copy link
Description
The following component does not work.
import { useEffect, useRef } from 'react';
import * as vg from "@uwdata/vgplot";
import data from 'vega-datasets';
const VGPlotChart = () => {
const chartRef = useRef(null);
const chartRef2 = useRef(null);
useEffect(() => {
const createChart = async () => {
const penguins = await data['penguins.json']();
vg.coordinator().databaseConnector(vg.wasmConnector())
vg.coordinator().exec([
vg.loadJSON('penguins', penguins)
]);
const $xs = vg.Selection.intersect();
const $ys = vg.Selection.intersect();
const $zs = vg.Selection.intersect();
const $filter = vg.Selection.single();
const $highlight = vg.Selection.intersect();
$filter.addEventListener('value', (event) => {
console.log('$filter value:', $filter);
});
$highlight.addEventListener('value', (event) => {
console.log('$highlight value:', $highlight);
});
const plot = vg.plot(
vg.dot(
// penguins,
vg.from('penguins', {filterBy: $filter}),
{x: "Body Mass (g)", y: "Flipper Length (mm)", fill: "Species", r: 2, clip: true}
),
vg.intervalXY({as: $filter}),
// vg.panZoom({x: $xs, y: $ys}),
vg.toggleX({as: $filter}),
vg.toggleX({as: $highlight}),
vg.highlight({by: $highlight}),
vg.width(400),
vg.height(300)
)
const plot2 = vg.plot(
vg.dot(
// penguins,
vg.from('penguins', {filterBy: $filter}),
{x: "Body Mass (g)", y: "Beak Length (mm)", fill: "Species", r: 2, clip: true}
),
vg.intervalX({as: $filter}),
// vg.panZoom({x: $xs}),
vg.toggleX({as: $filter}),
vg.toggleX({as: $highlight}),
vg.highlight({by: $highlight}),
vg.width(400),
vg.height(300)
)
chartRef.current.replaceChildren(plot);
chartRef2.current.replaceChildren(plot2);
};
createChart();
}, []);
return (
<div >
<div className='border rounded p-2 m-2' ref={chartRef}></div>
<div className='border rounded p-2 m-2' ref={chartRef2}></div>
</div>
)
};
export default VGPlotChart;
Whenever I try using the wasmConnector to allow for filtering in browser without running a separate db instance, I get stack overflow issues. I'm not really sure how to fix this and the docs don't seem to go into setting coordinators up in React.
RangeError: Maximum call stack size exceeded
at 08807eba:0xaa6be8
at 08807eba:0xaa6c15
at 08807eba:0xaa6beb
at 08807eba:0xaa6c15
at 08807eba:0xaa6beb
at 08807eba:0xaa6c15
at 08807eba:0xaa6beb
at 08807eba:0xaa6c15
at 08807eba:0xaa6beb
at 08807eba:0xaa6c15
Metadata
Metadata
Assignees
Labels
No labels