Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web-common/src/components/vega/VegaLiteRenderer.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import CancelCircle from "@rilldata/web-common/components/icons/CancelCircle.svelte";
import type { ColorMapping } from "@rilldata/web-common/features/canvas/inspector/types";
import { onDestroy } from "svelte";
import {
type SignalListeners,
Expand All @@ -23,7 +24,7 @@
export let theme: "light" | "dark" = "light";
export let config: Config | undefined = undefined;
export let tooltipFormatter: VLTooltipFormatter | undefined = undefined;
export let colorMapping: { value: string; color: string }[] = [];
export let colorMapping: ColorMapping = [];
export let viewVL: View;

let contentRect = new DOMRect(0, 0, 0, 0);
Expand Down
11 changes: 5 additions & 6 deletions web-common/src/components/vega/vega-embed-options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ColorMapping } from "@rilldata/web-common/features/canvas/inspector/types";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import type { EmbedOptions } from "svelte-vega";
import { get } from "svelte/store";
Expand All @@ -15,7 +16,7 @@ export interface CreateEmbedOptionsParams {
theme?: "light" | "dark";
expressionFunctions?: ExpressionFunction;
useExpressionInterpreter?: boolean;
colorMapping: { value: string; color: string }[];
colorMapping: ColorMapping;
}

export function createEmbedOptions({
Expand All @@ -36,7 +37,7 @@ export function createEmbedOptions({
renderer,
tooltip: {
theme: theme,
...(colorMapping.length
...(colorMapping?.length
? { formatTooltip: getTooltipFormatter(colorMapping) }
: {}),
},
Expand Down Expand Up @@ -64,14 +65,12 @@ export function createEmbedOptions({
};
}

export function getTooltipFormatter(
colorMapping: { value: string; color: string }[],
) {
export function getTooltipFormatter(colorMapping: ColorMapping) {
return (items: any, sanitize: (value: any) => string) => {
const rows = Object.entries(items)
.map(([key, val]) => {
if (val === undefined) return "";
const colorEntry = colorMapping.find(
const colorEntry = colorMapping?.find(
(mapping) => mapping.value === key,
);
const keyColor = colorEntry
Expand Down
Loading