@xplortech/apollo-data 0.0.4-draft.64ed229 → 0.0.4-draft.f74ef02

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 (31) hide show
  1. package/dist/apollo-data/apollo-data.esm.js +1 -1
  2. package/dist/apollo-data/p-2nuV5Vny.js +1 -0
  3. package/dist/apollo-data/p-4ac3c97c.entry.js +1 -0
  4. package/dist/apollo-data/p-BWkrM8dc.js +11 -0
  5. package/dist/apollo-data/p-b7471c12.entry.js +1 -0
  6. package/dist/apollo-data/p-e518baac.entry.js +1 -0
  7. package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +314 -0
  8. package/dist/{esm/apollo-data-bar-chart_3.entry.js → cjs/apollo-data-base-CxVQ-WVP.js} +2 -999
  9. package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +408 -0
  10. package/dist/cjs/apollo-data-line-chart_2.cjs.entry.js +534 -0
  11. package/dist/cjs/apollo-data.cjs.js +1 -1
  12. package/dist/cjs/constants-B3weDEpc.js +5 -0
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/collection/collection-manifest.json +2 -1
  15. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +329 -0
  16. package/dist/collection/examples/apollo-data-scatter.examples.js +94 -0
  17. package/dist/components/apollo-data-scatter-chart.d.ts +11 -0
  18. package/dist/components/apollo-data-scatter-chart.js +1 -0
  19. package/dist/esm/apollo-data-bar-chart.entry.js +312 -0
  20. package/dist/{cjs/apollo-data-bar-chart_3.cjs.entry.js → esm/apollo-data-base-BWkrM8dc.js} +1 -1004
  21. package/dist/esm/apollo-data-donut-chart.entry.js +406 -0
  22. package/dist/esm/apollo-data-line-chart_2.entry.js +531 -0
  23. package/dist/esm/apollo-data.js +1 -1
  24. package/dist/esm/constants-2nuV5Vny.js +3 -0
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +329 -0
  27. package/dist/types/components.d.ts +55 -0
  28. package/dist/types/examples/apollo-data-scatter.examples.d.ts +11 -0
  29. package/package.json +1 -1
  30. package/src/examples/apollo-data-scatter.examples.ts +109 -0
  31. package/dist/apollo-data/p-725550f2.entry.js +0 -11
