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

[Components] Add support for matplotlib #71

Open
amrutha97 opened this issue Feb 4, 2025 · 2 comments · May be fixed by #115
Open

[Components] Add support for matplotlib #71

amrutha97 opened this issue Feb 4, 2025 · 2 comments · May be fixed by #115

Comments

@amrutha97
Copy link
Member

amrutha97 commented Feb 4, 2025

Description

Add support for rendering Matplotlib figures as a component. Users should be able to do the following in an example project:

from preswald import matplotlib

When they run:

preswald run hello.py

The plot should render in the frontend automatically.


Tasks

Backend

  • Update preswald/components.py to support matplotlib.plot().
  • Convert matplotlib.figure.Figure to a format the frontend can handle (PNG, SVG, etc.).
  • Ensure the component follows the existing serialization structure.
  • Add tests to verify that Matplotlib figures can be created, serialized, and sent to the frontend.

Frontend

  • Add a new component in frontend/src/components/widgetsto render Matplotlib figures.
  • Handle the received image format properly (PNG, SVG, etc.).
  • Ensure the component updates dynamically when new figure data comes in.
  • Handle layout and resizing correctly.

Integration

  • Update DynamicComponents.jsx to recognize and render the Matplotlib component.
  • Test by running preswald run hello.py with a script that uses matplotlib.plot().

Docs

  • Update the preswald-docs repo:
    • Add a new documentation file under components/ explaining how to use matplotlib.plot().
    • Update mint.json to include the new component.

Acceptance Criteria

  • Running preswald run hello.py with matplotlib.plot() renders the plot in the UI.
  • The component updates dynamically when new data is passed.
  • No breaking changes to existing components.
  • Documentation is updated.
@bluzeey
Copy link
Contributor

bluzeey commented Feb 5, 2025

Picking this up @amrutha97 .

@devilkiller-ag
Copy link

Hi @bluzeey, are you still working on this? Or can I take this issue?

carlosnid1 added a commit to carlosnid1/preswald that referenced this issue Feb 14, 2025
@carlosnid1 carlosnid1 linked a pull request Feb 14, 2025 that will close this issue
12 tasks
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 a pull request may close this issue.

3 participants