Fit container
jansivans opened this issue · 5 comments
I am trying to implement a chart which automatically fits parent's container.
I have tried using resize observer which calls chart.update()
every time parent's dimensions change.
This works, but maybe there is a better way which I am missing?
Every example I have seen just sets parent container with fixed dimensions (width
, height
).
chart.update()
would be the way to go. Since you are not providing any new data, it will re-create the chart layout and some components may appear or disappear depending on the space available, as in a responsive behaviour.
@cbt1 thanks for answer!
Only issue I have with this approach is that brush selections gets cleared each time I call chart.update()
.
try using chart.update({ partialData: true })
I think that should skip clearing brush selections
@T-Wizard it does, but it also removes some components from chart and sometimes a whole chart doesn't get rendered at all.
As an example, you can add partialData: true
here https://github.com/qlik-oss/picasso.js/blob/master/examples/hammer/index.js#L190 and check what happens.
Right now I am just using this workaround:
const brush = chart.brush('select');
brush.clear = () => { };
This way calling chart.update()
will re-render everything responsively and selections won't be cleared.