@@ -0,0 +1,312 @@
1
+ import { r as registerInstance, g as getElement, h, H as Host } from './index-Bb2nY-Tf.js';
2
+ import { A as ApolloBase } from './apollo-data-base-BWkrM8dc.js';
3
+ import { C as CHART_COLORS } from './constants-2nuV5Vny.js';
4
+
5
+ const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
6
+ const ApolloDataBarChart = class extends ApolloBase {
7
+ constructor(hostRef) {
8
+ super();
9
+ registerInstance(this, hostRef);
10
+ }
11
+ get el() { return getElement(this); }
12
+ adData = [];
13
+ adSpec = null;
14
+ static tooltipStylesInjected = false;
15
+ componentDidLoad() {
16
+ this.injectTooltipStyles();
17
+ }
18
+ async componentDidRender() {
19
+ await this.renderChart();
20
+ }
21
+ injectTooltipStyles() {
22
+ if (ApolloDataBarChart.tooltipStylesInjected) {
23
+ return;
24
+ }
25
+ const styleId = 'apollo-data-bar-tooltip-styles';
26
+ if (document.getElementById(styleId)) {
27
+ ApolloDataBarChart.tooltipStylesInjected = true;
28
+ return;
29
+ }
30
+ const style = document.createElement('style');
31
+ style.id = styleId;
32
+ style.textContent = `
33
+ #vg-tooltip-element {
34
+ background-color: #ffffff;
35
+ border: 1px solid #e1e2e8;
36
+ border-radius: 0.25rem;
37
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);
38
+ font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;
39
+ font-weight: 500;
40
+ padding: 0.25rem 0.75rem;
41
+ pointer-events: none;
42
+ text-align: center;
43
+ transform: translateY(20%);
44
+ white-space: pre;
45
+ z-index: 999999999;
46
+ }
47
+
48
+ #vg-tooltip-element table tr td.key {
49
+ color: #6a6d7d;
50
+ text-align: center;
51
+ }
52
+
53
+ #vg-tooltip-element table tr td.value {
54
+ text-align: center;
55
+ }
56
+
57
+ #vg-tooltip-element.dark-theme {
58
+ background-color: #292632;
59
+ border: 1px solid #6a6d7d;
60
+ box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);
61
+ color: #ffffff;
62
+ }
63
+
64
+ #vg-tooltip-element::after {
65
+ border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
66
+ border-style: solid;
67
+ border-width: 9px;
68
+ bottom: -17px;
69
+ content: '';
70
+ left: 50%;
71
+ position: absolute;
72
+ transform: translateX(-50%);
73
+ }
74
+ `;
75
+ document.head.appendChild(style);
76
+ ApolloDataBarChart.tooltipStylesInjected = true;
77
+ }
78
+ // @ts-ignore
79
+ async getViewData(data, spec) {
80
+ if (!spec) {
81
+ throw new Error('adSpec is required for apollo-data-bar-chart');
82
+ }
83
+ const { tooltipPrefix = '', currencySymbol = '' } = spec;
84
+ if (!data || data.length === 0) {
85
+ throw new Error('Data is required for apollo-data-bar-chart');
86
+ }
87
+ const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
88
+ const formatNumber = tooltipPrefix ? '.2f' : '.0f';
89
+ const currencyPrefix = tooltipPrefix ? currencySymbol : '';
90
+ return {
91
+ $schema: 'https://vega.github.io/schema/vega/v5.json',
92
+ config: {
93
+ text: {
94
+ fill: '#6a6d7d',
95
+ font: FONT_FAMILY,
96
+ labelFontSize: 12,
97
+ labelFontWeight: 400,
98
+ },
99
+ axis: {
100
+ labelColor: '#6a6d7d',
101
+ titleColor: '#6a6d7d',
102
+ labelFont: FONT_FAMILY,
103
+ titleFont: FONT_FAMILY,
104
+ titleFontWeight: 400,
105
+ },
106
+ legend: {
107
+ labelColor: '#6a6d7d',
108
+ titleColor: '#6a6d7d',
109
+ labelFont: FONT_FAMILY,
110
+ titleFont: FONT_FAMILY,
111
+ labelFontSize: 12,
112
+ labelLimit: 95,
113
+ },
114
+ title: {
115
+ color: '#6a6d7d',
116
+ font: FONT_FAMILY,
117
+ labelFontSize: 12,
118
+ labelFontWeight: 400,
119
+ },
120
+ },
121
+ height: 250,
122
+ autosize: { type: 'fit-x', contains: 'padding', resize: true },
123
+ signals: [
124
+ {
125
+ name: 'containerW',
126
+ update: 'max(containerSize()[0], 400)',
127
+ },
128
+ {
129
+ name: 'legendColumns',
130
+ update: 'ceil(containerW / 140)',
131
+ },
132
+ {
133
+ name: 'hoveredPeriod',
134
+ value: null,
135
+ on: [
136
+ { events: 'rect:mouseover', update: 'datum.period' },
137
+ { events: 'rect:mouseout', update: 'null' },
138
+ ],
139
+ },
140
+ ],
141
+ width: { signal: 'containerW' },
142
+ data: [
143
+ {
144
+ name: 'raw',
145
+ values: data,
146
+ },
147
+ {
148
+ name: 'periodTotals',
149
+ source: 'raw',
150
+ transform: [
151
+ {
152
+ type: 'aggregate',
153
+ groupby: ['periodId'],
154
+ fields: ['value'],
155
+ ops: ['sum'],
156
+ as: ['total'],
157
+ },
158
+ ],
159
+ },
160
+ {
161
+ name: 'table',
162
+ source: 'raw',
163
+ transform: [
164
+ {
165
+ type: 'lookup',
166
+ from: 'periodTotals',
167
+ key: 'periodId',
168
+ fields: ['periodId'],
169
+ values: ['total'],
170
+ as: ['total'],
171
+ },
172
+ {
173
+ type: 'stack',
174
+ groupby: ['periodId'],
175
+ sort: { field: 'category' },
176
+ field: 'value',
177
+ },
178
+ {
179
+ type: 'formula',
180
+ as: 'periodId',
181
+ expr: 'datum.periodId',
182
+ },
183
+ {
184
+ type: 'formula',
185
+ as: 'labelOnly',
186
+ expr: 'datum.label',
187
+ },
188
+ ],
189
+ },
190
+ {
191
+ name: 'periodLabels',
192
+ source: 'raw',
193
+ transform: [
194
+ {
195
+ type: 'aggregate',
196
+ groupby: ['periodId', 'label'],
197
+ },
198
+ ],
199
+ },
200
+ ],
201
+ scales: [
202
+ {
203
+ name: 'x',
204
+ type: 'band',
205
+ domain: { data: 'table', field: 'periodId' },
206
+ range: 'width',
207
+ paddingInner: 0.35,
208
+ paddingOuter: 0.02,
209
+ },
210
+ {
211
+ name: 'xLabels',
212
+ type: 'ordinal',
213
+ domain: { data: 'periodLabels', field: 'periodId' },
214
+ range: { data: 'periodLabels', field: 'label' },
215
+ },
216
+ {
217
+ name: 'y',
218
+ type: 'linear',
219
+ domain: { data: 'table', field: 'y1' },
220
+ nice: true,
221
+ zero: true,
222
+ range: 'height',
223
+ },
224
+ {
225
+ name: 'color',
226
+ type: 'ordinal',
227
+ domain: uniqueCategories,
228
+ range: spec?.colorSet ?? CHART_COLORS,
229
+ },
230
+ ],
231
+ axes: [
232
+ {
233
+ orient: 'bottom',
234
+ scale: 'x',
235
+ title: spec?.xAxisTitle,
236
+ labelPadding: 12,
237
+ titlePadding: 12,
238
+ labelAngle: -90,
239
+ labelAlign: 'right',
240
+ labelBaseline: 'middle',
241
+ tickSize: 3,
242
+ labelFontSize: 12,
243
+ titleFontSize: 14,
244
+ ticks: false,
245
+ domain: false,
246
+ encode: {
247
+ labels: {
248
+ update: {
249
+ text: { signal: "scale('xLabels', datum.value)" },
250
+ },
251
+ },
252
+ },
253
+ },
254
+ {
255
+ orient: 'left',
256
+ scale: 'y',
257
+ title: spec?.yAxisTitle || '',
258
+ format: ',.0f',
259
+ grid: true,
260
+ tickCount: 6,
261
+ labelFontSize: 12,
262
+ titleFontSize: 14,
263
+ ticks: false,
264
+ domain: false,
265
+ tickBand: 'extent',
266
+ labelPadding: 10,
267
+ },
268
+ ],
269
+ legends: [
270
+ {
271
+ fill: 'color',
272
+ orient: 'bottom',
273
+ direction: 'horizontal',
274
+ columns: { signal: 'legendColumns' },
275
+ title: null,
276
+ symbolType: 'square',
277
+ rowPadding: 8,
278
+ symbolOffset: -35,
279
+ symbolSize: 100,
280
+ labelOffset: 8,
281
+ labelLimit: 95,
282
+ },
283
+ ],
284
+ marks: [
285
+ {
286
+ type: 'rect',
287
+ from: { data: 'table' },
288
+ encode: {
289
+ enter: {
290
+ x: { scale: 'x', field: 'periodId' },
291
+ width: { scale: 'x', band: 1 },
292
+ y: { scale: 'y', field: 'y1' },
293
+ y2: { scale: 'y', field: 'y0' },
294
+ fill: { scale: 'color', field: 'category' },
295
+ tooltip: {
296
+ signal: `datum.category + ': ${currencyPrefix}' + format(datum.value, ',${formatNumber}') + '\\nTotal: ${currencyPrefix}' + format(datum.total, ',${formatNumber}')`,
297
+ },
298
+ },
299
+ update: {
300
+ opacity: [{ test: 'hoveredPeriod && datum.period !== hoveredPeriod', value: 0.2 }, { value: 1 }],
301
+ },
302
+ },
303
+ },
304
+ ],
305
+ };
306
+ }
307
+ render() {
308
+ return (h(Host, { key: '86ed2e74e5abd57e684a93bc9cf6a014b3ed081c' }, h("div", { key: '96e5f7dd2dfa6a104ca709d1399308a86041c2f3', id: "container", style: { width: '100%', height: '100%' } })));
309
+ }
310
+ };
311
+
312
+ export { ApolloDataBarChart as apollo_data_bar_chart };