@malloydata/render 0.0.1

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.
Files changed (66) hide show
  1. package/README.md +7 -0
  2. package/dist/data_styles.d.ts +181 -0
  3. package/dist/data_styles.js +15 -0
  4. package/dist/drill.d.ts +10 -0
  5. package/dist/drill.js +103 -0
  6. package/dist/html/bar_chart.d.ts +7 -0
  7. package/dist/html/bar_chart.js +48 -0
  8. package/dist/html/boolean.d.ts +5 -0
  9. package/dist/html/boolean.js +26 -0
  10. package/dist/html/bytes.d.ts +5 -0
  11. package/dist/html/bytes.js +26 -0
  12. package/dist/html/cartesian_chart.d.ts +7 -0
  13. package/dist/html/cartesian_chart.js +88 -0
  14. package/dist/html/chart.d.ts +21 -0
  15. package/dist/html/chart.js +105 -0
  16. package/dist/html/container.d.ts +21 -0
  17. package/dist/html/container.js +43 -0
  18. package/dist/html/currency.d.ts +5 -0
  19. package/dist/html/currency.js +32 -0
  20. package/dist/html/dashboard.d.ts +7 -0
  21. package/dist/html/dashboard.js +224 -0
  22. package/dist/html/date.d.ts +7 -0
  23. package/dist/html/date.js +38 -0
  24. package/dist/html/html_view.d.ts +23 -0
  25. package/dist/html/html_view.js +217 -0
  26. package/dist/html/image.d.ts +7 -0
  27. package/dist/html/image.js +34 -0
  28. package/dist/html/index.d.ts +1 -0
  29. package/dist/html/index.js +18 -0
  30. package/dist/html/json.d.ts +7 -0
  31. package/dist/html/json.js +31 -0
  32. package/dist/html/line_chart.d.ts +7 -0
  33. package/dist/html/line_chart.js +51 -0
  34. package/dist/html/link.d.ts +7 -0
  35. package/dist/html/link.js +35 -0
  36. package/dist/html/list.d.ts +9 -0
  37. package/dist/html/list.js +63 -0
  38. package/dist/html/list_detail.d.ts +5 -0
  39. package/dist/html/list_detail.js +23 -0
  40. package/dist/html/number.d.ts +6 -0
  41. package/dist/html/number.js +30 -0
  42. package/dist/html/percent.d.ts +5 -0
  43. package/dist/html/percent.js +26 -0
  44. package/dist/html/point_map.d.ts +8 -0
  45. package/dist/html/point_map.js +147 -0
  46. package/dist/html/scatter_chart.d.ts +7 -0
  47. package/dist/html/scatter_chart.js +51 -0
  48. package/dist/html/segment_map.d.ts +8 -0
  49. package/dist/html/segment_map.js +128 -0
  50. package/dist/html/shape_map.d.ts +10 -0
  51. package/dist/html/shape_map.js +171 -0
  52. package/dist/html/state_codes.d.ts +3 -0
  53. package/dist/html/state_codes.js +127 -0
  54. package/dist/html/table.d.ts +7 -0
  55. package/dist/html/table.js +111 -0
  56. package/dist/html/text.d.ts +8 -0
  57. package/dist/html/text.js +35 -0
  58. package/dist/html/utils.d.ts +18 -0
  59. package/dist/html/utils.js +175 -0
  60. package/dist/html/vega_spec.d.ts +18 -0
  61. package/dist/html/vega_spec.js +499 -0
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.js +19 -0
  64. package/dist/renderer.d.ts +21 -0
  65. package/dist/renderer.js +23 -0
  66. package/package.json +17 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLView = void 0;
