marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Enable user copy rendering code from `mo.ui.data_explorer`

Open switchball opened this issue 1 year ago • 1 comments

Description

mo.ui.data_explorer provides awesome visualization about dataframe. I hope that i can copy the rendering code to another cell, so I can tweak, modify, or understand how it is implemented.

I guess the encoding and marks option on the left is a hint, but it is hard to understand for an altair-newbee like me.

Suggested solution

I suggest that a tab appears above the visualization, just like what mo.ui.dataframe does. image

More specifically, when user click code tab, the render code for main plot will be shown.

Alternative

No response

Additional context

No response

switchball avatar Sep 25 '24 09:09 switchball

This is doable and seems like a nice addition (thanks for the suggestion!)

We store the sidebar state (x, y, row, etc) in the value of the UI element. It should be fairly easy (frontend or backend) to auto-generated the altair snippet from those values.

We may not get to this at the moment, but open to contribution

mscolnick avatar Sep 26 '24 13:09 mscolnick

Picking this up next!

wasimxyz avatar Oct 10 '24 06:10 wasimxyz

@wasimsandhu - some design thoughts, feel free to take it or leave it: rather than a tab like we do with data-explorer, I think we can just add a Copy/Clipboard button with a tooltip "Copy as Altiar chart".

we would need to write some fairly simple string formatting to go from encodings -> altair chart. this could live in the frontend, but we should have really good unit tests for this

mscolnick avatar Oct 11 '24 10:10 mscolnick