@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,128 @@
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.HTMLSegmentMapRenderer = void 0;
19
+ const states_10m_json_1 = __importDefault(require("us-atlas/states-10m.json"));
20
+ const chart_1 = require("./chart");
21
+ const utils_1 = require("./utils");
22
+ class HTMLSegmentMapRenderer extends chart_1.HTMLChartRenderer {
23
+ getDataValue(data) {
24
+ if (data.isNull() || data.isNumber() || data.isString()) {
25
+ return data.value;
26
+ }
27
+ throw new Error("Invalid field type for segment map.");
28
+ }
29
+ getDataType(field) {
30
+ if (field.isAtomicField()) {
31
+ if (field.isString()) {
32
+ return "nominal";
33
+ }
34
+ else if (field.isNumber()) {
35
+ return "quantitative";
36
+ }
37
+ // TODO dates nominal?
38
+ }
39
+ throw new Error("Invalid field type for segment map.");
40
+ }
41
+ getVegaLiteSpec(data) {
42
+ if (data.isNull()) {
43
+ throw new Error("Expected struct value not to be null.");
44
+ }
45
+ const fields = data.field.intrinsicFields;
46
+ const lat1Field = fields[0];
47
+ const lon1Field = fields[1];
48
+ const lat2Field = fields[2];
49
+ const lon2Field = fields[3];
50
+ const colorField = fields[4];
51
+ const colorType = colorField ? this.getDataType(colorField) : undefined;
52
+ const colorDef = colorField !== undefined
53
+ ? {
54
+ field: colorField.name,
55
+ type: colorType,
56
+ axis: { title: colorField.name },
57
+ scale: (0, utils_1.getColorScale)(colorType, false),
58
+ }
59
+ : undefined;
60
+ return {
61
+ ...this.getSize(),
62
+ data: {
63
+ values: this.mapData(data),
64
+ },
65
+ projection: {
66
+ type: "albersUsa",
67
+ },
68
+ layer: [
69
+ {
70
+ data: {
71
+ values: states_10m_json_1.default,
72
+ format: {
73
+ type: "topojson",
74
+ feature: "states",
75
+ },
76
+ },
77
+ mark: {
78
+ type: "geoshape",
79
+ fill: "lightgray",
80
+ stroke: "white",
81
+ },
82
+ },
83
+ {
84
+ mark: "line",
85
+ encoding: {
86
+ latitude: { field: lat1Field.name, type: "quantitative" },
87
+ longitude: { field: lon1Field.name, type: "quantitative" },
88
+ latitude2: { field: lat2Field.name, type: "quantitative" },
89
+ longitude2: { field: lon2Field.name, type: "quantitative" },
90
+ color: colorDef,
91
+ },
92
+ },
93
+ ],
94
+ background: "transparent",
95
+ config: {
96
+ axis: {
97
+ labelFont: "var(--malloy-font-family, Roboto)",
98
+ titleFont: "var(--malloy-font-family, Roboto)",
99
+ titleFontWeight: 500,
100
+ titleColor: "var(--malloy-title-color, #505050)",
101
+ labelColor: "var(--malloy-label-color, #000000)",
102
+ titleFontSize: 12,
103
+ },
104
+ legend: {
105
+ labelFont: "var(--malloy-font-family, Roboto)",
106
+ titleFont: "var(--malloy-font-family, Roboto)",
107
+ titleFontWeight: 500,
108
+ titleColor: "var(--malloy-title-color, #505050)",
109
+ labelColor: "var(--malloy-label-color, #000000)",
110
+ titleFontSize: 12,
111
+ },
112
+ header: {
113
+ labelFont: "var(--malloy-font-family, Roboto)",
114
+ titleFont: "var(--malloy-font-family, Roboto)",
115
+ titleFontWeight: 500,
116
+ },
117
+ mark: { font: "var(--malloy-font-family, Roboto)" },
118
+ title: {
119
+ font: "var(--malloy-font-family, Roboto)",
120
+ subtitleFont: "var(--malloy-font-family, Roboto)",
121
+ fontWeight: 500,
122
+ },
123
+ },
124
+ };
125
+ }
126
+ }
127
+ exports.HTMLSegmentMapRenderer = HTMLSegmentMapRenderer;
128
+ //# sourceMappingURL=segment_map.js.map
@@ -0,0 +1,10 @@
1
+ import * as lite from "vega-lite";
2
+ import { DataColumn, Field } from "@malloydata/malloy";
3
+ import { HTMLChartRenderer } from "./chart";
4
+ export declare class HTMLShapeMapRenderer extends HTMLChartRenderer {
5
+ private getRegionField;
6
+ private getColorField;
7
+ getDataValue(data: DataColumn): string | number | undefined;
8
+ getDataType(field: Field): "ordinal" | "quantitative" | "nominal";
9
+ getVegaLiteSpec(data: DataColumn): lite.TopLevelSpec;
10
+ }
@@ -0,0 +1,171 @@
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.HTMLShapeMapRenderer = void 0;
19
+ const states_10m_json_1 = __importDefault(require("us-atlas/states-10m.json"));
20
+ const chart_1 = require("./chart");
21
+ const state_codes_1 = require("./state_codes");
22
+ const utils_1 = require("./utils");
23
+ class HTMLShapeMapRenderer extends chart_1.HTMLChartRenderer {
24
+ getRegionField(explore) {
25
+ return explore.intrinsicFields[0];
26
+ }
27
+ getColorField(explore) {
28
+ return explore.intrinsicFields[1];
29
+ }
30
+ getDataValue(data) {
31
+ if (data.isNumber()) {
32
+ return data.value;
33
+ }
34
+ else if (data.isString()) {
35
+ if (data.field === this.getRegionField(data.field.parentExplore)) {
36
+ const id = state_codes_1.STATE_CODES[data.value];
37
+ if (id === undefined) {
38
+ return undefined;
39
+ }
40
+ return id;
41
+ }
42
+ else {
43
+ return data.value;
44
+ }
45
+ }
46
+ else if (data.isNull()) {
47
+ // ignore nulls
48
+ return undefined;
49
+ }
50
+ else {
51
+ throw new Error("Invalid field type for shape map.");
52
+ }
53
+ }
54
+ getDataType(field) {
55
+ if (field.isAtomicField()) {
56
+ if (field.isDate() || field.isTimestamp()) {
57
+ return "nominal";
58
+ }
59
+ else if (field.isString()) {
60
+ if (field === this.getRegionField(field.parentExplore)) {
61
+ return "quantitative";
62
+ }
63
+ else {
64
+ return "nominal";
65
+ }
66
+ }
67
+ else if (field.isNumber()) {
68
+ return "quantitative";
69
+ }
70
+ }
71
+ throw new Error("Invalid field type for shape map.");
72
+ }
73
+ getVegaLiteSpec(data) {
74
+ if (data.isNull()) {
75
+ throw new Error("Expected struct value not to be null.");
76
+ }
77
+ if (!data.isArray()) {
78
+ throw new Error("Invalid data for shape map");
79
+ }
80
+ const regionField = this.getRegionField(data.field);
81
+ const colorField = this.getColorField(data.field);
82
+ const colorType = colorField ? this.getDataType(colorField) : undefined;
83
+ const colorDef = colorField !== undefined
84
+ ? {
85
+ field: colorField.name,
86
+ type: colorType,
87
+ axis: { title: colorField.name },
88
+ scale: (0, utils_1.getColorScale)(colorType, false),
89
+ }
90
+ : undefined;
91
+ const mapped = this.mapData(data).filter((row) => row[regionField.name] !== undefined);
92
+ return {
93
+ ...this.getSize(),
94
+ data: { values: mapped },
95
+ projection: {
96
+ type: "albersUsa",
97
+ },
98
+ layer: [
99
+ {
100
+ data: {
101
+ values: states_10m_json_1.default,
102
+ format: {
103
+ type: "topojson",
104
+ feature: "states",
105
+ },
106
+ },
107
+ mark: {
108
+ type: "geoshape",
109
+ fill: "#efefef",
110
+ stroke: "white",
111
+ },
112
+ },
113
+ {
114
+ transform: [
115
+ {
116
+ lookup: regionField.name,
117
+ from: {
118
+ data: {
119
+ values: states_10m_json_1.default,
120
+ format: {
121
+ type: "topojson",
122
+ feature: "states",
123
+ },
124
+ },
125
+ key: "id",
126
+ },
127
+ as: "geo",
128
+ },
129
+ ],
130
+ mark: "geoshape",
131
+ encoding: {
132
+ shape: { field: "geo", type: "geojson" },
133
+ color: colorDef,
134
+ },
135
+ },
136
+ ],
137
+ background: "transparent",
138
+ config: {
139
+ axis: {
140
+ labelFont: "var(--malloy-font-family, Roboto)",
141
+ titleFont: "var(--malloy-font-family, Roboto)",
142
+ titleFontWeight: 500,
143
+ titleColor: "var(--malloy-title-color, #505050)",
144
+ labelColor: "var(--malloy-label-color, #000000)",
145
+ titleFontSize: 12,
146
+ },
147
+ legend: {
148
+ labelFont: "var(--malloy-font-family, Roboto)",
149
+ titleFont: "var(--malloy-font-family, Roboto)",
150
+ titleFontWeight: 500,
151
+ titleColor: "var(--malloy-title-color, #505050)",
152
+ labelColor: "var(--malloy-label-color, #000000)",
153
+ titleFontSize: 12,
154
+ },
155
+ header: {
156
+ labelFont: "var(--malloy-font-family, Roboto)",
157
+ titleFont: "var(--malloy-font-family, Roboto)",
158
+ titleFontWeight: 500,
159
+ },
160
+ mark: { font: "var(--malloy-font-family, Roboto)" },
161
+ title: {
162
+ font: "var(--malloy-font-family, Roboto)",
163
+ subtitleFont: "var(--malloy-font-family, Roboto)",
164
+ fontWeight: 500,
165
+ },
166
+ },
167
+ };
168
+ }
169
+ }
170
+ exports.HTMLShapeMapRenderer = HTMLShapeMapRenderer;
171
+ //# sourceMappingURL=shape_map.js.map
@@ -0,0 +1,3 @@
1
+ export declare const STATE_CODES: {
2
+ [code: string]: string;
3
+ };
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STATE_CODES = void 0;
4
+ /*
5
+ * Copyright 2021 Google LLC
6
+ *
7
+ * This program is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU General Public License
9
+ * version 2 as published by the Free Software Foundation.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ */
16
+ // force a branch
17
+ exports.STATE_CODES = {
18
+ AL: "01",
19
+ Alabama: "01",
20
+ AK: "02",
21
+ Alaska: "02",
22
+ AZ: "04",
23
+ Arizona: "04",
24
+ AR: "05",
25
+ Arkansas: "05",
26
+ CA: "06",
27
+ California: "06",
28
+ CO: "08",
29
+ Colorado: "08",
30
+ CT: "09",
31
+ Connecticut: "09",
32
+ DE: "10",
33
+ Delaware: "10",
34
+ DC: "11",
35
+ "District of Columbia": "11",
36
+ FL: "12",
37
+ Florida: "12",
38
+ GA: "13",
39
+ Georgia: "13",
40
+ HI: "15",
41
+ Hawaii: "12",
42
+ ID: "16",
43
+ Idaho: "16",
44
+ IL: "17",
45
+ Illinois: "17",
46
+ IN: "18",
47
+ Indiana: "18",
48
+ IA: "19",
49
+ Iowa: "19",
50
+ KS: "20",
51
+ Kansas: "20",
52
+ KY: "21",
53
+ Kentucky: "21",
54
+ LA: "22",
55
+ Louisiana: "22",
56
+ ME: "23",
57
+ Maine: "23",
58
+ MD: "24",
59
+ Maryland: "24",
60
+ MA: "25",
61
+ Massachusetts: "25",
62
+ MI: "26",
63
+ Michigan: "26",
64
+ MN: "27",
65
+ Minnesota: "27",
66
+ MS: "28",
67
+ Mississippi: "28",
68
+ MO: "29",
69
+ Missouri: "29",
70
+ MT: "30",
71
+ Montana: "30",
72
+ NE: "31",
73
+ Nebraska: "31",
74
+ NV: "32",
75
+ Nevada: "32",
76
+ NH: "33",
77
+ "New Hampshire": "33",
78
+ NJ: "34",
79
+ "New Jersey": "34",
80
+ NM: "35",
81
+ "New Mexico": "35",
82
+ NY: "36",
83
+ "New York": "36",
84
+ NC: "37",
85
+ "North Carolina": "37",
86
+ ND: "38",
87
+ "North Dakota": "38",
88
+ OH: "39",
89
+ Ohio: "39",
90
+ OK: "40",
91
+ Oklahoma: "40",
92
+ OR: "41",
93
+ Oregon: "41",
94
+ PA: "42",
95
+ Pennsylvania: "42",
96
+ RI: "44",
97
+ "Rhode Island": "44",
98
+ SC: "45",
99
+ "South Carolina": "45",
100
+ SD: "46",
101
+ "South Dakota": "46",
102
+ TN: "47",
103
+ Tennessee: "47",
104
+ TX: "48",
105
+ Texas: "48",
106
+ UT: "49",
107
+ Utah: "49",
108
+ VT: "50",
109
+ Vermont: "50",
110
+ VA: "51",
111
+ Virginia: "51",
112
+ WA: "53",
113
+ Washington: "53",
114
+ WV: "54",
115
+ "West Virginia": "54",
116
+ WI: "55",
117
+ Wisconsin: "55",
118
+ WY: "56",
119
+ Wyoming: "56",
120
+ PR: "72",
121
+ "Puerto Rico": "72",
122
+ VI: "78",
123
+ AS: "60",
124
+ MP: "69",
125
+ GU: "66",
126
+ };
127
+ //# sourceMappingURL=state_codes.js.map
@@ -0,0 +1,7 @@
1
+ import { DataColumn } from "@malloydata/malloy";
2
+ import { StyleDefaults } from "../data_styles";
3
+ import { ContainerRenderer } from "./container";
4
+ export declare class HTMLTableRenderer extends ContainerRenderer {
5
+ protected childrenStyleDefaults: StyleDefaults;
6
+ render(table: DataColumn): Promise<HTMLElement>;
7
+ }
@@ -0,0 +1,111 @@
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.HTMLTableRenderer = void 0;
16
+ const drill_1 = require("../drill");
17
+ const container_1 = require("./container");
18
+ const number_1 = require("./number");
19
+ const utils_1 = require("./utils");
20
+ class HTMLTableRenderer extends container_1.ContainerRenderer {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.childrenStyleDefaults = {
24
+ size: "medium",
25
+ };
26
+ }
27
+ async render(table) {
28
+ if (!table.isArray() && !table.isRecord()) {
29
+ throw new Error("Invalid type for Table Renderer");
30
+ }
31
+ const header = this.document.createElement("tr");
32
+ table.field.intrinsicFields.forEach((field) => {
33
+ const name = field.name;
34
+ const childRenderer = this.childRenderers[name];
35
+ const isNumeric = childRenderer instanceof number_1.HTMLNumberRenderer;
36
+ const headerCell = this.document.createElement("th");
37
+ headerCell.style.cssText = `
38
+ padding: 8px;
39
+ color: var(--malloy-title-color, #505050);
40
+ border-bottom: 1px solid var(--malloy-border-color, #eaeaea);
41
+ text-align: ${isNumeric ? "right" : "left"};
42
+ `;
43
+ headerCell.innerHTML = name.replace(/_/g, "_&#8203;");
44
+ header.appendChild(headerCell);
45
+ });
46
+ if (this.options.isDrillingEnabled) {
47
+ const drillHeader = this.document.createElement("th");
48
+ drillHeader.style.cssText = `
49
+ padding: 8px;
50
+ color: var(--malloy-title-color, #505050);
51
+ border-bottom: 1px solid var(--malloy-border-color, #eaeaea);
52
+ width: 25px;
53
+ `;
54
+ header.appendChild(drillHeader);
55
+ }
56
+ const tableBody = this.document.createElement("tbody");
57
+ for (const row of table) {
58
+ const rowElement = this.document.createElement("tr");
59
+ for (const field of table.field.intrinsicFields) {
60
+ const childRenderer = this.childRenderers[field.name];
61
+ const isNumeric = childRenderer instanceof number_1.HTMLNumberRenderer;
62
+ await (0, utils_1.yieldTask)();
63
+ const rendered = await childRenderer.render(row.cell(field));
64
+ const cellElement = this.document.createElement("td");
65
+ cellElement.style.cssText = `
66
+ padding: ${childRenderer instanceof HTMLTableRenderer ? "0" : "8px"};
67
+ vertical-align: top;
68
+ border-bottom: 1px solid var(--malloy-border-color, #eaeaea);
69
+ ${isNumeric ? "text-align: right;" : ""}
70
+ `;
71
+ cellElement.appendChild(rendered);
72
+ rowElement.appendChild(cellElement);
73
+ }
74
+ if (this.options.isDrillingEnabled) {
75
+ const drillCell = this.document.createElement("td");
76
+ const drillIcon = (0, utils_1.createDrillIcon)(this.document);
77
+ drillCell.appendChild(drillIcon);
78
+ drillCell.style.cssText = `
79
+ padding: 8px;
80
+ vertical-align: top;
81
+ border-bottom: 1px solid var(--malloy-border-color, #eaeaea);
82
+ width: 25px;
83
+ cursor: pointer
84
+ `;
85
+ drillCell.onclick = () => {
86
+ if (this.options.onDrill) {
87
+ const { drillQuery, drillFilters } = (0, drill_1.getDrillQuery)(row);
88
+ this.options.onDrill(drillQuery, drillIcon, drillFilters);
89
+ }
90
+ };
91
+ rowElement.appendChild(drillCell);
92
+ }
93
+ tableBody.appendChild(rowElement);
94
+ }
95
+ const tableElement = this.document.createElement("table");
96
+ tableElement.style.cssText = `
97
+ border: 1px solid var(--malloy-border-color, #eaeaea);
98
+ vertical-align: top;
99
+ border-bottom: 1px solid var(--malloy-border-color, #eaeaea);
100
+ border-collapse: collapse;
101
+ width: 100%;
102
+ `;
103
+ const tableHead = this.document.createElement("thead");
104
+ tableHead.appendChild(header);
105
+ tableElement.appendChild(tableHead);
106
+ tableElement.appendChild(tableBody);
107
+ return tableElement;
108
+ }
109
+ }
110
+ exports.HTMLTableRenderer = HTMLTableRenderer;
111
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1,8 @@
1
+ import { DataColumn } from "@malloydata/malloy";
2
+ import { Renderer } from "../renderer";
3
+ export declare class HTMLTextRenderer implements Renderer {
4
+ private readonly document;
5
+ constructor(document: Document);
6
+ getText(data: DataColumn): string | null;
7
+ render(data: DataColumn): Promise<HTMLElement>;
8
+ }
@@ -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.HTMLTextRenderer = void 0;
16
+ const utils_1 = require("./utils");
17
+ class HTMLTextRenderer {
18
+ constructor(document) {
19
+ this.document = document;
20
+ }
21
+ getText(data) {
22
+ return `${data.value}`;
23
+ }
24
+ async render(data) {
25
+ const text = this.getText(data);
26
+ if (text === null) {
27
+ return (0, utils_1.createNullElement)(this.document);
28
+ }
29
+ const element = this.document.createElement("span");
30
+ element.appendChild(this.document.createTextNode(text));
31
+ return element;
32
+ }
33
+ }
34
+ exports.HTMLTextRenderer = HTMLTextRenderer;
35
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1,18 @@
1
+ import { DateTimeframe, TimestampTimeframe } from "@malloydata/malloy";
2
+ export declare function getColorScale(type: "temporal" | "ordinal" | "quantitative" | "nominal" | undefined, isRectMark: boolean, hasOverlappingText?: boolean): {
3
+ range: string[];
4
+ } | undefined;
5
+ export declare function timeToString(time: Date, timeframe: DateTimeframe | TimestampTimeframe): string;
6
+ /**
7
+ * Use this function to break up expensive computation over multiple tasks.
8
+ *
9
+ * @returns A promise, which when awaited, puts subsequent code in a separate task.
10
+ *
11
+ * This is useful for cases when expensive code needs to run "concurrently" with a
12
+ * rendering / UI task. Sprinkling in `yieldTask`s into a long task allows other
13
+ * tasks to run periodically.
14
+ */
15
+ export declare function yieldTask(): Promise<void>;
16
+ export declare function createErrorElement(document: Document, error: string | Error): HTMLElement;
17
+ export declare function createNullElement(document: Document): HTMLElement;
18
+ export declare function createDrillIcon(document: Document): HTMLElement;