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

feat: Add iframe/widget endpoint for displaying widgets #4938

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

mofojed
Copy link
Member

@mofojed mofojed commented Dec 12, 2023

  • Opens widgets from plugins (such as plotly-express) or any table just by name by adding the iframe/widget path
  • Exposed at /iframe/widget
  • Updated workflow to automatically update the version when new web packages are published
  • Tested by running the following code to create a plotly-express widget and some tables:
import deephaven.plot.express as dx
from deephaven import time_table
import random
import pandas as pd
import deephaven.pandas as dhpd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

t = dhpd.to_table(df)

sourceh = time_table("PT1S").update(formulas=[
    "X = (int)random.uniform(0, 180) - 90",
    "Y = (int)random.uniform(0, 360) - 180",
    "Z = (float)random.gauss(30, 3)",
    "l1 = i % 20",
    "l2 = i % 30",
    ])

fig = dx.density_mapbox(t,  lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
                        center=dict(lat=0, lon=180), zoom=0,
                        mapbox_style="stamen-terrain")
  • Then tested that each table/widget opened correctly by opening the following links:
  1. plot.express: http://localhost:10000/iframe/widget/?name=fig
  2. table: http://localhost:10000/iframe/widget/?name=t
  3. Pandas data frame: http://localhost:10000/iframe/widget/?name=df

- Opens widgets from plugins or any table just by name by adding the iframe/widget path
- Exposed at `/iframe/widget`
- Tested by running the following code to create a plotly-express widget and some tables:
```
import deephaven.plot.express as dx
from deephaven import time_table
import random
import pandas as pd
import deephaven.pandas as dhpd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

t = dhpd.to_table(df)

sourceh = time_table("PT1S").update(formulas=[
    "X = (int)random.uniform(0, 180) - 90",
    "Y = (int)random.uniform(0, 360) - 180",
    "Z = (float)random.gauss(30, 3)",
    "l1 = i % 20",
    "l2 = i % 30",
    ])

fig = dx.density_mapbox(t,  lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
                        center=dict(lat=0, lon=180), zoom=0,
                        mapbox_style="stamen-terrain")
```
- Then tested that each table/widget opened correctly by opening the following links:
1. plot.express: http://localhost:10000/iframe/widget/?name=fig
2. table: http://localhost:10000/iframe/widget/?name=t
3. Pandas data frame: http://localhost:10000/iframe/widget/?name=df
devinrsmith
devinrsmith previously approved these changes Dec 12, 2023
Copy link
Member

@devinrsmith devinrsmith left a comment

Choose a reason for hiding this comment

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

Is the plan to deprecate / remove /iframe/chart/ / /iframe/table/?

@mofojed
Copy link
Member Author

mofojed commented Dec 12, 2023

Need to add an example to the iframe documentation: https://deephaven.io/core/docs/how-to-guides/use-iframes/#display-tables-in-an-iframe

dsmmcken
dsmmcken previously approved these changes Dec 14, 2023
Copy link
Contributor

@dsmmcken dsmmcken left a comment

Choose a reason for hiding this comment

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

Yes, we should deprecate the table and chart paths, but only once we have proper code splitting for bundle size based on what's loaded.

@mofojed mofojed dismissed stale reviews from dsmmcken and devinrsmith via 91e3fe5 December 14, 2023 18:41
@mofojed mofojed enabled auto-merge (squash) December 14, 2023 18:41
@mofojed mofojed merged commit 13ea304 into deephaven:main Dec 15, 2023
19 checks passed
@mofojed mofojed deleted the embed-widget branch December 15, 2023 15:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2023
@deephaven-internal
Copy link
Contributor

Labels indicate documentation is required. Issues for documentation have been opened:

How-to: https://github.com/deephaven/deephaven.io/issues/3551
Reference: https://github.com/deephaven/deephaven.io/issues/3552

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants