Closed martinch-kth closed 5 years ago
@martinch-kth wrapping it with react-kapsule should provide you with a React interface.
In case it helps anybody, here's what seems to work fine:
function Chart({ data }: { data: Group[] }) {
const ref = useRef<null | HTMLDivElement>(null);
useEffect(() => {
let chart: TimelinesChartInstance | null = null;
const { current: node } = ref;
if (node) {
chart = TimelinesChart()(node)
// .zScaleLabel('My Scale Units')
// .zQualitative(true)
.data(data);
}
return () => {
if (node) {
while (node.firstChild) {
node.removeChild(node.firstChild);
}
}
};
}, [data]);
return <div ref={ref}></div>;
}
I've only just got it to work and not familiar with any problems yet.
How can I use this lib as a react component? A simple example would be great. Thanks!