marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
6.62k stars 225 forks source link

improvement: add .apply_selection() to mo.ui.altair_chart for layered/stacked charts #1557

Closed mscolnick closed 4 months ago

mscolnick commented 4 months ago

Adds .apply_selection to a altair_chart widget:

Apply the selection to a DataFrame.

This method is useful when you have a layered chart and you want to apply the selection to a DataFrame.

Example.

  import altair as alt
  import marimo as mo
  from vega_datasets import data

  cars = data.cars()

  _chart = (
      alt.Chart(cars)
      .mark_point()
      .encode(
          x="Horsepower",
          y="Miles_per_Gallon",
          color="Origin",
      )
  )

  chart = mo.ui.altair_chart(_chart)
  chart

  # In another cell
  selected_df = chart.apply_selection(cars)

Args.

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2024 8:53pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2024 8:53pm
github-actions[bot] commented 4 months ago

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.6.15-dev5