A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
docs: add table panels and chart builder docs (#5533)
Shahmir Varqha36486b522464
diff --git a/docs/_static/docs-chart-builder-table.mp4 b/docs/_static/docs-chart-builder-table.mp4new file mode 100644index 0000000000..a92a379a7cBinary files /dev/null and b/docs/_static/docs-chart-builder-table.mp4 differdiff --git a/docs/_static/docs-column-explorer-table.mp4 b/docs/_static/docs-column-explorer-table.mp4new file mode 100644index 0000000000..dd2decc9ceBinary files /dev/null and b/docs/_static/docs-column-explorer-table.mp4 differdiff --git a/docs/_static/docs-row-viewer-panel.gif b/docs/_static/docs-row-viewer-panel.gifdeleted file mode 100644index 94d75368cf..0000000000Binary files a/docs/_static/docs-row-viewer-panel.gif and /dev/null differdiff --git a/docs/_static/docs-row-viewer-panel.mp4 b/docs/_static/docs-row-viewer-panel.mp4new file mode 100644index 0000000000..58e98f80eaBinary files /dev/null and b/docs/_static/docs-row-viewer-panel.mp4 differdiff --git a/docs/guides/working_with_data/dataframes.md b/docs/guides/working_with_data/dataframes.mdindex 2b8e7116c9..69a2dd6dab 100644--- a/docs/guides/working_with_data/dataframes.md+++ b/docs/guides/working_with_data/dataframes.md@@ -247,19 +247,55 @@ table.value///-## Row viewer panel+## Dataframe panels-To inspect individual rows, you can toggle the Row viewer panel located at the bottom left of a table. While open, click on any row to view.+Dataframe outputs in marimo come with several panels to help you visualize, explore, and page through your data interactively. These panels are accessible via toggles at the bottom-left of a dataframe output. If you need further control, after opening a panel you can-For convenience, you can pin the panel to the side of your editor or toggle the focused cell feature, which ensures the value of the currently focused cell is displayed in the panel.+- **pin the panel** to the side of your editor for persistent access;+- **toggle focus** to automatically display the currently focused dataframe in the panel.++??? note++ Toggles are visible when editing notebooks (with `marimo edit ...`) but not when running notebooks as apps (with `marimo run ...`), except for the row viewer which is available in both.++### Row viewer panel<div align="center"><figure>-<img src="/_static/docs-row-viewer-panel.gif" width="100%" height="100%" alt="Row viewer panel demonstration (click the bottom left of the table to toggle)">-<figcaption>Open the row viewer panel to display data vertically</figcaption>+<video muted playsinline controls align="center" src="/_static/docs-row-viewer-panel.mp4">+</video></figure></div>+To inspect individual rows, open the **row viewer**. This presents a vertical view of the selected row.++- **Press `Space`** to select/deselect the current row+- **Use arrow keys** (`←` `→`) to navigate between rows+- **Click** on any row in the dataframe to view its data in the panel++### Column explorer panel++<div align="center">+<figure>+<video controls muted playsinline align="center" src="/_static/docs-column-explorer-table.mp4">+</video>+</figure>+</div>++To explore your data, open the **column explorer** where you can find summary statistics and charts for each column. Click the `+` button to add the chart code to a new cell.++This requires the `altair` package to be installed. For large dataframes, `vegafusion` is also needed to render charts. To use the generated Python code, enable vegafusion in your notebook:++```python+import altair++altair.data_transformers.enable("vegafusion")+```++### Chart builder++The chart builder toggle lets you rapidly develop charts using a GUI, while also generating Python code to insert in your notebook. Refer to the [chart builder guide](plotting.md#chart-builder) for more details.+## Example notebookFor a comprehensive example of using Polars with marimo, check out our [Polars example notebook](https://github.com/marimo-team/marimo/blob/main/examples/third_party/polars/polars_example.py).diff --git a/docs/guides/working_with_data/plotting.md b/docs/guides/working_with_data/plotting.mdindex 69fc6e3bf4..1e1f8ba230 100644--- a/docs/guides/working_with_data/plotting.md+++ b/docs/guides/working_with_data/plotting.md@@ -279,3 +279,22 @@ If you want to output the plot in the console area, use `plt.show()` orTo make matplotlib plots interactive, use[mo.mpl.interactive][marimo.mpl.interactive].(Matplotlib plots are not yet reactive.)++## Chart builder++marimo comes with a built-in chart builder that makes it easy to create plots specialized to your dataframes with just a few clicks. As you make your charts, marimo generates Python code that you can add to your notebook to save them.++You can toggle the chart builder with a button at the bottom-left of a dataframe output. This provides a GUI interface to create many kinds of plots, while also generating Python code.++<div align="center">+<figure>+<video controls muted playsinline align="center" src="/_static/docs-chart-builder-table.mp4">+</video>+</figure>+</div>++Charts are powered by [Vega-Lite](https://vega.github.io/vega-lite/). To save a chart, click the `+` button in the `Python code` tab to add the code to a new cell.++!!! note++ This feature is in active development. Please report any issues or feedback [here](https://github.com/marimo-team/marimo/issues).\ No newline at end of filediff --git a/frontend/src/components/data-table/charts/components/form-fields.tsx b/frontend/src/components/data-table/charts/components/form-fields.tsxindex 189050c4bb..eddc632ac1 100644--- a/frontend/src/components/data-table/charts/components/form-fields.tsx+++ b/frontend/src/components/data-table/charts/components/form-fields.tsx@@ -52,6 +52,7 @@ import {AGGREGATION_FNS,type AggregationFn,BIN_AGGREGATION,+ ChartType,COMBINED_TIME_UNITS,NONE_VALUE,SELECTABLE_DATA_TYPES,@@ -640,6 +641,10 @@ export const AggregationSelect = ({const availableAggregations =selectedDataType === "string" ? STRING_AGGREGATION_FNS : AGGREGATION_FNS;+ const { chartType } = useChartFormContext();+ // Heatmap already has binning as an option elsewhere+ const isBinningAllowed = chartType !== ChartType.HEATMAP;+const renderSubtitle = (text: string) => {return <span className="text-xs text-muted-foreground pr-10">{text}</span>;};@@ -711,6 +716,9 @@ export const AggregationSelect = ({);const selectItem = renderSelectItem(agg, Icon, subtitle);if (agg === BIN_AGGREGATION) {+ if (!isBinningAllowed) {+ return null;+ }return (<div key={agg}><SelectSeparator />diff --git a/marimo/_data/charts.py b/marimo/_data/charts.pyindex bb1c954b6a..1c300a1176 100644--- a/marimo/_data/charts.py+++ b/marimo/_data/charts.py@@ -205,7 +205,7 @@ class StringChartBuilder(ChartBuilder):def simple_altair_code(self, data: str, column: str) -> str:properties_config = (- """.properties(title="Top 10 {column}", width="container")"""+ f""".properties(title="Top 10 {column}", width="container")"""if self.should_limit_to_10_itemselse """.properties(width="container")""")diff --git a/tests/_data/snapshots/charts.txt b/tests/_data/snapshots/charts.txtindex 9e744d2f5a..784186345b 100644--- a/tests/_data/snapshots/charts.txt+++ b/tests/_data/snapshots/charts.txt@@ -184,7 +184,7 @@ _chart = (alt.Tooltip("count:Q", format=",.0f", title="Number of records"),],)- .properties(title="Top 10 {column}", width="container")+ .properties(title="Top 10 some_column", width="container").configure_view(stroke=None).configure_axis(grid=False))