Skip to content
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

add plotly template tag #793

Merged
merged 14 commits into from
Mar 20, 2023
Merged

add plotly template tag #793

merged 14 commits into from
Mar 20, 2023

Conversation

shapiromatron
Copy link
Owner

@shapiromatron shapiromatron commented Feb 27, 2023

Add a plotly template tag for easily adding new figures into our application. The template tag by default assumes that the plot should be rendered when the DOM is ready, and it should not be resizable, but these are options that can be passed to the template tag.

Refactor plotly figures on the admin to use the new template tag, and make them resizable so that we can shape the figure to fit powerpoint presentations or other reports.

On the view side, you'll just generate a plotly Figure and make sure it's available in the view context. On the template side, you'll pass the figure to our custom tag:

{% load bs4 %}

<-- common usage; wrap a figure inside a bootstrap cell -->
<div class="col-md-4">{% plotly fig %}</div>

<-- render plot from an htmx event; make it resizable by the user -->
{% plotly fig event="htmx" resizable=True %}

When resizable; you can change the parent div dimensions (see handle in bottom-right):
image

@shapiromatron shapiromatron marked this pull request as ready for review March 14, 2023 14:17
@shapiromatron shapiromatron changed the title add plotly templatetag add plotly template tag Mar 14, 2023
# Conflicts:
#	hawc/apps/assessment/views.py
Copy link
Collaborator

@caseyhans caseyhans left a comment

Choose a reason for hiding this comment

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

Looks good!

@shapiromatron shapiromatron merged commit d425ee2 into main Mar 20, 2023
@shapiromatron shapiromatron deleted the plotly-templatetag branch March 20, 2023 20:15
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.

None yet

2 participants