I'm following this example, using the following code
// resizable chart function
const callback = (chartObj: DCGraphicType) => () => {
redrawChartNoTransitions(chartObj.width(null).rescale()); // @typeerror
};
// watch for resize and call callback when resize occurs
React.useEffect(() => {
new ResizeObserver(callback(chart)).observe(
d3.select(div.current!).node()!
);
}, [chart]);
and getting this error:
ChartTemplate.tsx:77 Uncaught TypeError: chartObj.width is not a function
at ResizeObserver.<anonymous> (ChartTemplate.tsx:77)
(anonymous) @ ChartTemplate.tsx:77
Note: the helper functions are
const restoreGetset = (property, value) => f => c => {
if (Array.isArray(c)) c.forEach(restoreGetset(property, value)(f));
else {
const cs = c.children ? [c].concat(c.children()) : [c];
const last = cs.map(c => c[property]());
cs.forEach(ch => ch[property](value));
f(c);
cs.forEach(ch => ch[property](last));
}
return c;
};
// specifically, turn off transitions for a chart or charts
const noTransitions = restoreGetset("transitionDuration", 0);
// specifically, turn off transitions for a chart or charts and redraw
export const redrawChartNoTransitions = noTransitions(c => c.redraw());
This works on my local app (forced through the error), but I'd like to understand and get rid of it... Here's a Stackblitz with the error in place
