Skip to content

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.

chore(frontend): Remove "vega" as top-level dependency (#5453)

Trevor Manz82f97b363584
diff --git a/frontend/package.json b/frontend/package.json
index cfb83c66f9..8ca43dde92 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -150,7 +150,6 @@
"timestring": "^7.0.0",
"typescript-memoize": "^1.1.1",
"use-resize-observer": "^9.1.0",
- "vega": "^5.33.0",
"vega-lite": "^5.23.0",
"vega-loader": "^4.5.3",
"vscode-languageserver-protocol": "^3.17.5",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 290ed34f52..56daf2ac47 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -426,9 +426,6 @@ importers:
use-resize-observer:
specifier: ^9.1.0
- vega:
- specifier: ^5.33.0
- version: 5.33.0
vega-lite:
specifier: ^5.23.0
version: 5.23.0([email protected])
diff --git a/frontend/src/components/data-table/charts/chart-spec/encodings.ts b/frontend/src/components/data-table/charts/chart-spec/encodings.ts
index 5770817abb..922ef9db28 100644
--- a/frontend/src/components/data-table/charts/chart-spec/encodings.ts
+++ b/frontend/src/components/data-table/charts/chart-spec/encodings.ts
@@ -1,6 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-import type { ColorScheme } from "vega";
import type { Aggregate } from "vega-lite/build/src/aggregate";
import type { BinParams } from "vega-lite/build/src/bin";
import type { ColorDef, OffsetDef } from "vega-lite/build/src/channeldef";
@@ -12,6 +11,7 @@ import {
type AggregationFn,
BIN_AGGREGATION,
ChartType,
+ type ColorScheme,
NONE_AGGREGATION,
type SelectableDataType,
STRING_AGGREGATION_FNS,
diff --git a/frontend/src/components/data-table/charts/chart-spec/spec.ts b/frontend/src/components/data-table/charts/chart-spec/spec.ts
index ba372149cb..54b624bfb3 100644
--- a/frontend/src/components/data-table/charts/chart-spec/spec.ts
+++ b/frontend/src/components/data-table/charts/chart-spec/spec.ts
@@ -1,6 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-import type { ExprRef, SignalRef } from "vega";
import type { TopLevelSpec } from "vega-lite";
import type {
ColorDef,
@@ -164,7 +163,7 @@ export function getAxisEncoding(
export function getFacetEncoding(
facet: z.infer<typeof RowFacet> | z.infer<typeof ColumnFacet>,
chartType: ChartType,
-): FacetFieldDef<Field, ExprRef | SignalRef> {
+): FacetFieldDef<Field> {
const binValues = getBinEncoding(
chartType,
facet.selectedDataType || "string",
diff --git a/frontend/src/components/data-table/charts/constants.ts b/frontend/src/components/data-table/charts/constants.ts
index b830c0a977..b28684ce13 100644
--- a/frontend/src/components/data-table/charts/constants.ts
+++ b/frontend/src/components/data-table/charts/constants.ts
@@ -18,10 +18,10 @@ import {
SquareFunctionIcon,
TableIcon,
} from "lucide-react";
-import type { ColorScheme } from "vega";
import type {
AggregationFn,
ChartType,
+ ColorScheme,
SelectableDataType,
TimeUnit,
} from "./types";
diff --git a/frontend/src/components/data-table/charts/types.ts b/frontend/src/components/data-table/charts/types.ts
index a592b2a41f..3ede1226f2 100644
--- a/frontend/src/components/data-table/charts/types.ts
+++ b/frontend/src/components/data-table/charts/types.ts
@@ -1,4 +1,11 @@
/* Copyright 2024 Marimo. All rights reserved. */
+import type { Scale } from "vega-lite/build/src/scale";
+
+/**
+ * Valid string-based color scheme options from
+ * Vega-Lite `Scale["scheme"]` (aka `vega.ColorScheme`).
+ */
+export type ColorScheme = NonNullable<Scale["scheme"] & string>;
/**
* Similar to VegaLite's ScaleType, https://vega.github.io/vega-lite/docs/scale.html#type
diff --git a/frontend/src/components/tracing/tracing-spec.ts b/frontend/src/components/tracing/tracing-spec.ts
index ea1915e898..812b123c02 100644
--- a/frontend/src/components/tracing/tracing-spec.ts
+++ b/frontend/src/components/tracing/tracing-spec.ts
@@ -1,6 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-import type { TimeUnit } from "vega";
import type { TopLevelSpec } from "vega-lite";
import type { CellId } from "@/core/cells/ids";
import type { CellRun } from "@/core/cells/runs";
@@ -30,7 +29,7 @@ export function createGanttBaseSpec(
hiddenInputElementId: string,
chartPosition: ChartPosition,
theme: ResolvedTheme,
-): TopLevelSpec {
+): Readonly<TopLevelSpec> {
return {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
background: theme === "dark" ? "black" : undefined,
@@ -75,13 +74,15 @@ export function createGanttBaseSpec(
{
field: startTimestampField,
type: "temporal",
- timeUnit: "hoursminutessecondsmilliseconds" as TimeUnit,
+ // @ts-expect-error - Supported by vega/vega-lite but invalid "TimeUnit" option from exported type
+ timeUnit: "hoursminutessecondsmilliseconds",
title: "Start",
},
{
field: endTimestampField,
type: "temporal",
- timeUnit: "hoursminutessecondsmilliseconds" as TimeUnit,
+ // @ts-expect-error - Supported by vega/vega-lite but invalid "TimeUnit" option from exported type
+ timeUnit: "hoursminutessecondsmilliseconds",
title: "End",
},
],