16
+ var html_view_1 = require("./html_view");
17
+ Object.defineProperty(exports, "HTMLView", { enumerable: true, get: function () { return html_view_1.HTMLView; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ import { DataColumn } from "@malloydata/malloy";
2
+ import { Renderer } from "../renderer";
3
+ export declare class HTMLJSONRenderer implements Renderer {
4
+ private readonly document;
5
+ constructor(document: Document);
6
+ render(table: DataColumn): Promise<HTMLElement>;
7
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLJSONRenderer = void 0;
16
+ const utils_1 = require("./utils");
17
+ class HTMLJSONRenderer {
18
+ constructor(document) {
19
+ this.document = document;
20
+ }
21
+ async render(table) {
22
+ if (!table.isArray() && !table.isRecord()) {
23
+ (0, utils_1.createErrorElement)(this.document, "Invalid data for chart renderer.");
24
+ }
25
+ const element = this.document.createElement("pre");
26
+ element.appendChild(this.document.createTextNode(JSON.stringify(table.value, undefined, 2)));
27
+ return element;
28
+ }
29
+ }
30
+ exports.HTMLJSONRenderer = HTMLJSONRenderer;
31
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1,7 @@
1
+ import { DataColumn, Field } from "@malloydata/malloy";
2
+ import { HTMLCartesianChartRenderer } from "./cartesian_chart";
3
+ export declare class HTMLLineChartRenderer extends HTMLCartesianChartRenderer {
4
+ getMark(): "line";
5
+ getDataType(field: Field): "temporal" | "ordinal" | "quantitative" | "nominal";
6
+ getDataValue(data: DataColumn): Date | string | number | null;
7
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLLineChartRenderer = void 0;
16
+ const cartesian_chart_1 = require("./cartesian_chart");
17
+ class HTMLLineChartRenderer extends cartesian_chart_1.HTMLCartesianChartRenderer {
18
+ getMark() {
19
+ return "line";
20
+ }
21
+ getDataType(field) {
22
+ if (field.isAtomicField()) {
23
+ if (field.isDate() || field.isTimestamp()) {
24
+ return "temporal";
25
+ }
26
+ else if (field.isString()) {
27
+ return "nominal";
28
+ }
29
+ else if (field.isNumber()) {
30
+ return "quantitative";
31
+ }
32
+ }
33
+ throw new Error("Invalid field type for line chart.");
34
+ }
35
+ getDataValue(data) {
36
+ if (data.isNull()) {
37
+ return null;
38
+ }
39
+ else if (data.isTimestamp() ||
40
+ data.isDate() ||
41
+ data.isNumber() ||
42
+ data.isString()) {
43
+ return data.value;
44
+ }
45
+ else {
46
+ throw new Error("Invalid field type for line chart.");
47
+ }
48
+ }
49
+ }
50
+ exports.HTMLLineChartRenderer = HTMLLineChartRenderer;
51
+ //# sourceMappingURL=line_chart.js.map
@@ -0,0 +1,7 @@
1
+ import { DataColumn } from "@malloydata/malloy";
2
+ import { Renderer } from "../renderer";
3
+ export declare class HTMLLinkRenderer implements Renderer {
4
+ private readonly document;
5
+ constructor(document: Document);
6
+ render(data: DataColumn): Promise<HTMLElement>;
7
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLLinkRenderer = void 0;
16
+ const utils_1 = require("./utils");
17
+ class HTMLLinkRenderer {
18
+ constructor(document) {
19
+ this.document = document;
20
+ }
21
+ async render(data) {
22
+ if (data.isNull()) {
23
+ return (0, utils_1.createNullElement)(this.document);
24
+ }
25
+ if (!data.isString()) {
26
+ return (0, utils_1.createErrorElement)(this.document, "Invalid type for link renderer.");
27
+ }
28
+ const element = document.createElement("a");
29
+ element.href = data.value;
30
+ element.appendChild(this.document.createTextNode(data.value.replace(/\//g, "/\u200C")));
31
+ return element;
32
+ }
33
+ }
34
+ exports.HTMLLinkRenderer = HTMLLinkRenderer;
35
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1,9 @@
1
+ import { DataColumn, Field, Explore } from "@malloydata/malloy";
2
+ import { StyleDefaults } from "../data_styles";
3
+ import { ContainerRenderer } from "./container";
4
+ export declare class HTMLListRenderer extends ContainerRenderer {
5
+ protected childrenStyleDefaults: StyleDefaults;
6
+ getValueField(struct: Explore): Field;
7
+ getDetailField(_struct: Explore): Field | undefined;
8
+ render(table: DataColumn): Promise<HTMLElement>;
9
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLListRenderer = void 0;
16
+ const container_1 = require("./container");
17
+ const utils_1 = require("./utils");
18
+ class HTMLListRenderer extends container_1.ContainerRenderer {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.childrenStyleDefaults = {
22
+ size: "small",
23
+ };
24
+ }
25
+ getValueField(struct) {
26
+ return struct.intrinsicFields[0];
27
+ }
28
+ getDetailField(_struct) {
29
+ return undefined;
30
+ }
31
+ async render(table) {
32
+ if (!table.isArray()) {
33
+ return (0, utils_1.createErrorElement)(this.document, "Invalid data for chart renderer.");
34
+ }
35
+ if (table.rowCount === 0) {
36
+ return this.document.createElement("span");
37
+ }
38
+ const valueField = this.getValueField(table.field);
39
+ const detailField = this.getDetailField(table.field);
40
+ const element = this.document.createElement("span");
41
+ let isFirst = true;
42
+ for (const row of table) {
43
+ if (!isFirst) {
44
+ element.appendChild(this.document.createTextNode(", "));
45
+ }
46
+ isFirst = false;
47
+ const childRenderer = this.childRenderers[valueField.name];
48
+ const rendered = await childRenderer.render(row.cell(valueField));
49
+ element.appendChild(rendered);
50
+ if (detailField) {
51
+ const childRenderer = this.childRenderers[detailField.name];
52
+ await (0, utils_1.yieldTask)();
53
+ const rendered = await childRenderer.render(row.cell(detailField));
54
+ element.appendChild(this.document.createTextNode("("));
55
+ element.appendChild(rendered);
56
+ element.appendChild(this.document.createTextNode(")"));
57
+ }
58
+ }
59
+ return element;
60
+ }
61
+ }
62
+ exports.HTMLListRenderer = HTMLListRenderer;
63
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1,5 @@
1
+ import { Explore, Field } from "@malloydata/malloy";
2
+ import { HTMLListRenderer } from "./list";
3
+ export declare class HTMLListDetailRenderer extends HTMLListRenderer {
4
+ getDetailField(explore: Explore): Field | undefined;
5
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLListDetailRenderer = void 0;
16
+ const list_1 = require("./list");
17
+ class HTMLListDetailRenderer extends list_1.HTMLListRenderer {
18
+ getDetailField(explore) {
19
+ return explore.intrinsicFields[1];
20
+ }
21
+ }
22
+ exports.HTMLListDetailRenderer = HTMLListDetailRenderer;
23
+ //# sourceMappingURL=list_detail.js.map
@@ -0,0 +1,6 @@
1
+ import { DataColumn } from "@malloydata/malloy";
2
+ import { HTMLTextRenderer } from "./text";
3
+ export declare class HTMLNumberRenderer extends HTMLTextRenderer {
4
+ getNumber(data: DataColumn): number | null;
5
+ getText(data: DataColumn): string | null;
6
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLNumberRenderer = void 0;
16
+ const text_1 = require("./text");
17
+ class HTMLNumberRenderer extends text_1.HTMLTextRenderer {
18
+ getNumber(data) {
19
+ if (data.isNull()) {
20
+ return null;
21
+ }
22
+ return data.number.value;
23
+ }
24
+ getText(data) {
25
+ const num = this.getNumber(data);
26
+ return num === null ? num : num.toLocaleString();
27
+ }
28
+ }
29
+ exports.HTMLNumberRenderer = HTMLNumberRenderer;
30
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1,5 @@
1
+ import { DataColumn } from "@malloydata/malloy";
2
+ import { HTMLNumberRenderer } from "./number";
3
+ export declare class HTMLPercentRenderer extends HTMLNumberRenderer {
4
+ getText(data: DataColumn): string | null;
5
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLPercentRenderer = void 0;
16
+ const number_1 = require("./number");
17
+ class HTMLPercentRenderer extends number_1.HTMLNumberRenderer {
18
+ getText(data) {
19
+ const num = this.getNumber(data);
20
+ return num === null
21
+ ? num
22
+ : (num * 100).toLocaleString("en", { maximumFractionDigits: 2 }) + "%";
23
+ }
24
+ }
25
+ exports.HTMLPercentRenderer = HTMLPercentRenderer;
26
+ //# sourceMappingURL=percent.js.map
@@ -0,0 +1,8 @@
1
+ import * as lite from "vega-lite";
2
+ import { DataArray, DataColumn, Field } from "@malloydata/malloy";
3
+ import { HTMLChartRenderer } from "./chart";
4
+ export declare class HTMLPointMapRenderer extends HTMLChartRenderer {
5
+ getDataValue(data: DataColumn): string | number;
6
+ getDataType(field: Field): "ordinal" | "quantitative" | "nominal";
7
+ getVegaLiteSpec(data: DataArray): lite.TopLevelSpec;
8
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.HTMLPointMapRenderer = void 0;
19
+ const malloy_1 = require("@malloydata/malloy");
20
+ const states_10m_json_1 = __importDefault(require("us-atlas/states-10m.json"));
21
+ const chart_1 = require("./chart");
22
+ const utils_1 = require("./utils");
23
+ class HTMLPointMapRenderer extends chart_1.HTMLChartRenderer {
24
+ getDataValue(data) {
25
+ if (data.isNumber() || data.isString()) {
26
+ return data.value;
27
+ }
28
+ else if (data.isTimestamp() || data.isDate()) {
29
+ return (0, utils_1.timeToString)(data.value, data.field.timeframe || malloy_1.TimestampTimeframe.Second);
30
+ }
31
+ throw new Error("Invalid field type for point map chart.");
32
+ }
33
+ getDataType(field) {
34
+ if (field.isAtomicField()) {
35
+ if (field.isDate() || field.isTimestamp() || field.isString()) {
36
+ return "nominal";
37
+ }
38
+ else if (field.isNumber()) {
39
+ return "quantitative";
40
+ }
41
+ }
42
+ throw new Error("Invalid field type for point map.");
43
+ }
44
+ getVegaLiteSpec(data) {
45
+ if (data.isNull()) {
46
+ throw new Error("Expected struct value not to be null.");
47
+ }
48
+ const fields = data.field.intrinsicFields;
49
+ const latField = fields[0];
50
+ const lonField = fields[1];
51
+ const colorField = fields[2];
52
+ const sizeField = fields[3];
53
+ const shapeField = fields[4];
54
+ const colorType = colorField ? this.getDataType(colorField) : undefined;
55
+ const sizeType = sizeField ? this.getDataType(sizeField) : undefined;
56
+ const shapeType = shapeField ? this.getDataType(shapeField) : undefined;
57
+ const colorDef = colorField !== undefined
58
+ ? {
59
+ field: colorField.name,
60
+ type: colorType,
61
+ axis: { title: colorField.name },
62
+ scale: (0, utils_1.getColorScale)(colorType, false),
63
+ }
64
+ : undefined;
65
+ const sizeDef = sizeField
66
+ ? {
67
+ field: sizeField.name,
68
+ type: sizeType,
69
+ axis: { title: sizeField.name },
70
+ }
71
+ : { value: 5 };
72
+ const shapeDef = shapeField
73
+ ? {
74
+ field: shapeField.name,
75
+ type: shapeType,
76
+ axis: { title: shapeField.name },
77
+ }
78
+ : { value: "circle" };
79
+ return {
80
+ ...this.getSize(),
81
+ data: {
82
+ values: this.mapData(data),
83
+ },
84
+ projection: {
85
+ type: "albersUsa",
86
+ },
87
+ layer: [
88
+ {
89
+ data: {
90
+ values: states_10m_json_1.default,
91
+ format: {
92
+ type: "topojson",
93
+ feature: "states",
94
+ },
95
+ },
96
+ mark: {
97
+ type: "geoshape",
98
+ fill: "#efefef",
99
+ stroke: "white",
100
+ },
101
+ },
102
+ {
103
+ mark: "point",
104
+ encoding: {
105
+ latitude: { field: latField.name, type: "quantitative" },
106
+ longitude: { field: lonField.name, type: "quantitative" },
107
+ size: sizeDef,
108
+ color: colorDef,
109
+ shape: shapeDef,
110
+ },
111
+ },
112
+ ],
113
+ background: "transparent",
114
+ config: {
115
+ axis: {
116
+ labelFont: "var(--malloy-font-family, Roboto)",
117
+ titleFont: "var(--malloy-font-family, Roboto)",
118
+ titleFontWeight: 500,
119
+ titleColor: "var(--malloy-title-color, #505050)",
120
+ labelColor: "var(--malloy-label-color, #000000)",
121
+ titleFontSize: 12,
122
+ },
123
+ legend: {
124
+ labelFont: "var(--malloy-font-family, Roboto)",
125
+ titleFont: "var(--malloy-font-family, Roboto)",
126
+ titleFontWeight: 500,
127
+ titleColor: "var(--malloy-title-color, #505050)",
128
+ labelColor: "var(--malloy-label-color, #000000)",
129
+ titleFontSize: 12,
130
+ },
131
+ header: {
132
+ labelFont: "var(--malloy-font-family, Roboto)",
133
+ titleFont: "var(--malloy-font-family, Roboto)",
134
+ titleFontWeight: 500,
135
+ },
136
+ mark: { font: "var(--malloy-Roboto" },
137
+ title: {
138
+ font: "var(--malloy-font-family, Roboto)",
139
+ subtitleFont: "var(--malloy-font-family, Roboto)",
140
+ fontWeight: 500,
141
+ },
142
+ },
143
+ };
144
+ }
145
+ }
146
+ exports.HTMLPointMapRenderer = HTMLPointMapRenderer;
147
+ //# sourceMappingURL=point_map.js.map
@@ -0,0 +1,7 @@
1
+ import { DataColumn, Field } from "@malloydata/malloy";
2
+ import { HTMLCartesianChartRenderer } from "./cartesian_chart";
3
+ export declare class HTMLScatterChartRenderer extends HTMLCartesianChartRenderer {
4
+ getMark(): "point";
5
+ getDataType(field: Field): "temporal" | "ordinal" | "quantitative" | "nominal";
6
+ getDataValue(data: DataColumn): Date | string | number | null;
7
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * version 2 as published by the Free Software Foundation.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HTMLScatterChartRenderer = void 0;
16
+ const cartesian_chart_1 = require("./cartesian_chart");
17
+ class HTMLScatterChartRenderer extends cartesian_chart_1.HTMLCartesianChartRenderer {
18
+ getMark() {
19
+ return "point";
20
+ }
21
+ getDataType(field) {
22
+ if (field.isAtomicField()) {
23
+ if (field.isDate() || field.isTimestamp()) {
24
+ return "temporal";
25
+ }
26
+ else if (field.isString()) {
27
+ return "nominal";
28
+ }
29
+ else if (field.isNumber()) {
30
+ return "quantitative";
31
+ }
32
+ }
33
+ throw new Error("Invalid field type for scatter chart.");
34
+ }
35
+ getDataValue(data) {
36
+ if (data.isNull()) {
37
+ return null;
38
+ }
39
+ else if (data.isTimestamp() ||
40
+ data.isDate() ||
41
+ data.isNumber() ||
42
+ data.isString()) {
43
+ return data.value;
44
+ }
45
+ else {
46
+ throw new Error("Invalid field type for scatter chart.");
47
+ }
48
+ }
49
+ }
50
+ exports.HTMLScatterChartRenderer = HTMLScatterChartRenderer;
51
+ //# sourceMappingURL=scatter_chart.js.map
@@ -0,0 +1,8 @@
1
+ import * as lite from "vega-lite";
2
+ import { DataArray, DataColumn, Field } from "@malloydata/malloy";
3
+ import { HTMLChartRenderer } from "./chart";
4
+ export declare class HTMLSegmentMapRenderer extends HTMLChartRenderer {
5
+ getDataValue(data: DataColumn): string | number | null;
6
+ getDataType(field: Field): "ordinal" | "quantitative" | "nominal";
7
+ getVegaLiteSpec(data: DataArray): lite.TopLevelSpec;
8
+ }