Skip to content

Commit 5c96ce4

Browse files
authored
fix: use svg renderer and support enum charts (#5846)
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR fixes any issues, list them here by number (e.g., Fixes #123). --> Better resolution vega spec in tables <img width="220" height="211" alt="CleanShot 2025-07-31 at 11 30 40" src="https://github.com/user-attachments/assets/1e94aeaf-a1d3-4fba-90f1-42f9ed86fe91" /> And enum charts (polars) don't raise an error anymore for chart explorer. ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [x] I have added tests for the changes made. - [x] I have run the code and verified that it works as expected.
1 parent 52d80a9 commit 5c96ce4

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

frontend/src/components/data-table/column-summary/column-summary.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const TableColumnSummary = <TData, TValue>({
4747
spec={spec}
4848
width={70}
4949
height={30}
50+
renderer="svg"
5051
// @ts-expect-error - Our `loader.load` method is broader than VegaLite's typings but is functionally supported.
5152
loader={batchedLoader}
5253
style={{ minWidth: "unset", maxHeight: "40px" }}

marimo/_data/preview_column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def _sanitize_dtypes(
336336
"""Sanitize dtypes for vegafusion"""
337337
try:
338338
dtype = column_data.schema[column_name]
339-
if dtype == nw.Categorical:
339+
if dtype == nw.Categorical or dtype == nw.Enum:
340340
column_data = column_data.with_columns(
341341
nw.col(column_name).cast(nw.String)
342342
)

tests/_data/test_preview_column.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,23 @@ def test_sanitize_dtypes() -> None:
493493

494494
result = _sanitize_dtypes(nw_df, "int128_col")
495495
assert result.schema["int128_col"] == nw.Int64
496+
497+
498+
@pytest.mark.skipif(
499+
not DependencyManager.narwhals.has(), reason="narwhals not installed"
500+
)
501+
@pytest.mark.xfail(reason="Sanitizing is failing") # TODO: Fix this
502+
def test_sanitize_dtypes_enum() -> None:
503+
import narwhals as nw
504+
import polars as pl
505+
506+
df = pl.DataFrame(
507+
{
508+
"enum_col": ["A", "B", "A"],
509+
},
510+
schema={"enum_col": pl.Enum(["A", "B"])},
511+
)
512+
nw_df = nw.from_native(df)
513+
514+
result = _sanitize_dtypes(nw_df, "enum_col")
515+
assert result.schema["enum_col"] == nw.String

0 commit comments

Comments
 (0)