-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement resize callback for all charts #38
Conversation
@johnSamilin, this resize callback was to completely redraw the component so that the font sizes get rendered properly, and also the 'inset' of the legend can be applied differently based on the relative size of the legend and the overall graph size. Just relying on the 'viewbox' property causes the text to get shrunk. Therefore, the callback is not redundant. Unless you can point me to the code where the render() method is called after a resize? The isse described in OHDSIAtlas#1105 I believe comes from the incorrect width/height dimensions being fed into the control. Somehow it's sending in values that are larger than the actual component space and it causes that slight growth between renders. |
@chrisknoll then why only line chart has this callback? what about the donut chart or any other? all of them have axis labels, and donut also has a legend |
True! This was just a focused fix to address some rendering issues related to line plot, but this could be hoisted up to the base 'chart' level and applied to all plots. |
Anyway, this should be done with css media queries and not resize callbacks. In most cases (like this one) I think it's anti-pattern |
I've tried it both ways, having the chart redraw itself has had the best result. Some reading: And i think this is a good example of why resize is better: Then scale it down. notice, fonts remain consistent, ticks are dynamic based on total width: using media queries would not give you this effect: as you zoomed in, the font size would not adjust appropriately to pad the axis between the axis label, leading to overlapping text. |
Again, I don't mean only |
Ok, if you think it's possible to have the same fidelity using those techniques, that would be great to see. Still wondering how you can adjust ticks and orient axis labels based on dimensions via css and media queries, but I'm always willing to learn something new. |
Question: |
It gives us only 50 k of size |
Apolgoies! you are corect, this cdn shows just 23k download size. I forget where I saw a large bundle size on one of the other libs on atlas. But for this PR, the dependnecy on lodash isn't a large burdeon. Thanks. let me check the local tests for this change and let you know if there's any problems. |
@johnSamilin , sorry to distract this PR but i found where i saw lodash being so large: This is the file that's downloaded with atlas. the difference is it is comming from a NPM install vs a CDN. Do you know if it is possible to get a smaller lodash lib from NPM that can be used in Atlas? |
Does not apply to Split-box due to technical constraints.
@johnSamilin : i took the liberty of applying the resize logic across the different chart types (by hoisting the resize logic to the base chart class, and having subclasses call super()). A nice use of the class hierarchy! I need to import this component into my local atlas env to ensure nothing breaks, but I wanted to share these changes with you first. |
In theory, it could be achieved by removing |
@chrisknoll it won't be effective because of two main reasons:
|
fixes OHDSI/Atlas#1105