Skip to content

Cleanup MacroElements #2088

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

Merged
merged 2 commits into from
Mar 22, 2025

Conversation

hansthen
Copy link
Collaborator

During an earlier change, I noted that many MacroElement subclasses do not fully use the templating facilities of their parent class.

This PR makes the code more internally consistent by using the template route where possible. I skipped the DualMap, Vega and Vegalite classes because I do not fully understand what is happening there.

@hansthen hansthen requested a review from Conengmo January 27, 2025 07:09
Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you identified some areas where templates are not used in the default way. I added some comments to places that may require some more attention. If you could limit this PR to just the straight forward cases, it should be easy to merge. Then we can maybe look at the more complicated cases separately or leave them as is.

Earlier I noted many macroelements do not fully use
the facilities of Figure, but instead in render manipulate
the parent Figure.

Step 1: remove GlobalSwitches as Element
@hansthen hansthen force-pushed the cleanup_macroelements branch from f40bd8c to 0e9ef12 Compare March 16, 2025 21:32
@hansthen hansthen requested a review from Conengmo March 16, 2025 21:38
@hansthen
Copy link
Collaborator Author

Nice that you identified some areas where templates are not used in the default way. I added some comments to places that may require some more attention. If you could limit this PR to just the straight forward cases, it should be easy to merge. Then we can maybe look at the more complicated cases separately or leave them as is.

I made the requested changes.

Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice cleanup!

@@ -60,6 +60,29 @@ class Draw(JSCSSMixin, MacroElement):

_template = Template(
"""
{% macro html(this, kwargs) %}
{% if this.export %}
<style>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this style element was originally added to the header. Here it's in the body. I guess it doesn't make a difference really, does it?

@hansthen hansthen merged commit c50ab41 into python-visualization:main Mar 22, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants