@xplortech/apollo-data 0.0.4 → 0.0.6

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 (88) hide show
  1. package/README.md +15 -91
  2. package/dist/apollo-data/apollo-data.esm.js +1 -1
  3. package/dist/apollo-data/p-25841a73.entry.js +1 -0
  4. package/dist/apollo-data/p-2nuV5Vny.js +1 -0
  5. package/dist/apollo-data/p-839050b7.entry.js +1 -0
  6. package/dist/apollo-data/p-C2k3WBpi.js +11 -0
  7. package/dist/apollo-data/p-D64asVrg.js +2 -0
  8. package/dist/apollo-data/p-e2c3a317.entry.js +1 -0
  9. package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +315 -0
  10. package/dist/{esm/apollo-data-bar-chart_2.entry.js → cjs/apollo-data-base-COGMOEqL.js} +9 -724
  11. package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +408 -0
  12. package/dist/cjs/apollo-data-heat-map_4.cjs.entry.js +883 -0
  13. package/dist/cjs/apollo-data.cjs.js +3 -3
  14. package/dist/cjs/constants-B3weDEpc.js +5 -0
  15. package/dist/cjs/{index-Cl7HgRm0.js → index-Bd5risOy.js} +116 -63
  16. package/dist/cjs/loader.cjs.js +2 -2
  17. package/dist/collection/apollo-data-base.js +4 -8
  18. package/dist/collection/collection-manifest.json +7 -2
  19. package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +8 -7
  20. package/dist/collection/components/apollo-data-bar/apollo-data-bar.stories.js +122 -0
  21. package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +1 -1
  22. package/dist/collection/components/apollo-data-donut/apollo-data-donut.stories.js +132 -0
  23. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.js +208 -0
  24. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.stories.js +137 -0
  25. package/dist/collection/components/apollo-data-line/apollo-data-line.js +348 -0
  26. package/dist/collection/components/apollo-data-line/apollo-data-line.stories.js +122 -0
  27. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +329 -0
  28. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.stories.js +147 -0
  29. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.js +294 -0
  30. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.stories.js +126 -0
  31. package/dist/collection/examples/apollo-data-heat-map.examples.js +131 -0
  32. package/dist/collection/examples/apollo-data-line.examples.js +91 -0
  33. package/dist/collection/examples/apollo-data-scatter.examples.js +94 -0
  34. package/dist/collection/examples/apollo-data-world-map.examples.js +45 -0
  35. package/dist/collection/examples/index.js +3 -0
  36. package/dist/collection/utils/code-generator.js +1 -1
  37. package/dist/components/apollo-data-bar-chart.js +1 -1
  38. package/dist/components/apollo-data-donut-chart.js +1 -1
  39. package/dist/components/apollo-data-heat-map.d.ts +11 -0
  40. package/dist/components/apollo-data-heat-map.js +1 -0
  41. package/dist/components/apollo-data-line-chart.d.ts +11 -0
  42. package/dist/components/apollo-data-line-chart.js +1 -0
  43. package/dist/components/apollo-data-scatter-chart.d.ts +11 -0
  44. package/dist/components/apollo-data-scatter-chart.js +1 -0
  45. package/dist/components/apollo-data-world-map-chart.d.ts +11 -0
  46. package/dist/components/apollo-data-world-map-chart.js +1 -0
  47. package/dist/components/index.js +1 -1
  48. package/dist/components/p-2nuV5Vny.js +1 -0
  49. package/dist/components/p-CfbMSXKd.js +11 -0
  50. package/dist/components/p-gcjU8DVr.js +1 -0
  51. package/dist/esm/apollo-data-bar-chart.entry.js +313 -0
  52. package/dist/{cjs/apollo-data-bar-chart_2.cjs.entry.js → esm/apollo-data-base-C2k3WBpi.js} +8 -728
  53. package/dist/esm/apollo-data-donut-chart.entry.js +406 -0
  54. package/dist/esm/apollo-data-heat-map_4.entry.js +878 -0
  55. package/dist/esm/apollo-data.js +4 -4
  56. package/dist/esm/constants-2nuV5Vny.js +3 -0
  57. package/dist/esm/{index-Bb2nY-Tf.js → index-D64asVrg.js} +116 -63
  58. package/dist/esm/loader.js +3 -3
  59. package/dist/types/apollo-data-base.d.ts +2 -2
  60. package/dist/types/components/apollo-data-bar/apollo-data-bar.stories.d.ts +5 -0
  61. package/dist/types/components/apollo-data-donut/apollo-data-donut.stories.d.ts +5 -0
  62. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.d.ts +140 -0
  63. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.stories.d.ts +5 -0
  64. package/dist/types/components/apollo-data-line/apollo-data-line.d.ts +244 -0
  65. package/dist/types/components/apollo-data-line/apollo-data-line.stories.d.ts +5 -0
  66. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +327 -0
  67. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.stories.d.ts +5 -0
  68. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.d.ts +281 -0
  69. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.stories.d.ts +5 -0
  70. package/dist/types/components.d.ts +210 -4
  71. package/dist/types/examples/apollo-data-heat-map.examples.d.ts +11 -0
  72. package/dist/types/examples/apollo-data-line.examples.d.ts +12 -0
  73. package/dist/types/examples/apollo-data-scatter.examples.d.ts +11 -0
  74. package/dist/types/examples/apollo-data-world-map.examples.d.ts +11 -0
  75. package/dist/types/examples/index.d.ts +3 -0
  76. package/dist/types/stencil-public-runtime.d.ts +23 -2
  77. package/dist/types/utils/code-generator.d.ts +1 -3
  78. package/package.json +8 -8
  79. package/src/examples/apollo-data-bar.examples.ts +157 -157
  80. package/src/examples/apollo-data-heat-map.examples.ts +147 -0
  81. package/src/examples/apollo-data-line.examples.ts +103 -0
  82. package/src/examples/apollo-data-scatter.examples.ts +109 -0
  83. package/src/examples/apollo-data-world-map.examples.ts +57 -0
  84. package/src/examples/index.ts +4 -1
  85. package/dist/apollo-data/p-Bb2nY-Tf.js +0 -2
  86. package/dist/apollo-data/p-e6584598.entry.js +0 -11
  87. package/dist/components/p-7XF5Cax8.js +0 -11
  88. package/dist/components/p-Dws5s-Xe.js +0 -1
