@marimo-team/islands 0.24.1-dev20 → 0.24.1-dev21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedDataExplorerComponent-BUC1MrsF.js → ConnectedDataExplorerComponent-yEsovh7C.js} +4 -4
- package/dist/{chat-ui-ChBRy1iT.js → chat-ui-dZ0mdOG3.js} +2 -2
- package/dist/{common-3k3erMZf.js → common-DhYGWkNU.js} +13 -7
- package/dist/{formats-Dz0QNUEa.js → formats-BZtMpeQe.js} +1 -1
- package/dist/{glide-data-editor-BI2i_IEE.js → glide-data-editor-BcvvJTCH.js} +2 -0
- package/dist/{html-to-image-BtNr4zrO.js → html-to-image-p-mxZ3_V.js} +2332 -2310
- package/dist/{loader-DTnbNSVZ.js → loader-Chm6nOqy.js} +1 -1
- package/dist/main.js +13 -12
- package/dist/{process-output-Dch8KCi8.js → process-output-Bh4xztNq.js} +1 -1
- package/dist/{react-vega-zyfTF9SY.js → react-vega-BE2Uv1cq.js} +1 -1
- package/dist/{reveal-component-CCuZFOFo.js → reveal-component-BzecpV7i.js} +4 -4
- package/dist/{spec-BL1GSUUF.js → spec-DR1CyTOo.js} +2 -0
- package/dist/style.css +1 -1
- package/dist/{vega-component-CioKuDut.js → vega-component-CTiCS_5w.js} +4 -4
- package/dist/{vega-embed-container-BRjjqRGz.js → vega-embed-container-B1tc-DoN.js} +2 -2
- package/dist/{vega-loader.browser-CGb-2Kwi.js → vega-loader.browser-VFQfHaoV.js} +1 -1
- package/package.json +1 -1
- package/src/components/data-table/__tests__/column_formatting.test.ts +7 -0
- package/src/components/data-table/charts/__tests__/schemas.test.ts +17 -2
- package/src/components/data-table/charts/chart-spec/types.ts +2 -0
- package/src/components/data-table/column-formatting/feature.ts +1 -0
- package/src/components/data-table/column-formatting/types.ts +1 -0
- package/src/components/data-table/column-summary/chart-spec-model.tsx +1 -0
- package/src/components/data-table/column-summary/column-summary.tsx +1 -0
- package/src/components/data-table/columns.tsx +4 -3
- package/src/components/datasets/__tests__/icons.test.ts +10 -2
- package/src/components/datasets/icons.tsx +4 -0
- package/src/components/datasources/__tests__/components.test.tsx +14 -1
- package/src/core/codemirror/language/languages/sql/__tests__/renderers.test.tsx +15 -4
- package/src/core/codemirror/language/languages/sql/renderers.tsx +1 -0
- package/src/core/kernel/messages.ts +1 -0
- package/src/plugins/impl/__tests__/DataEditorPlugin.test.ts +13 -1
- package/src/plugins/impl/data-editor/glide-data-editor.tsx +1 -0
- package/src/plugins/impl/data-editor/glide-utils.ts +1 -0
- package/src/plugins/impl/data-frames/__tests__/schema.test.ts +9 -1
- package/src/plugins/impl/data-frames/utils/__tests__/operators.test.ts +8 -0
- package/src/plugins/impl/data-frames/utils/operators.ts +1 -1
- package/src/plugins/impl/vega/__tests__/vega.test.ts +22 -4
- package/src/plugins/impl/vega/utils.ts +3 -0
|
@@ -12,10 +12,10 @@ import { t as debounce_default } from "./debounce-D784bpms.js";
|
|
|
12
12
|
import { A as useEvent_default, n as useTheme } from "./useTheme-BzEXeAR5.js";
|
|
13
13
|
import { s as uniq } from "./arrays-C56grfjL.js";
|
|
14
14
|
import { t as Objects } from "./objects-UzwQd5gx.js";
|
|
15
|
-
import { a as isValid, i as AlertTitle, n as Alert, t as arrow } from "./formats-
|
|
16
|
-
import { A as getContainerWidth, n as formats } from "./vega-loader.browser-
|
|
17
|
-
import { a as tooltipHandler, n as vegaLoadData } from "./loader-
|
|
18
|
-
import { t as j } from "./react-vega-
|
|
15
|
+
import { a as isValid, i as AlertTitle, n as Alert, t as arrow } from "./formats-BZtMpeQe.js";
|
|
16
|
+
import { A as getContainerWidth, n as formats } from "./vega-loader.browser-VFQfHaoV.js";
|
|
17
|
+
import { a as tooltipHandler, n as vegaLoadData } from "./loader-Chm6nOqy.js";
|
|
18
|
+
import { t as j } from "./react-vega-BE2Uv1cq.js";
|
|
19
19
|
import "./defaultLocale-CMezyvMc.js";
|
|
20
20
|
import "./defaultLocale-DMZFeDB8.js";
|
|
21
21
|
import { t as useAsyncData } from "./useAsyncData-CDcbh-Qv.js";
|
|
@@ -2,8 +2,8 @@ import { o as __toESM } from "./chunk-Bfp04NdC.js";
|
|
|
2
2
|
import { t as require_react } from "./react-DhGsCS90.js";
|
|
3
3
|
import { t as require_compiler_runtime } from "./compiler-runtime-DsR6imPN.js";
|
|
4
4
|
import { t as require_jsx_runtime } from "./jsx-runtime-Dp_oQwaf.js";
|
|
5
|
-
import { A as getContainerWidth } from "./vega-loader.browser-
|
|
6
|
-
import { n as q } from "./react-vega-
|
|
5
|
+
import { A as getContainerWidth } from "./vega-loader.browser-VFQfHaoV.js";
|
|
6
|
+
import { n as q } from "./react-vega-BE2Uv1cq.js";
|
|
7
7
|
import "./defaultLocale-CMezyvMc.js";
|
|
8
8
|
import "./defaultLocale-DMZFeDB8.js";
|
|
9
9
|
import { t as useVegaContainerRemeasure } from "./use-vega-container-remeasure-B7OD7yUY.js";
|
|
@@ -410,7 +410,7 @@ function getContainerWidth(o) {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
function getVegaFieldTypes(F) {
|
|
413
|
-
return !F || Object.keys(F).length === 0 ? "auto" : Objects.mapValues(F, (o) => o === "date" || o === "time" ? "string" : o === "datetime" ? "date" : o);
|
|
413
|
+
return !F || Object.keys(F).length === 0 ? "auto" : Objects.mapValues(F, (o) => o === "geometry" || o === "date" || o === "time" ? "string" : o === "datetime" ? "date" : o);
|
|
414
414
|
}
|
|
415
415
|
var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13;
|
|
416
416
|
function objectConverter(o) {
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
prettyScientificNumber,
|
|
6
6
|
} from "@/utils/numbers";
|
|
7
7
|
import { applyFormat } from "../column-formatting/feature";
|
|
8
|
+
import { formatOptions } from "../column-formatting/types";
|
|
8
9
|
|
|
9
10
|
const locale = "en-US";
|
|
10
11
|
|
|
@@ -128,3 +129,9 @@ describe("applyFormat", () => {
|
|
|
128
129
|
).toBe(123);
|
|
129
130
|
});
|
|
130
131
|
});
|
|
132
|
+
|
|
133
|
+
describe("formatOptions", () => {
|
|
134
|
+
it("has no geometry format options", () => {
|
|
135
|
+
expect(formatOptions.geometry).toEqual([]);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -14,7 +14,7 @@ describe("ChartSchema", () => {
|
|
|
14
14
|
|
|
15
15
|
it("normalizes an unrecognized axis column type", () => {
|
|
16
16
|
const result = ChartSchema.parse({
|
|
17
|
-
general: { xColumn: { field: "geom", type: "
|
|
17
|
+
general: { xColumn: { field: "geom", type: "bogus_type" } },
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
expect(result.general?.xColumn?.type).toBe("unknown");
|
|
@@ -24,7 +24,7 @@ describe("ChartSchema", () => {
|
|
|
24
24
|
const result = ChartSchema.parse({
|
|
25
25
|
tooltips: {
|
|
26
26
|
auto: false,
|
|
27
|
-
fields: [{ field: "geom", type: "
|
|
27
|
+
fields: [{ field: "geom", type: "bogus_type" }],
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -32,4 +32,19 @@ describe("ChartSchema", () => {
|
|
|
32
32
|
{ field: "geom", type: "unknown" },
|
|
33
33
|
]);
|
|
34
34
|
});
|
|
35
|
+
|
|
36
|
+
it("keeps geometry axis and tooltip field types", () => {
|
|
37
|
+
const result = ChartSchema.parse({
|
|
38
|
+
general: { xColumn: { field: "geom", type: "geometry" } },
|
|
39
|
+
tooltips: {
|
|
40
|
+
auto: false,
|
|
41
|
+
fields: [{ field: "geom", type: "geometry" }],
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(result.general?.xColumn?.type).toBe("geometry");
|
|
46
|
+
expect(result.tooltips?.fields).toEqual([
|
|
47
|
+
{ field: "geom", type: "geometry" },
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
35
50
|
});
|
|
@@ -29,6 +29,7 @@ export function convertDataTypeToVega(
|
|
|
29
29
|
return "quantitative";
|
|
30
30
|
case "string":
|
|
31
31
|
case "boolean":
|
|
32
|
+
case "geometry":
|
|
32
33
|
case "unknown":
|
|
33
34
|
return "nominal";
|
|
34
35
|
case "date":
|
|
@@ -51,6 +52,7 @@ export function convertDataTypeToSelectable(
|
|
|
51
52
|
return "number";
|
|
52
53
|
case "string":
|
|
53
54
|
case "boolean":
|
|
55
|
+
case "geometry":
|
|
54
56
|
case "unknown":
|
|
55
57
|
return "string";
|
|
56
58
|
case "date":
|
|
@@ -13,6 +13,7 @@ export const formatOptions = {
|
|
|
13
13
|
number: ["Auto", "Percent", "Scientific", "Engineering", "Integer"],
|
|
14
14
|
string: ["Uppercase", "Lowercase", "Capitalize", "Title"],
|
|
15
15
|
boolean: ["Yes/No", "On/Off"],
|
|
16
|
+
geometry: [],
|
|
16
17
|
unknown: [],
|
|
17
18
|
} as const satisfies Record<DataType, string[]>;
|
|
18
19
|
|
|
@@ -320,9 +320,8 @@ export function generateColumns<T>({
|
|
|
320
320
|
},
|
|
321
321
|
// Remove any default filtering
|
|
322
322
|
filterFn: undefined,
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
enableSorting: !!key,
|
|
323
|
+
// Unnamed index columns and geometry columns are not sortable
|
|
324
|
+
enableSorting: !!key && getMeta(key).dataType !== "geometry",
|
|
326
325
|
meta: {
|
|
327
326
|
...getMeta(key),
|
|
328
327
|
width: columnWidths?.[key],
|
|
@@ -485,6 +484,8 @@ function getFilterTypeForFieldType(
|
|
|
485
484
|
return "time";
|
|
486
485
|
case "boolean":
|
|
487
486
|
return "boolean";
|
|
487
|
+
case "geometry":
|
|
488
|
+
return undefined;
|
|
488
489
|
default:
|
|
489
490
|
return undefined;
|
|
490
491
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import type { DataType } from "@/core/kernel/messages";
|
|
5
|
-
import { DATA_TYPE_ICON, resolveDataType } from "../icons";
|
|
5
|
+
import { DATA_TYPE_ICON, getDataTypeColor, resolveDataType } from "../icons";
|
|
6
6
|
|
|
7
7
|
describe("resolveDataType", () => {
|
|
8
8
|
it("passes through every mapped data type", () => {
|
|
@@ -12,7 +12,15 @@ describe("resolveDataType", () => {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it("resolves unmapped data types to unknown", () => {
|
|
15
|
-
expect(resolveDataType("
|
|
15
|
+
expect(resolveDataType("bogus_type" as DataType)).toBe("unknown");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("resolves geometry with its icon and color", () => {
|
|
19
|
+
expect(resolveDataType("geometry")).toBe("geometry");
|
|
20
|
+
expect(DATA_TYPE_ICON.geometry).toBeDefined();
|
|
21
|
+
expect(getDataTypeColor("geometry")).toBe(
|
|
22
|
+
"bg-(--cyan-4) dark:bg-(--cyan-5)",
|
|
23
|
+
);
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
it("resolves data types shadowing Object.prototype keys to unknown", () => {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CurlyBracesIcon,
|
|
8
8
|
HashIcon,
|
|
9
9
|
type LucideIcon,
|
|
10
|
+
MapPinIcon,
|
|
10
11
|
ToggleLeftIcon,
|
|
11
12
|
TypeIcon,
|
|
12
13
|
} from "lucide-react";
|
|
@@ -27,6 +28,7 @@ export const DATA_TYPE_ICON: Record<DataType | SelectableDataType, LucideIcon> =
|
|
|
27
28
|
number: HashIcon,
|
|
28
29
|
string: TypeIcon,
|
|
29
30
|
integer: HashIcon,
|
|
31
|
+
geometry: MapPinIcon,
|
|
30
32
|
unknown: CurlyBracesIcon,
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -56,6 +58,8 @@ export function getDataTypeColor(
|
|
|
56
58
|
return "bg-(--purple-4)";
|
|
57
59
|
case "string":
|
|
58
60
|
return "bg-(--blue-4)";
|
|
61
|
+
case "geometry":
|
|
62
|
+
return "bg-(--cyan-4) dark:bg-(--cyan-5)";
|
|
59
63
|
case "unknown":
|
|
60
64
|
return "bg-(--slate-4) dark:bg-(--slate-6)";
|
|
61
65
|
default:
|
|
@@ -12,7 +12,7 @@ describe("ColumnName", () => {
|
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
14
|
const unrecognized = render(
|
|
15
|
-
<ColumnName columnName="geom" dataType={"
|
|
15
|
+
<ColumnName columnName="geom" dataType={"bogus_type" as DataType} />,
|
|
16
16
|
);
|
|
17
17
|
const unknown = render(
|
|
18
18
|
<ColumnName columnName="geom" dataType="unknown" />,
|
|
@@ -26,4 +26,17 @@ describe("ColumnName", () => {
|
|
|
26
26
|
warn.mockRestore();
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
+
|
|
30
|
+
it("renders geometry with a distinct icon", () => {
|
|
31
|
+
const geometry = render(
|
|
32
|
+
<ColumnName columnName="geom" dataType="geometry" />,
|
|
33
|
+
);
|
|
34
|
+
const unknown = render(<ColumnName columnName="geom" dataType="unknown" />);
|
|
35
|
+
|
|
36
|
+
expect(geometry.container.querySelector(".lucide-map-pin")).not.toBeNull();
|
|
37
|
+
expect(unknown.container.querySelector(".lucide-braces")).not.toBeNull();
|
|
38
|
+
expect(geometry.container.innerHTML).not.toEqual(
|
|
39
|
+
unknown.container.innerHTML,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
29
42
|
});
|
|
@@ -9,13 +9,18 @@ import type {
|
|
|
9
9
|
} from "@/core/kernel/messages";
|
|
10
10
|
import { renderColumnInfo, renderTableInfo } from "../renderers";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const bogusColumn = {
|
|
13
13
|
name: "geom",
|
|
14
|
-
type: "
|
|
14
|
+
type: "bogus_type" as DataType,
|
|
15
15
|
external_type: "geometry",
|
|
16
16
|
sample_values: [],
|
|
17
17
|
} as DataTableColumn;
|
|
18
18
|
|
|
19
|
+
const geometryColumn = {
|
|
20
|
+
...bogusColumn,
|
|
21
|
+
type: "geometry" as DataType,
|
|
22
|
+
} as DataTableColumn;
|
|
23
|
+
|
|
19
24
|
describe("SQL renderers", () => {
|
|
20
25
|
it("renders table information with an unrecognized column type", () => {
|
|
21
26
|
const table: DataTable = {
|
|
@@ -26,7 +31,7 @@ describe("SQL renderers", () => {
|
|
|
26
31
|
num_rows: null,
|
|
27
32
|
num_columns: 1,
|
|
28
33
|
variable_name: null,
|
|
29
|
-
columns: [
|
|
34
|
+
columns: [bogusColumn],
|
|
30
35
|
primary_keys: [],
|
|
31
36
|
indexes: [],
|
|
32
37
|
};
|
|
@@ -37,8 +42,14 @@ describe("SQL renderers", () => {
|
|
|
37
42
|
});
|
|
38
43
|
|
|
39
44
|
it("renders column information with an unrecognized column type", () => {
|
|
40
|
-
const result = render(renderColumnInfo(
|
|
45
|
+
const result = render(renderColumnInfo(bogusColumn));
|
|
41
46
|
|
|
42
47
|
expect(result.container.querySelector("svg")).not.toBeNull();
|
|
43
48
|
});
|
|
49
|
+
|
|
50
|
+
it("renders geometry column information with the map pin icon", () => {
|
|
51
|
+
const result = render(renderColumnInfo(geometryColumn));
|
|
52
|
+
|
|
53
|
+
expect(result.container.querySelector(".lucide-map-pin")).not.toBeNull();
|
|
54
|
+
});
|
|
44
55
|
});
|
|
@@ -41,6 +41,7 @@ const DATA_TYPE_COLORS: Record<DataType, string> = {
|
|
|
41
41
|
number: "bg-(--purple-4) text-(--purple-11)",
|
|
42
42
|
integer: "bg-(--purple-4) text-(--purple-11)",
|
|
43
43
|
string: "bg-(--blue-4) text-(--blue-11)",
|
|
44
|
+
geometry: "bg-(--cyan-4) text-(--cyan-11)",
|
|
44
45
|
unknown: "bg-(--slate-4) text-(--slate-11)",
|
|
45
46
|
};
|
|
46
47
|
|
|
@@ -9,10 +9,22 @@ describe("DataEditorPlugin", () => {
|
|
|
9
9
|
initialValue: { edits: [] },
|
|
10
10
|
label: null,
|
|
11
11
|
data: [],
|
|
12
|
-
fieldTypes: [["geom", ["
|
|
12
|
+
fieldTypes: [["geom", ["bogus_type", "geometry"]]],
|
|
13
13
|
editableColumns: "all",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
expect(result.fieldTypes).toEqual([["geom", ["unknown", "geometry"]]]);
|
|
17
17
|
});
|
|
18
|
+
|
|
19
|
+
it("keeps the geometry field type", () => {
|
|
20
|
+
const result = DataEditorPlugin.validator.parse({
|
|
21
|
+
initialValue: { edits: [] },
|
|
22
|
+
label: null,
|
|
23
|
+
data: [],
|
|
24
|
+
fieldTypes: [["geom", ["geometry", "geometry"]]],
|
|
25
|
+
editableColumns: "all",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(result.fieldTypes).toEqual([["geom", ["geometry", "geometry"]]]);
|
|
29
|
+
});
|
|
18
30
|
});
|
|
@@ -18,7 +18,7 @@ describe("columnToFieldTypesSchema", () => {
|
|
|
18
18
|
|
|
19
19
|
it("normalizes an unrecognized field type without discarding other fields", () => {
|
|
20
20
|
const result = columnToFieldTypesSchema.parse([
|
|
21
|
-
["geom", ["
|
|
21
|
+
["geom", ["bogus_type", "geometry"]],
|
|
22
22
|
["label", ["string", "object"]],
|
|
23
23
|
]);
|
|
24
24
|
|
|
@@ -27,4 +27,12 @@ describe("columnToFieldTypesSchema", () => {
|
|
|
27
27
|
["label", ["string", "object"]],
|
|
28
28
|
]);
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
it("keeps the geometry field type", () => {
|
|
32
|
+
const result = columnToFieldTypesSchema.parse([
|
|
33
|
+
["geom", ["geometry", "geometry"]],
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
expect(result).toEqual([["geom", ["geometry", "geometry"]]]);
|
|
37
|
+
});
|
|
30
38
|
});
|
|
@@ -60,6 +60,10 @@ describe("getOperatorForDtype", () => {
|
|
|
60
60
|
it("should return empty array for unknown dtype", () => {
|
|
61
61
|
expect(getOperatorForDtype("unknown")).toEqual([]);
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
it("should return no operators for geometry", () => {
|
|
65
|
+
expect(getOperatorForDtype("geometry")).toEqual([]);
|
|
66
|
+
});
|
|
63
67
|
});
|
|
64
68
|
|
|
65
69
|
describe("getSchemaForOperator", () => {
|
|
@@ -87,6 +91,10 @@ describe("getSchemaForOperator", () => {
|
|
|
87
91
|
expect(getSchemaForOperator("unknown", "==")).toEqual([]);
|
|
88
92
|
expect(getSchemaForOperator("int", "unknown")).toEqual([]);
|
|
89
93
|
});
|
|
94
|
+
|
|
95
|
+
it("should return no operand schema for geometry", () => {
|
|
96
|
+
expect(getSchemaForOperator("geometry", "==")).toEqual([]);
|
|
97
|
+
});
|
|
90
98
|
});
|
|
91
99
|
|
|
92
100
|
describe("isConditionValueValid", () => {
|
|
@@ -76,7 +76,7 @@ export const ALL_OPERATORS = {
|
|
|
76
76
|
|
|
77
77
|
export type OperatorType = keyof typeof ALL_OPERATORS;
|
|
78
78
|
|
|
79
|
-
function numpyTypeToDataType(type: string): DataType {
|
|
79
|
+
function numpyTypeToDataType(type: string): Exclude<DataType, "geometry"> {
|
|
80
80
|
if (!type) {
|
|
81
81
|
return "unknown";
|
|
82
82
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
vegaLoadData,
|
|
8
8
|
vegaLoader,
|
|
9
9
|
} from "../loader";
|
|
10
|
+
import { getVegaFieldTypes } from "../utils";
|
|
10
11
|
|
|
11
12
|
const { ZERO_WIDTH_SPACE, replacePeriodsInColumnNames, uniquifyColumnNames } =
|
|
12
13
|
exportedForTesting;
|
|
@@ -102,15 +103,32 @@ yield_error,yield_center
|
|
|
102
103
|
`);
|
|
103
104
|
});
|
|
104
105
|
|
|
105
|
-
it.each(DATA_TYPES)
|
|
106
|
-
|
|
106
|
+
it.each(DATA_TYPES.filter((type) => type !== "geometry"))(
|
|
107
|
+
"should handle %s data-type",
|
|
108
|
+
async (type) => {
|
|
109
|
+
const csvData = "name,value_column\nAlice,1";
|
|
110
|
+
vi.spyOn(vegaLoader, "load").mockReturnValue(Promise.resolve(csvData));
|
|
111
|
+
|
|
112
|
+
const result = await vegaLoadData(csvData, {
|
|
113
|
+
type: "csv",
|
|
114
|
+
parse: { value_column: type },
|
|
115
|
+
});
|
|
116
|
+
expect(result.length).toEqual(1);
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
it("should parse geometry as a WKT string", async () => {
|
|
121
|
+
const csvData = "name,value_column\nAlice,POINT (0 0)";
|
|
107
122
|
vi.spyOn(vegaLoader, "load").mockReturnValue(Promise.resolve(csvData));
|
|
108
123
|
|
|
124
|
+
const fieldTypes = getVegaFieldTypes({ value_column: "geometry" });
|
|
125
|
+
expect(fieldTypes).toEqual({ value_column: "string" });
|
|
126
|
+
|
|
109
127
|
const result = await vegaLoadData(csvData, {
|
|
110
128
|
type: "csv",
|
|
111
|
-
parse:
|
|
129
|
+
parse: fieldTypes,
|
|
112
130
|
});
|
|
113
|
-
expect(result
|
|
131
|
+
expect(result).toEqual([{ name: "Alice", value_column: "POINT (0 0)" }]);
|
|
114
132
|
});
|
|
115
133
|
|
|
116
134
|
it("should parse csv data with out of bound integers", async () => {
|
|
@@ -55,6 +55,9 @@ export function getVegaFieldTypes(
|
|
|
55
55
|
// the correct formatting. For example, a date like '2024-01-01' will
|
|
56
56
|
// be formatted to '2024-01-01T00:00:00.000Z'.
|
|
57
57
|
return Objects.mapValues(types, (type): VegaDataType => {
|
|
58
|
+
if (type === "geometry") {
|
|
59
|
+
return "string";
|
|
60
|
+
}
|
|
58
61
|
if (type === "date") {
|
|
59
62
|
return "string";
|
|
60
63
|
}
|