Is there an easy way to trigger redrawing an Insig...
# gooddata-ui
e
Is there an easy way to trigger redrawing an InsightView when the dimensions of it’s container change? Currently I have to unmount and remount the entire InsightView component, but that also means having to wait for it to fetch all sorts of data again. I know Highcharts has a redraw callback, wondering if there’s anyway to trigger it from InsightView
j
Hello Evan, may I know what's the exact use-case? Could you share more why do you need to redraw the insight? Is it because you expect the underlying data has changed? Or is it because of updating the layout of the page? What's the reason please?
e
updating the layout of the page
most common use case would be resizing of the chart or its parent container. the data is all the same, it just needs to update to the new dimensions
j
It should update automatically 🤔 Does it not re-render automatically when you change the dimensions of the chart's parent container? Are you working within a React environment? Could you please provide a screen recording where this is an issue? I'd love to take a look. It might be a legit use-case that we didn't think of, or it may be a bug. Hard to say at this point. Please share more!
e
since you said that i poked around some more and i see it does auto-update when its container width is changed, but not for height. i’ll make a recording
Kapture 2022-12-16 at 11.49.27.mp4
j
Thanks for the recording! I believe this is correct behavior. The width should always take 100% of the parent container, while the height must be specified by the developer. If you wish the chart to get taller (or shorter), you must update its height programatically, e.g. try setting the new height value like this
<ColumnChart style={{ height: 200 }} />
.
There are 3rd party React libraries/components that will monitor the height of a certain container and provide the new value so that you can simply apply this logic as you see fit.
e
ok i got it to work, thanks! Although the style property doesn’t exist on these chart components, I had to apply it to the .gd-viz-highchart-wrap css class. Anywhere else either had no effect, truncated the graph, or proportionally scaled the width too which wasn’t desired behavior.
j
Glad you were able to work it out! 👏 And thank you for letting us know!
👍 1