@@ -0,0 +1,883 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-Bd5risOy.js');
4
+ var apolloDataBase = require('./apollo-data-base-COGMOEqL.js');
5
+ var constants = require('./constants-B3weDEpc.js');
6
+
7
+ const ApolloDataHeatMap = class extends apolloDataBase.ApolloBase {
8
+ constructor(hostRef) {
9
+ super();
10
+ index.registerInstance(this, hostRef);
11
+ }
12
+ get el() { return index.getElement(this); }
13
+ /**
14
+ * Data for the heat map. Each item defines a cell by xLabel, yLabel, and value.
15
+ * @property {string} xLabel - Label for the X-axis (horizontal).
16
+ * @property {string} yLabel - Label for the Y-axis (vertical).
17
+ * @property {number} value - Numeric value encoded as color.
18
+ */
19
+ adData = [];
20
+ /**
21
+ * Optional specification for axis titles, color range, and tooltip behavior.
22
+ * @property {string} [xAxisTitle] - Label for the X-axis.
23
+ * @property {string} [yAxisTitle] - Label for the Y-axis.
24
+ * @property {string[]} [colorRange] - Two or more colors for the value scale (Vega interpolates between them).
25
+ * @property {'auto' | 'none'} [tooltip] - Tooltip behavior.
26
+ */
27
+ adSpec = {};
28
+ async componentDidRender() {
29
+ await this.renderChart();
30
+ }
31
+ DEFAULT_COLOR_RANGE = ['#e8f4f8', '#0066a1'];
32
+ // @ts-ignore
33
+ async getViewData(data, spec) {
34
+ const rawRange = spec?.colorRange;
35
+ const colorRange = Array.isArray(rawRange) && rawRange.length >= 2 ? rawRange : this.DEFAULT_COLOR_RANGE;
36
+ const tooltip = spec?.tooltip !== 'none';
37
+ const valid = data.filter(d => d != null && typeof d.xLabel === 'string' && typeof d.yLabel === 'string' && d.xLabel !== '' && d.yLabel !== '' && typeof d.value === 'number');
38
+ const xLabels = [...new Set(valid.map(d => d.xLabel))];
39
+ const yLabels = [...new Set(valid.map(d => d.yLabel))];
40
+ return {
41
+ $schema: 'https://vega.github.io/schema/vega/v6.json',
42
+ description: 'A heat map with xLabel and yLabel categories and value encoded as color.',
43
+ width: 450,
44
+ height: 350,
45
+ padding: { left: 5, top: 5, bottom: 5, right: 70 },
46
+ autosize: { type: 'fit', resize: true },
47
+ data: [
48
+ {
49
+ name: 'source',
50
+ values: valid,
51
+ },
52
+ ],
53
+ scales: [
54
+ {
55
+ name: 'xscale',
56
+ type: 'band',
57
+ range: [0, { signal: 'width' }],
58
+ domain: xLabels,
59
+ padding: 0.05,
60
+ },
61
+ {
62
+ name: 'yscale',
63
+ type: 'band',
64
+ range: [{ signal: 'height' }, 0],
65
+ domain: yLabels,
66
+ padding: 0.05,
67
+ },
68
+ {
69
+ name: 'color',
70
+ type: 'sequential',
71
+ range: colorRange,
72
+ domain: { data: 'source', field: 'value' },
73
+ zero: true,
74
+ },
75
+ ],
76
+ axes: [
77
+ {
78
+ orient: 'bottom',
79
+ scale: 'xscale',
80
+ title: spec?.xAxisTitle ?? 'X',
81
+ labelAngle: -90,
82
+ labelAlign: 'right',
83
+ },
84
+ {
85
+ orient: 'left',
86
+ scale: 'yscale',
87
+ title: spec?.yAxisTitle ?? 'Y',
88
+ },
89
+ ],
90
+ legends: [
91
+ {
92
+ type: 'gradient',
93
+ fill: 'color',
94
+ orient: 'right',
95
+ direction: 'vertical',
96
+ title: 'Value',
97
+ titleLimit: 120,
98
+ tickCount: 5,
99
+ format: 's',
100
+ },
101
+ ],
102
+ marks: [
103
+ {
104
+ type: 'rect',
105
+ from: { data: 'source' },
106
+ encode: {
107
+ ...(tooltip && {
108
+ enter: {
109
+ tooltip: {
110
+ signal: "datum.xLabel + ' | ' + datum.yLabel + ' | ' + format(datum.value, ',.2f')",
111
+ },
112
+ },
113
+ }),
114
+ update: {
115
+ x: { scale: 'xscale', field: 'xLabel' },
116
+ y: { scale: 'yscale', field: 'yLabel' },
117
+ width: { scale: 'xscale', band: 1 },
118
+ height: { scale: 'yscale', band: 1 },
119
+ fill: { scale: 'color', field: 'value' },
120
+ },
121
+ hover: {
122
+ fill: { value: 'firebrick' },
123
+ opacity: { value: 0.8 },
124
+ },
125
+ },
126
+ },
127
+ ],
128
+ };
129
+ }
130
+ render() {
131
+ return (index.h(index.Host, { key: 'd15b44f268f153498e61dc7829fe0d45f315a992' }, index.h("div", { key: '7783444f4675c885980f1cd571737d506e00fdbc', id: "container", style: { width: '100%', height: '100%' } })));
132
+ }
133
+ };
134
+
135
+ const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
136
+ function lineStyleToStrokeDash(lineStyle) {
137
+ switch (lineStyle) {
138
+ case 'dashed':
139
+ return [6, 4];
140
+ case 'dotted':
141
+ return [2, 2];
142
+ case 'solid':
143
+ default:
144
+ return [];
145
+ }
146
+ }
147
+ const ApolloDataLineChart = class extends apolloDataBase.ApolloBase {
148
+ constructor(hostRef) {
149
+ super();
150
+ index.registerInstance(this, hostRef);
151
+ }
152
+ get el() { return index.getElement(this); }
153
+ adData = [];
154
+ adSpec = null;
155
+ static tooltipStylesInjected = false;
156
+ componentDidLoad() {
157
+ this.injectTooltipStyles();
158
+ }
159
+ async componentDidRender() {
160
+ await this.renderChart();
161
+ }
162
+ injectTooltipStyles() {
163
+ const chartClass = this.constructor;
164
+ if (chartClass.tooltipStylesInjected) {
165
+ return;
166
+ }
167
+ const styleId = 'apollo-data-line-tooltip-styles';
168
+ if (document.getElementById(styleId)) {
169
+ chartClass.tooltipStylesInjected = true;
170
+ return;
171
+ }
172
+ const style = document.createElement('style');
173
+ style.id = styleId;
174
+ style.textContent = `
175
+ #vg-tooltip-element {
176
+ background-color: #ffffff;
177
+ border: 1px solid #e1e2e8;
178
+ border-radius: 0.25rem;
179
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);
180
+ font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;
181
+ font-weight: 500;
182
+ padding: 0.25rem 0.75rem;
183
+ pointer-events: none;
184
+ text-align: center;
185
+ transform: translateY(20%);
186
+ white-space: pre;
187
+ z-index: 999999999;
188
+ }
189
+
190
+ #vg-tooltip-element table tr td.key {
191
+ color: #6a6d7d;
192
+ text-align: center;
193
+ }
194
+
195
+ #vg-tooltip-element table tr td.value {
196
+ text-align: center;
197
+ }
198
+
199
+ #vg-tooltip-element.dark-theme {
200
+ background-color: #292632;
201
+ border: 1px solid #6a6d7d;
202
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);
203
+ color: #ffffff;
204
+ }
205
+
206
+ #vg-tooltip-element::after {
207
+ border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
208
+ border-style: solid;
209
+ border-width: 9px;
210
+ bottom: -17px;
211
+ content: '';
212
+ left: 50%;
213
+ position: absolute;
214
+ transform: translateX(-50%);
215
+ }
216
+ `;
217
+ document.head.appendChild(style);
218
+ chartClass.tooltipStylesInjected = true;
219
+ }
220
+ // @ts-ignore
221
+ async getViewData(data, spec) {
222
+ const componentTag = this.el?.tagName?.toLowerCase() ?? 'apollo-data-line-chart';
223
+ if (!spec) {
224
+ throw new Error(`adSpec is required for ${componentTag}`);
225
+ }
226
+ const { tooltipPrefix = '', currencySymbol = '' } = spec;
227
+ if (!data || data.length === 0) {
228
+ throw new Error(`Data is required for ${componentTag}`);
229
+ }
230
+ const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
231
+ const uniqueXValues = [...new Set(data.map(item => item.xValue))].sort((a, b) => a - b);
232
+ const colorSet = spec?.colorSet ?? constants.CHART_COLORS;
233
+ const xLabelData = uniqueXValues.map(x => {
234
+ const first = data.find(d => d.xValue === x);
235
+ return { xValue: x, displayLabel: first?.xLabel != null ? first.xLabel : String(x) };
236
+ });
237
+ const formatNumber = tooltipPrefix ? '.2f' : '.0f';
238
+ const currencyPrefix = tooltipPrefix ? currencySymbol : '';
239
+ const pointShape = spec.pointStyle ?? 'circle';
240
+ const strokeDash = lineStyleToStrokeDash(spec.lineStyle ?? 'solid');
241
+ const dataSpec = [
242
+ { name: 'raw', values: data },
243
+ { name: 'xLabelData', values: xLabelData },
244
+ ];
245
+ uniqueCategories.forEach((cat, i) => {
246
+ dataSpec.push({
247
+ name: `series_${i}`,
248
+ source: 'raw',
249
+ transform: [
250
+ { type: 'filter', expr: `datum.category === ${JSON.stringify(cat)}` },
251
+ { type: 'collect', sort: { field: 'xValue' } },
252
+ ],
253
+ });
254
+ });
255
+ const lineMarks = uniqueCategories.map((_, i) => ({
256
+ type: 'line',
257
+ from: { data: `series_${i}` },
258
+ encode: {
259
+ enter: {
260
+ x: { scale: 'x', field: 'xValue' },
261
+ y: { scale: 'y', field: 'yValue' },
262
+ stroke: { value: colorSet[i % colorSet.length] },
263
+ strokeWidth: { value: 2 },
264
+ interpolate: { value: 'monotone' },
265
+ ...(strokeDash.length > 0 ? { strokeDash: { value: strokeDash } } : {}),
266
+ },
267
+ },
268
+ }));
269
+ return {
270
+ $schema: 'https://vega.github.io/schema/vega/v5.json',
271
+ config: {
272
+ text: {
273
+ fill: '#6a6d7d',
274
+ font: FONT_FAMILY,
275
+ labelFontSize: 12,
276
+ labelFontWeight: 400,
277
+ },
278
+ axis: {
279
+ labelColor: '#6a6d7d',
280
+ titleColor: '#6a6d7d',
281
+ labelFont: FONT_FAMILY,
282
+ titleFont: FONT_FAMILY,
283
+ titleFontWeight: 400,
284
+ },
285
+ legend: {
286
+ labelColor: '#6a6d7d',
287
+ titleColor: '#6a6d7d',
288
+ labelFont: FONT_FAMILY,
289
+ titleFont: FONT_FAMILY,
290
+ labelFontSize: 12,
291
+ labelLimit: 95,
292
+ },
293
+ title: {
294
+ color: '#6a6d7d',
295
+ font: FONT_FAMILY,
296
+ labelFontSize: 12,
297
+ labelFontWeight: 400,
298
+ },
299
+ },
300
+ height: 250,
301
+ autosize: { type: 'fit-x', contains: 'padding', resize: true },
302
+ signals: [
303
+ {
304
+ name: 'containerW',
305
+ update: 'max(containerSize()[0], 400)',
306
+ },
307
+ {
308
+ name: 'legendColumns',
309
+ update: 'ceil(containerW / 140)',
310
+ },
311
+ ],
312
+ width: { signal: 'containerW' },
313
+ data: dataSpec,
314
+ scales: [
315
+ {
316
+ name: 'x',
317
+ type: 'point',
318
+ domain: uniqueXValues,
319
+ range: 'width',
320
+ padding: 0.5,
321
+ },
322
+ {
323
+ name: 'xLabels',
324
+ type: 'ordinal',
325
+ domain: { data: 'xLabelData', field: 'xValue' },
326
+ range: { data: 'xLabelData', field: 'displayLabel' },
327
+ },
328
+ {
329
+ name: 'y',
330
+ type: 'linear',
331
+ domain: { data: 'raw', field: 'yValue' },
332
+ nice: true,
333
+ zero: true,
334
+ range: 'height',
335
+ },
336
+ {
337
+ name: 'color',
338
+ type: 'ordinal',
339
+ domain: uniqueCategories,
340
+ range: spec?.colorSet ?? constants.CHART_COLORS,
341
+ },
342
+ ],
343
+ axes: [
344
+ {
345
+ orient: 'bottom',
346
+ scale: 'x',
347
+ title: spec?.xAxisTitle,
348
+ labelPadding: 12,
349
+ titlePadding: 12,
350
+ labelAngle: -90,
351
+ labelAlign: 'right',
352
+ labelBaseline: 'middle',
353
+ tickSize: 3,
354
+ labelFontSize: 12,
355
+ titleFontSize: 14,
356
+ ticks: false,
357
+ domain: false,
358
+ encode: {
359
+ labels: {
360
+ update: {
361
+ text: { signal: "scale('xLabels', datum.value)" },
362
+ },
363
+ },
364
+ },
365
+ },
366
+ {
367
+ orient: 'left',
368
+ scale: 'y',
369
+ title: spec?.yAxisTitle || '',
370
+ format: ',.0f',
371
+ grid: true,
372
+ tickCount: 6,
373
+ labelFontSize: 12,
374
+ titleFontSize: 14,
375
+ ticks: false,
376
+ domain: false,
377
+ tickBand: 'extent',
378
+ labelPadding: 10,
379
+ },
380
+ ],
381
+ legends: [
382
+ {
383
+ stroke: 'color',
384
+ orient: 'bottom',
385
+ direction: 'horizontal',
386
+ columns: { signal: 'legendColumns' },
387
+ title: null,
388
+ symbolType: 'stroke',
389
+ symbolStrokeWidth: 3,
390
+ rowPadding: 8,
391
+ symbolOffset: -35,
392
+ symbolSize: 100,
393
+ labelOffset: 8,
394
+ labelLimit: 95,
395
+ },
396
+ ],
397
+ marks: [
398
+ ...lineMarks,
399
+ {
400
+ type: 'symbol',
401
+ from: { data: 'raw' },
402
+ encode: {
403
+ enter: {
404
+ x: { scale: 'x', field: 'xValue' },
405
+ y: { scale: 'y', field: 'yValue' },
406
+ fill: { scale: 'color', field: 'category' },
407
+ size: { value: 50 },
408
+ shape: { value: pointShape },
409
+ tooltip: {
410
+ signal: `(datum.xLabel != null ? datum.xLabel : format(datum.xValue, ',.0f')) + ' · ' + datum.category + ': ' + (datum.yLabel != null ? datum.yLabel : '${currencyPrefix}' + format(datum.yValue, ',${formatNumber}'))`,
411
+ },
412
+ },
413
+ },
414
+ },
415
+ ],
416
+ };
417
+ }
418
+ render() {
419
+ return (index.h(index.Host, { key: 'fd64f4abb624b14a878808b23345910c9b23a72c' }, index.h("div", { key: 'aeda5086730862ca1368a0374caf2d918969839d', id: "container", style: { width: '100%', height: '100%' } })));
420
+ }
421
+ };
422
+
423
+ const ApolloDataScatterChart = class extends apolloDataBase.ApolloBase {
424
+ constructor(hostRef) {
425
+ super();
426
+ index.registerInstance(this, hostRef);
427
+ }
428
+ get el() { return index.getElement(this); }
429
+ /**
430
+ * Represents a single data point in the scatter chart.
431
+ * @property {string} category - Category or group name associated with the data point.
432
+ * This can be used for legend grouping or category-based styling.
433
+ * @property {number} xValue - Numeric value plotted along the X-axis.
434
+ * @property {number} yValue - Numeric value plotted along the Y-axis.
435
+ * @property {PointStyle} [pointStyle] - Optional style override for this specific data point.
436
+ * If provided, it takes precedence over default or category-level styles.
437
+ */
438
+ adData = [];
439
+ /**
440
+ * Optional specification object for customizing the scatter chart configuration.
441
+ * @property {string} [yAxisTitle] - Label displayed for the Y-axis.
442
+ * @property {string} [xAxisTitle] - Label displayed for the X-axis.
443
+ * @property {PointStyle} [defaultPointStyle] - Default styling applied to all scatter points (e.g., size, color, shape, opacity).
444
+ * @property {PointStyle} [pointStyle] - Global point style override applied to all data points.
445
+ * @property {{ [categoryName: string]: PointStyle }} [categoryPointStyleMap] -
446
+ * A mapping object that allows custom point styles per category name.
447
+ * Each key represents a category, and its value defines the corresponding PointStyle.
448
+ * @property {'auto' | 'none'} [tooltip] - Controls tooltip behavior.
449
+ * 'auto' enables default tooltip rendering, while 'none' disables tooltips.
450
+ */
451
+ adSpec = {};
452
+ async componentDidRender() {
453
+ await this.renderChart();
454
+ }
455
+ DEFAULT_POINT_STYLE = {
456
+ shape: 'circle',
457
+ opacity: 1,
458
+ color: 'blue',
459
+ size: 1,
460
+ };
461
+ // @ts-ignore
462
+ async getViewData(data, spec) {
463
+ const dataItemsToUse = data.map(dataItem => {
464
+ const pointStylesToUse = {};
465
+ Object.keys(this.DEFAULT_POINT_STYLE).forEach(key => {
466
+ const value = dataItem.pointStyle?.[key] ??
467
+ dataItem?.[key] ??
468
+ spec.categoryPointStyleMap?.[dataItem.category]?.[key] ??
469
+ spec.defaultPointStyle?.[key] ??
470
+ this.DEFAULT_POINT_STYLE[key];
471
+ pointStylesToUse[key] = value;
472
+ });
473
+ return {
474
+ category: dataItem.category,
475
+ xValue: dataItem.xValue,
476
+ yValue: dataItem.yValue,
477
+ color: pointStylesToUse.color,
478
+ shape: pointStylesToUse.shape,
479
+ opacity: pointStylesToUse.opacity,
480
+ };
481
+ });
482
+ const tooltipField = spec?.tooltip === 'auto' ? 'category' : 'none';
483
+ return {
484
+ $schema: 'https://vega.github.io/schema/vega/v6.json',
485
+ description: 'A scatter plot with null values visualized along the axes.',
486
+ width: 450,
487
+ height: 450,
488
+ padding: 5,
489
+ autosize: { type: 'fit', resize: true },
490
+ signals: [
491
+ { name: 'nullSize', value: 8 },
492
+ { name: 'nullGap', update: 'nullSize + 10' },
493
+ ],
494
+ data: [
495
+ {
496
+ name: 'source',
497
+ values: dataItemsToUse,
498
+ },
499
+ {
500
+ name: 'valid',
501
+ source: 'source',
502
+ transform: [
503
+ {
504
+ type: 'filter',
505
+ expr: 'datum.xValue != null && datum.yValue != null',
506
+ },
507
+ ],
508
+ },
509
+ {
510
+ name: 'nullXY',
511
+ source: 'source',
512
+ transform: [
513
+ {
514
+ type: 'filter',
515
+ expr: 'datum.xValue == null && datum.yValue == null',
516
+ },
517
+ { type: 'aggregate' },
518
+ ],
519
+ },
520
+ {
521
+ name: 'nullY',
522
+ source: 'source',
523
+ transform: [
524
+ {
525
+ type: 'filter',
526
+ expr: 'datum.xValue != null && datum.yValue == null',
527
+ },
528
+ ],
529
+ },
530
+ {
531
+ name: 'nullX',
532
+ source: 'source',
533
+ transform: [
534
+ {
535
+ type: 'filter',
536
+ expr: 'datum.xValue == null && datum.yValue != null',
537
+ },
538
+ ],
539
+ },
540
+ ],
541
+ scales: [
542
+ {
543
+ name: 'xscale',
544
+ type: 'linear',
545
+ range: [{ signal: 'nullGap' }, { signal: 'width' }],
546
+ nice: true,
547
+ domain: { data: 'valid', field: 'xValue' },
548
+ },
549
+ {
550
+ name: 'yscale',
551
+ type: 'linear',
552
+ range: [{ signal: 'height - nullGap' }, 0],
553
+ nice: true,
554
+ domain: { data: 'valid', field: 'yValue' },
555
+ },
556
+ ],
557
+ axes: [
558
+ {
559
+ orient: 'bottom',
560
+ scale: 'xscale',
561
+ offset: 5,
562
+ format: 's',
563
+ title: spec?.xAxisTitle || 'X Value',
564
+ },
565
+ {
566
+ orient: 'left',
567
+ scale: 'yscale',
568
+ offset: 5,
569
+ format: 's',
570
+ title: spec?.yAxisTitle || 'Y Value',
571
+ },
572
+ ],
573
+ marks: [
574
+ {
575
+ type: 'symbol',
576
+ from: { data: 'valid' },
577
+ encode: {
578
+ enter: {
579
+ size: { value: 50 },
580
+ tooltip: { field: tooltipField },
581
+ },
582
+ update: {
583
+ x: { scale: 'xscale', field: 'xValue' },
584
+ y: { scale: 'yscale', field: 'yValue' },
585
+ fill: { field: 'color' },
586
+ fillOpacity: { field: 'opacity' },
587
+ shape: { field: 'shape' },
588
+ zindex: { value: 0 },
589
+ },
590
+ hover: {
591
+ fill: { value: 'firebrick' },
592
+ fillOpacity: { value: 1 },
593
+ zindex: { value: 1 },
594
+ },
595
+ },
596
+ },
597
+ {
598
+ type: 'symbol',
599
+ from: { data: 'nullY' },
600
+ encode: {
601
+ enter: {
602
+ size: { value: 50 },
603
+ tooltip: { field: tooltipField },
604
+ },
605
+ update: {
606
+ x: { scale: 'xscale', field: 'xValue' },
607
+ y: { signal: 'height - nullSize/2' },
608
+ fill: { value: '#aaa' },
609
+ fillOpacity: { value: 0.2 },
610
+ },
611
+ hover: {
612
+ fill: { value: 'firebrick' },
613
+ fillOpacity: { value: 1 },
614
+ },
615
+ },
616
+ },
617
+ {
618
+ type: 'symbol',
619
+ from: { data: 'nullX' },
620
+ encode: {
621
+ enter: {
622
+ size: { value: 50 },
623
+ tooltip: { field: 'name' },
624
+ },
625
+ update: {
626
+ x: { signal: 'nullSize/2' },
627
+ y: { scale: 'yscale', field: 'yValue' },
628
+ fill: { value: '#aaa' },
629
+ fillOpacity: { value: 0.2 },
630
+ zindex: { value: 0 },
631
+ },
632
+ hover: {
633
+ fill: { value: 'firebrick' },
634
+ fillOpacity: { value: 1 },
635
+ zindex: { value: 1 },
636
+ },
637
+ },
638
+ },
639
+ {
640
+ type: 'text',
641
+ interactive: false,
642
+ from: { data: 'nullXY' },
643
+ encode: {
644
+ update: {
645
+ x: { signal: 'nullSize', offset: -4 },
646
+ y: { signal: 'height', offset: 13 },
647
+ text: { signal: "datum.count + ' null'" },
648
+ align: { value: 'right' },
649
+ baseline: { value: 'top' },
650
+ fill: { value: '#999' },
651
+ fontSize: { value: 9 },
652
+ },
653
+ },
654
+ },
655
+ ],
656
+ };
657
+ }
658
+ render() {
659
+ return (index.h(index.Host, { key: 'f6c1e8d9e9a6ba41dbbf8c2c5737895b96b0915d' }, index.h("div", { key: '2aeba82bc31c5995a3d5b532c339f5b45ae850f7', id: "container", style: { width: '100%', height: '100%' } })));
660
+ }
661
+ };
662
+
663
+ const ApolloDataWorldMapChart = class extends apolloDataBase.ApolloBase {
664
+ constructor(hostRef) {
665
+ super();
666
+ index.registerInstance(this, hostRef);
667
+ }
668
+ get el() { return index.getElement(this); }
669
+ /**
670
+ * Represents a single data point in the world map chart.
671
+ * @property {number} lon - Longitude coordinate used to position the point on the map.
672
+ * @property {number} lat - Latitude coordinate used to position the point on the map.
673
+ * @property {number} value - A numeric metric tied to the point.
674
+ * @property {string} label - Label displayed for the place or location represented by the point.
675
+ */
676
+ adData = [];
677
+ /**
678
+ * @property {string} pinColor - Color of the pin representing the point.
679
+ * @property {'circle' | 'square' | 'triangle'} pinShape - Shape of the pin representing the point.
680
+ */
681
+ adSpec = {};
682
+ async componentDidRender() {
683
+ await this.renderChart();
684
+ }
685
+ // @ts-ignore
686
+ // eslint-disable-next-line class-methods-use-this
687
+ async getViewData(data, spec) {
688
+ const pinColor = spec?.pinColor || '#d3544b';
689
+ const pinShape = spec?.pinShape || 'circle';
690
+ return {
691
+ $schema: 'https://vega.github.io/schema/vega/v6.json',
692
+ description: 'World map + tooltip + points.',
693
+ width: 600,
694
+ height: 400,
695
+ autosize: 'none',
696
+ background: '#cfe3f1',
697
+ signals: [
698
+ {
699
+ name: 'scale',
700
+ value: 85,
701
+ on: [
702
+ {
703
+ events: { type: 'wheel', consume: true },
704
+ update: 'clamp(scale * pow(1.002, -event.deltaY), 85, 2000)',
705
+ },
706
+ ],
707
+ },
708
+ {
709
+ name: 'xc',
710
+ value: 0,
711
+ on: [{ events: 'mousedown', update: 'x()' }],
712
+ },
713
+ {
714
+ name: 'yc',
715
+ value: 0,
716
+ on: [{ events: 'mousedown', update: 'y()' }],
717
+ },
718
+ {
719
+ name: 'xo',
720
+ value: 300,
721
+ on: [{ events: 'mousedown', update: 'tx' }],
722
+ },
723
+ {
724
+ name: 'yo',
725
+ value: 175,
726
+ on: [{ events: 'mousedown', update: 'ty' }],
727
+ },
728
+ {
729
+ name: 'tx',
730
+ value: 300,
731
+ on: [
732
+ {
733
+ events: '[mousedown, window:mouseup] > window:mousemove',
734
+ update: 'xo - (x() - xc)',
735
+ },
736
+ ],
737
+ },
738
+ {
739
+ name: 'ty',
740
+ value: 270,
741
+ on: [
742
+ {
743
+ events: '[mousedown, window:mouseup] > window:mousemove',
744
+ update: 'clamp(yo + y() - yc, -scale * 0.5, scale * 2.5 + height)',
745
+ },
746
+ ],
747
+ },
748
+ ],
749
+ projections: [
750
+ {
751
+ name: 'projection',
752
+ type: 'mercator',
753
+ scale: { signal: 'scale' },
754
+ rotate: [{ signal: '-(tx - width / 2) * 180 / (scale * PI)' }, 0, 0],
755
+ center: [0, 0],
756
+ translate: [{ signal: 'width / 2' }, { signal: 'ty' }],
757
+ },
758
+ ],
759
+ data: [
760
+ {
761
+ name: 'names',
762
+ url: 'https://raw.githubusercontent.com/KoGor/Map-Icons-Generator/master/data/world-110m-country-names.tsv',
763
+ format: { type: 'tsv' },
764
+ transform: [{ type: 'formula', as: 'id', expr: 'toNumber(datum.id)' }],
765
+ },
766
+ {
767
+ name: 'metrics',
768
+ values: data,
769
+ },
770
+ {
771
+ name: 'world',
772
+ url: 'https://vega.github.io/editor/data/world-110m.json',
773
+ format: { type: 'topojson', feature: 'countries' },
774
+ transform: [
775
+ {
776
+ type: 'lookup',
777
+ from: 'names',
778
+ key: 'id',
779
+ fields: ['id'],
780
+ values: ['name'],
781
+ as: ['name'],
782
+ },
783
+ { type: 'filter', expr: "datum.name != 'Antarctica'" },
784
+ ],
785
+ },
786
+ {
787
+ name: 'points',
788
+ source: 'metrics',
789
+ transform: [
790
+ { type: 'filter', expr: 'isValid(datum.lon) && isValid(datum.lat)' },
791
+ {
792
+ type: 'geopoint',
793
+ projection: 'projection',
794
+ fields: ['lon', 'lat'],
795
+ as: ['x', 'y'],
796
+ },
797
+ ],
798
+ },
799
+ {
800
+ name: 'continentLabels',
801
+ values: [
802
+ { name: 'North America', lon: -105, lat: 45 },
803
+ { name: 'South America', lon: -60, lat: -15 },
804
+ { name: 'Europe', lon: 15, lat: 52 },
805
+ { name: 'Africa', lon: 20, lat: 5 },
806
+ { name: 'Asia', lon: 90, lat: 35 },
807
+ { name: 'Oceania', lon: 135, lat: -25 },
808
+ ],
809
+ transform: [
810
+ {
811
+ type: 'geopoint',
812
+ projection: 'projection',
813
+ fields: ['lon', 'lat'],
814
+ as: ['x', 'y'],
815
+ },
816
+ ],
817
+ },
818
+ ],
819
+ marks: [
820
+ {
821
+ type: 'shape',
822
+ from: { data: 'world' },
823
+ transform: [{ type: 'geoshape', projection: 'projection' }],
824
+ encode: {
825
+ update: {
826
+ fill: { value: '#8fbf8f' },
827
+ stroke: { value: '#6c8c8c' },
828
+ strokeWidth: { value: 0.7 },
829
+ tooltip: { signal: "{Country: datum.name ? datum.name : 'Unknown'}" },
830
+ },
831
+ hover: {
832
+ stroke: { value: '#2b3a42' },
833
+ strokeWidth: { value: 1.3 },
834
+ },
835
+ },
836
+ },
837
+ {
838
+ type: 'symbol',
839
+ from: { data: 'points' },
840
+ encode: {
841
+ update: {
842
+ x: { field: 'x' },
843
+ y: { field: 'y' },
844
+ size: { value: 80 },
845
+ fill: { value: pinColor },
846
+ stroke: { value: 'white' },
847
+ shape: { value: pinShape },
848
+ strokeWidth: { value: 1 },
849
+ tooltip: {
850
+ signal: '{Label: datum.label, Value: datum.value, Latitude: datum.lat, Longitude: datum.lon}',
851
+ },
852
+ },
853
+ },
854
+ },
855
+ {
856
+ type: 'text',
857
+ from: { data: 'continentLabels' },
858
+ encode: {
859
+ update: {
860
+ x: { field: 'x' },
861
+ y: { field: 'y' },
862
+ text: { field: 'name' },
863
+ align: { value: 'center' },
864
+ baseline: { value: 'middle' },
865
+ fontSize: { value: 12 },
866
+ fontWeight: { value: '600' },
867
+ fill: { value: '#2b3a42' },
868
+ fillOpacity: { value: 0.5 },
869
+ },
870
+ },
871
+ },
872
+ ],
873
+ };
874
+ }
875
+ render() {
876
+ return (index.h(index.Host, { key: '8053ea3b9706cdd03a430157b3f63e93c1201d1f' }, index.h("div", { key: '514807ae8dd4868d3d74e86c4260b7b9967c0ac2', id: "container", style: { width: '100%', height: '100%' } })));
877
+ }
878
+ };
879
+
880
+ exports.apollo_data_heat_map = ApolloDataHeatMap;
881
+ exports.apollo_data_line_chart = ApolloDataLineChart;
882
+ exports.apollo_data_scatter_chart = ApolloDataScatterChart;
883
+ exports.apollo_data_world_map_chart = ApolloDataWorldMapChart;