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