@xplortech/apollo-data 0.0.4 → 0.0.5
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-2nuV5Vny.js +1 -0
- package/dist/apollo-data/p-4ac3c97c.entry.js +1 -0
- package/dist/apollo-data/p-BWkrM8dc.js +11 -0
- package/dist/apollo-data/p-b7471c12.entry.js +1 -0
- package/dist/apollo-data/p-e518baac.entry.js +1 -0
- package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +314 -0
- package/dist/cjs/{apollo-data-bar-chart_2.cjs.entry.js → apollo-data-base-CxVQ-WVP.js} +1 -715
- package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +408 -0
- package/dist/cjs/apollo-data-line-chart_2.cjs.entry.js +534 -0
- package/dist/cjs/apollo-data.cjs.js +1 -1
- package/dist/cjs/constants-B3weDEpc.js +5 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/apollo-data-line/apollo-data-line.js +346 -0
- package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +329 -0
- package/dist/collection/examples/apollo-data-line.examples.js +91 -0
- package/dist/collection/examples/apollo-data-scatter.examples.js +94 -0
- package/dist/collection/examples/index.js +1 -0
- package/dist/components/apollo-data-bar-chart.js +1 -1
- package/dist/components/apollo-data-line-chart.d.ts +11 -0
- package/dist/components/apollo-data-line-chart.js +1 -0
- package/dist/components/apollo-data-scatter-chart.d.ts +11 -0
- package/dist/components/apollo-data-scatter-chart.js +1 -0
- package/dist/components/p-2nuV5Vny.js +1 -0
- package/dist/esm/apollo-data-bar-chart.entry.js +312 -0
- package/dist/esm/{apollo-data-bar-chart_2.entry.js → apollo-data-base-BWkrM8dc.js} +1 -714
- package/dist/esm/apollo-data-donut-chart.entry.js +406 -0
- package/dist/esm/apollo-data-line-chart_2.entry.js +531 -0
- package/dist/esm/apollo-data.js +1 -1
- package/dist/esm/constants-2nuV5Vny.js +3 -0
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/apollo-data-line/apollo-data-line.d.ts +244 -0
- package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +329 -0
- package/dist/types/components.d.ts +86 -0
- package/dist/types/examples/apollo-data-line.examples.d.ts +12 -0
- package/dist/types/examples/apollo-data-scatter.examples.d.ts +11 -0
- package/dist/types/examples/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/examples/apollo-data-line.examples.ts +103 -0
- package/src/examples/apollo-data-scatter.examples.ts +109 -0
- package/src/examples/index.ts +2 -1
- package/dist/apollo-data/p-e6584598.entry.js +0 -11
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { ApolloBase } from "../../apollo-data-base";
|
|
3
|
+
import { CHART_COLORS } from "../../utils/constants";
|
|
4
|
+
const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
|
|
5
|
+
function lineStyleToStrokeDash(lineStyle) {
|
|
6
|
+
switch (lineStyle) {
|
|
7
|
+
case 'dashed':
|
|
8
|
+
return [6, 4];
|
|
9
|
+
case 'dotted':
|
|
10
|
+
return [2, 2];
|
|
11
|
+
case 'solid':
|
|
12
|
+
default:
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class ApolloDataLineChart extends ApolloBase {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
el = null;
|
|
21
|
+
adData = [];
|
|
22
|
+
adSpec = null;
|
|
23
|
+
static tooltipStylesInjected = false;
|
|
24
|
+
componentDidLoad() {
|
|
25
|
+
this.injectTooltipStyles();
|
|
26
|
+
}
|
|
27
|
+
async componentDidRender() {
|
|
28
|
+
await this.renderChart();
|
|
29
|
+
}
|
|
30
|
+
injectTooltipStyles() {
|
|
31
|
+
if (ApolloDataLineChart.tooltipStylesInjected) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const styleId = 'apollo-data-line-tooltip-styles';
|
|
35
|
+
if (document.getElementById(styleId)) {
|
|
36
|
+
ApolloDataLineChart.tooltipStylesInjected = true;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const style = document.createElement('style');
|
|
40
|
+
style.id = styleId;
|
|
41
|
+
style.textContent = `
|
|
42
|
+
#vg-tooltip-element {
|
|
43
|
+
background-color: #ffffff;
|
|
44
|
+
border: 1px solid #e1e2e8;
|
|
45
|
+
border-radius: 0.25rem;
|
|
46
|
+
box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);
|
|
47
|
+
font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
padding: 0.25rem 0.75rem;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
text-align: center;
|
|
52
|
+
transform: translateY(20%);
|
|
53
|
+
white-space: pre;
|
|
54
|
+
z-index: 999999999;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#vg-tooltip-element table tr td.key {
|
|
58
|
+
color: #6a6d7d;
|
|
59
|
+
text-align: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#vg-tooltip-element table tr td.value {
|
|
63
|
+
text-align: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#vg-tooltip-element.dark-theme {
|
|
67
|
+
background-color: #292632;
|
|
68
|
+
border: 1px solid #6a6d7d;
|
|
69
|
+
box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);
|
|
70
|
+
color: #ffffff;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#vg-tooltip-element::after {
|
|
74
|
+
border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
|
|
75
|
+
border-style: solid;
|
|
76
|
+
border-width: 9px;
|
|
77
|
+
bottom: -17px;
|
|
78
|
+
content: '';
|
|
79
|
+
left: 50%;
|
|
80
|
+
position: absolute;
|
|
81
|
+
transform: translateX(-50%);
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
document.head.appendChild(style);
|
|
85
|
+
ApolloDataLineChart.tooltipStylesInjected = true;
|
|
86
|
+
}
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
async getViewData(data, spec) {
|
|
89
|
+
if (!spec) {
|
|
90
|
+
throw new Error('adSpec is required for apollo-data-line-chart');
|
|
91
|
+
}
|
|
92
|
+
const { tooltipPrefix = '', currencySymbol = '' } = spec;
|
|
93
|
+
if (!data || data.length === 0) {
|
|
94
|
+
throw new Error('Data is required for apollo-data-line-chart');
|
|
95
|
+
}
|
|
96
|
+
const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
|
|
97
|
+
const uniqueXValues = [...new Set(data.map(item => item.xValue))].sort((a, b) => a - b);
|
|
98
|
+
const colorSet = spec?.colorSet ?? CHART_COLORS;
|
|
99
|
+
const xLabelData = uniqueXValues.map(x => {
|
|
100
|
+
const first = data.find(d => d.xValue === x);
|
|
101
|
+
return { xValue: x, displayLabel: first?.xLabel != null ? first.xLabel : String(x) };
|
|
102
|
+
});
|
|
103
|
+
const formatNumber = tooltipPrefix ? '.2f' : '.0f';
|
|
104
|
+
const currencyPrefix = tooltipPrefix ? currencySymbol : '';
|
|
105
|
+
const pointShape = spec.pointStyle ?? 'circle';
|
|
106
|
+
const strokeDash = lineStyleToStrokeDash(spec.lineStyle ?? 'solid');
|
|
107
|
+
const dataSpec = [
|
|
108
|
+
{ name: 'raw', values: data },
|
|
109
|
+
{ name: 'xLabelData', values: xLabelData },
|
|
110
|
+
];
|
|
111
|
+
uniqueCategories.forEach((cat, i) => {
|
|
112
|
+
dataSpec.push({
|
|
113
|
+
name: `series_${i}`,
|
|
114
|
+
source: 'raw',
|
|
115
|
+
transform: [
|
|
116
|
+
{ type: 'filter', expr: `datum.category === ${JSON.stringify(cat)}` },
|
|
117
|
+
{ type: 'collect', sort: { field: 'xValue' } },
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
const lineMarks = uniqueCategories.map((_, i) => ({
|
|
122
|
+
type: 'line',
|
|
123
|
+
from: { data: `series_${i}` },
|
|
124
|
+
encode: {
|
|
125
|
+
enter: {
|
|
126
|
+
x: { scale: 'x', field: 'xValue' },
|
|
127
|
+
y: { scale: 'y', field: 'yValue' },
|
|
128
|
+
stroke: { value: colorSet[i % colorSet.length] },
|
|
129
|
+
strokeWidth: { value: 2 },
|
|
130
|
+
interpolate: { value: 'monotone' },
|
|
131
|
+
...(strokeDash.length > 0 ? { strokeDash: { value: strokeDash } } : {}),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
}));
|
|
135
|
+
return {
|
|
136
|
+
$schema: 'https://vega.github.io/schema/vega/v5.json',
|
|
137
|
+
config: {
|
|
138
|
+
text: {
|
|
139
|
+
fill: '#6a6d7d',
|
|
140
|
+
font: FONT_FAMILY,
|
|
141
|
+
labelFontSize: 12,
|
|
142
|
+
labelFontWeight: 400,
|
|
143
|
+
},
|
|
144
|
+
axis: {
|
|
145
|
+
labelColor: '#6a6d7d',
|
|
146
|
+
titleColor: '#6a6d7d',
|
|
147
|
+
labelFont: FONT_FAMILY,
|
|
148
|
+
titleFont: FONT_FAMILY,
|
|
149
|
+
titleFontWeight: 400,
|
|
150
|
+
},
|
|
151
|
+
legend: {
|
|
152
|
+
labelColor: '#6a6d7d',
|
|
153
|
+
titleColor: '#6a6d7d',
|
|
154
|
+
labelFont: FONT_FAMILY,
|
|
155
|
+
titleFont: FONT_FAMILY,
|
|
156
|
+
labelFontSize: 12,
|
|
157
|
+
labelLimit: 95,
|
|
158
|
+
},
|
|
159
|
+
title: {
|
|
160
|
+
color: '#6a6d7d',
|
|
161
|
+
font: FONT_FAMILY,
|
|
162
|
+
labelFontSize: 12,
|
|
163
|
+
labelFontWeight: 400,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
height: 250,
|
|
167
|
+
autosize: { type: 'fit-x', contains: 'padding', resize: true },
|
|
168
|
+
signals: [
|
|
169
|
+
{
|
|
170
|
+
name: 'containerW',
|
|
171
|
+
update: 'max(containerSize()[0], 400)',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'legendColumns',
|
|
175
|
+
update: 'ceil(containerW / 140)',
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
width: { signal: 'containerW' },
|
|
179
|
+
data: dataSpec,
|
|
180
|
+
scales: [
|
|
181
|
+
{
|
|
182
|
+
name: 'x',
|
|
183
|
+
type: 'point',
|
|
184
|
+
domain: uniqueXValues,
|
|
185
|
+
range: 'width',
|
|
186
|
+
padding: 0.5,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'xLabels',
|
|
190
|
+
type: 'ordinal',
|
|
191
|
+
domain: { data: 'xLabelData', field: 'xValue' },
|
|
192
|
+
range: { data: 'xLabelData', field: 'displayLabel' },
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'y',
|
|
196
|
+
type: 'linear',
|
|
197
|
+
domain: { data: 'raw', field: 'yValue' },
|
|
198
|
+
nice: true,
|
|
199
|
+
zero: true,
|
|
200
|
+
range: 'height',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'color',
|
|
204
|
+
type: 'ordinal',
|
|
205
|
+
domain: uniqueCategories,
|
|
206
|
+
range: spec?.colorSet ?? CHART_COLORS,
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
axes: [
|
|
210
|
+
{
|
|
211
|
+
orient: 'bottom',
|
|
212
|
+
scale: 'x',
|
|
213
|
+
title: spec?.xAxisTitle,
|
|
214
|
+
labelPadding: 12,
|
|
215
|
+
titlePadding: 12,
|
|
216
|
+
labelAngle: -90,
|
|
217
|
+
labelAlign: 'right',
|
|
218
|
+
labelBaseline: 'middle',
|
|
219
|
+
tickSize: 3,
|
|
220
|
+
labelFontSize: 12,
|
|
221
|
+
titleFontSize: 14,
|
|
222
|
+
ticks: false,
|
|
223
|
+
domain: false,
|
|
224
|
+
encode: {
|
|
225
|
+
labels: {
|
|
226
|
+
update: {
|
|
227
|
+
text: { signal: "scale('xLabels', datum.value)" },
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
orient: 'left',
|
|
234
|
+
scale: 'y',
|
|
235
|
+
title: spec?.yAxisTitle || '',
|
|
236
|
+
format: ',.0f',
|
|
237
|
+
grid: true,
|
|
238
|
+
tickCount: 6,
|
|
239
|
+
labelFontSize: 12,
|
|
240
|
+
titleFontSize: 14,
|
|
241
|
+
ticks: false,
|
|
242
|
+
domain: false,
|
|
243
|
+
tickBand: 'extent',
|
|
244
|
+
labelPadding: 10,
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
legends: [
|
|
248
|
+
{
|
|
249
|
+
stroke: 'color',
|
|
250
|
+
orient: 'bottom',
|
|
251
|
+
direction: 'horizontal',
|
|
252
|
+
columns: { signal: 'legendColumns' },
|
|
253
|
+
title: null,
|
|
254
|
+
symbolType: 'stroke',
|
|
255
|
+
symbolStrokeWidth: 3,
|
|
256
|
+
rowPadding: 8,
|
|
257
|
+
symbolOffset: -35,
|
|
258
|
+
symbolSize: 100,
|
|
259
|
+
labelOffset: 8,
|
|
260
|
+
labelLimit: 95,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
marks: [
|
|
264
|
+
...lineMarks,
|
|
265
|
+
{
|
|
266
|
+
type: 'symbol',
|
|
267
|
+
from: { data: 'raw' },
|
|
268
|
+
encode: {
|
|
269
|
+
enter: {
|
|
270
|
+
x: { scale: 'x', field: 'xValue' },
|
|
271
|
+
y: { scale: 'y', field: 'yValue' },
|
|
272
|
+
fill: { scale: 'color', field: 'category' },
|
|
273
|
+
size: { value: 50 },
|
|
274
|
+
shape: { value: pointShape },
|
|
275
|
+
tooltip: {
|
|
276
|
+
signal: `(datum.xLabel != null ? datum.xLabel : format(datum.xValue, ',.0f')) + ' · ' + datum.category + ': ' + (datum.yLabel != null ? datum.yLabel : '${currencyPrefix}' + format(datum.yValue, ',${formatNumber}'))`,
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
render() {
|
|
285
|
+
return (h(Host, { key: '7799f01536f212d7a06da08c1e463d8529c5bf21' }, h("div", { key: '25463f10bbc0f5443c35ab03b5b53164d9ad1efd', id: "container", style: { width: '100%', height: '100%' } })));
|
|
286
|
+
}
|
|
287
|
+
static get is() { return "apollo-data-line-chart"; }
|
|
288
|
+
static get encapsulation() { return "shadow"; }
|
|
289
|
+
static get properties() {
|
|
290
|
+
return {
|
|
291
|
+
"adData": {
|
|
292
|
+
"type": "string",
|
|
293
|
+
"mutable": false,
|
|
294
|
+
"complexType": {
|
|
295
|
+
"original": "string | LineDataItem[]",
|
|
296
|
+
"resolved": "LineDataItem[] | string",
|
|
297
|
+
"references": {
|
|
298
|
+
"LineDataItem": {
|
|
299
|
+
"location": "local",
|
|
300
|
+
"path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-line/apollo-data-line.tsx",
|
|
301
|
+
"id": "src/components/apollo-data-line/apollo-data-line.tsx::LineDataItem"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
"required": false,
|
|
306
|
+
"optional": false,
|
|
307
|
+
"docs": {
|
|
308
|
+
"tags": [],
|
|
309
|
+
"text": ""
|
|
310
|
+
},
|
|
311
|
+
"getter": false,
|
|
312
|
+
"setter": false,
|
|
313
|
+
"reflect": false,
|
|
314
|
+
"attribute": "ad-data",
|
|
315
|
+
"defaultValue": "[]"
|
|
316
|
+
},
|
|
317
|
+
"adSpec": {
|
|
318
|
+
"type": "string",
|
|
319
|
+
"mutable": false,
|
|
320
|
+
"complexType": {
|
|
321
|
+
"original": "string | LineSpec",
|
|
322
|
+
"resolved": "LineSpec | string",
|
|
323
|
+
"references": {
|
|
324
|
+
"LineSpec": {
|
|
325
|
+
"location": "local",
|
|
326
|
+
"path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-line/apollo-data-line.tsx",
|
|
327
|
+
"id": "src/components/apollo-data-line/apollo-data-line.tsx::LineSpec"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
"required": false,
|
|
332
|
+
"optional": false,
|
|
333
|
+
"docs": {
|
|
334
|
+
"tags": [],
|
|
335
|
+
"text": ""
|
|
336
|
+
},
|
|
337
|
+
"getter": false,
|
|
338
|
+
"setter": false,
|
|
339
|
+
"reflect": false,
|
|
340
|
+
"attribute": "ad-spec",
|
|
341
|
+
"defaultValue": "null"
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
static get elementRef() { return "el"; }
|
|
346
|
+
}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { ApolloBase } from "../../apollo-data-base";
|
|
3
|
+
export class ApolloDataScatterChart extends ApolloBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
el = null;
|
|
8
|
+
/**
|
|
9
|
+
* Represents a single data point in the scatter chart.
|
|
10
|
+
* @property {string} category - Category or group name associated with the data point.
|
|
11
|
+
* This can be used for legend grouping or category-based styling.
|
|
12
|
+
* @property {number} xValue - Numeric value plotted along the X-axis.
|
|
13
|
+
* @property {number} yValue - Numeric value plotted along the Y-axis.
|
|
14
|
+
* @property {PointStyle} [pointStyle] - Optional style override for this specific data point.
|
|
15
|
+
* If provided, it takes precedence over default or category-level styles.
|
|
16
|
+
*/
|
|
17
|
+
adData = [];
|
|
18
|
+
/**
|
|
19
|
+
* Optional specification object for customizing the scatter chart configuration.
|
|
20
|
+
* @property {string} [yAxisTitle] - Label displayed for the Y-axis.
|
|
21
|
+
* @property {string} [xAxisTitle] - Label displayed for the X-axis.
|
|
22
|
+
* @property {PointStyle} [defaultPointStyle] - Default styling applied to all scatter points (e.g., size, color, shape, opacity).
|
|
23
|
+
* @property {PointStyle} [pointStyle] - Global point style override applied to all data points.
|
|
24
|
+
* @property {{ [categoryName: string]: PointStyle }} [categoryPointStyleMap] -
|
|
25
|
+
* A mapping object that allows custom point styles per category name.
|
|
26
|
+
* Each key represents a category, and its value defines the corresponding PointStyle.
|
|
27
|
+
* @property {'auto' | 'none'} [tooltip] - Controls tooltip behavior.
|
|
28
|
+
* 'auto' enables default tooltip rendering, while 'none' disables tooltips.
|
|
29
|
+
*/
|
|
30
|
+
adSpec = {};
|
|
31
|
+
async componentDidRender() {
|
|
32
|
+
await this.renderChart();
|
|
33
|
+
}
|
|
34
|
+
DEFAULT_POINT_STYLE = {
|
|
35
|
+
shape: 'circle',
|
|
36
|
+
opacity: 1,
|
|
37
|
+
color: 'blue',
|
|
38
|
+
size: 1,
|
|
39
|
+
};
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
async getViewData(data, spec) {
|
|
42
|
+
const dataItemsToUse = data.map(dataItem => {
|
|
43
|
+
const pointStylesToUse = {};
|
|
44
|
+
Object.keys(this.DEFAULT_POINT_STYLE).forEach(key => {
|
|
45
|
+
const value = dataItem.pointStyle?.[key] ??
|
|
46
|
+
dataItem?.[key] ??
|
|
47
|
+
spec.categoryPointStyleMap?.[dataItem.category]?.[key] ??
|
|
48
|
+
spec.defaultPointStyle?.[key] ??
|
|
49
|
+
this.DEFAULT_POINT_STYLE[key];
|
|
50
|
+
pointStylesToUse[key] = value;
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
category: dataItem.category,
|
|
54
|
+
xValue: dataItem.xValue,
|
|
55
|
+
yValue: dataItem.yValue,
|
|
56
|
+
color: pointStylesToUse.color,
|
|
57
|
+
shape: pointStylesToUse.shape,
|
|
58
|
+
opacity: pointStylesToUse.opacity,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const tooltipField = spec?.tooltip === 'auto' ? 'category' : 'none';
|
|
62
|
+
return {
|
|
63
|
+
$schema: 'https://vega.github.io/schema/vega/v6.json',
|
|
64
|
+
description: 'A scatter plot with null values visualized along the axes.',
|
|
65
|
+
width: 450,
|
|
66
|
+
height: 450,
|
|
67
|
+
padding: 5,
|
|
68
|
+
autosize: { type: 'fit', resize: true },
|
|
69
|
+
signals: [
|
|
70
|
+
{ name: 'nullSize', value: 8 },
|
|
71
|
+
{ name: 'nullGap', update: 'nullSize + 10' },
|
|
72
|
+
],
|
|
73
|
+
data: [
|
|
74
|
+
{
|
|
75
|
+
name: 'source',
|
|
76
|
+
values: dataItemsToUse,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'valid',
|
|
80
|
+
source: 'source',
|
|
81
|
+
transform: [
|
|
82
|
+
{
|
|
83
|
+
type: 'filter',
|
|
84
|
+
expr: 'datum.xValue != null && datum.yValue != null',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'nullXY',
|
|
90
|
+
source: 'source',
|
|
91
|
+
transform: [
|
|
92
|
+
{
|
|
93
|
+
type: 'filter',
|
|
94
|
+
expr: 'datum.xValue == null && datum.yValue == null',
|
|
95
|
+
},
|
|
96
|
+
{ type: 'aggregate' },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'nullY',
|
|
101
|
+
source: 'source',
|
|
102
|
+
transform: [
|
|
103
|
+
{
|
|
104
|
+
type: 'filter',
|
|
105
|
+
expr: 'datum.xValue != null && datum.yValue == null',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'nullX',
|
|
111
|
+
source: 'source',
|
|
112
|
+
transform: [
|
|
113
|
+
{
|
|
114
|
+
type: 'filter',
|
|
115
|
+
expr: 'datum.xValue == null && datum.yValue != null',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
scales: [
|
|
121
|
+
{
|
|
122
|
+
name: 'xscale',
|
|
123
|
+
type: 'linear',
|
|
124
|
+
range: [{ signal: 'nullGap' }, { signal: 'width' }],
|
|
125
|
+
nice: true,
|
|
126
|
+
domain: { data: 'valid', field: 'xValue' },
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'yscale',
|
|
130
|
+
type: 'linear',
|
|
131
|
+
range: [{ signal: 'height - nullGap' }, 0],
|
|
132
|
+
nice: true,
|
|
133
|
+
domain: { data: 'valid', field: 'yValue' },
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
axes: [
|
|
137
|
+
{
|
|
138
|
+
orient: 'bottom',
|
|
139
|
+
scale: 'xscale',
|
|
140
|
+
offset: 5,
|
|
141
|
+
format: 's',
|
|
142
|
+
title: spec?.xAxisTitle || 'X Value',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
orient: 'left',
|
|
146
|
+
scale: 'yscale',
|
|
147
|
+
offset: 5,
|
|
148
|
+
format: 's',
|
|
149
|
+
title: spec?.yAxisTitle || 'Y Value',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
marks: [
|
|
153
|
+
{
|
|
154
|
+
type: 'symbol',
|
|
155
|
+
from: { data: 'valid' },
|
|
156
|
+
encode: {
|
|
157
|
+
enter: {
|
|
158
|
+
size: { value: 50 },
|
|
159
|
+
tooltip: { field: tooltipField },
|
|
160
|
+
},
|
|
161
|
+
update: {
|
|
162
|
+
x: { scale: 'xscale', field: 'xValue' },
|
|
163
|
+
y: { scale: 'yscale', field: 'yValue' },
|
|
164
|
+
fill: { field: 'color' },
|
|
165
|
+
fillOpacity: { field: 'opacity' },
|
|
166
|
+
shape: { field: 'shape' },
|
|
167
|
+
zindex: { value: 0 },
|
|
168
|
+
},
|
|
169
|
+
hover: {
|
|
170
|
+
fill: { value: 'firebrick' },
|
|
171
|
+
fillOpacity: { value: 1 },
|
|
172
|
+
zindex: { value: 1 },
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
type: 'symbol',
|
|
178
|
+
from: { data: 'nullY' },
|
|
179
|
+
encode: {
|
|
180
|
+
enter: {
|
|
181
|
+
size: { value: 50 },
|
|
182
|
+
tooltip: { field: tooltipField },
|
|
183
|
+
},
|
|
184
|
+
update: {
|
|
185
|
+
x: { scale: 'xscale', field: 'xValue' },
|
|
186
|
+
y: { signal: 'height - nullSize/2' },
|
|
187
|
+
fill: { value: '#aaa' },
|
|
188
|
+
fillOpacity: { value: 0.2 },
|
|
189
|
+
},
|
|
190
|
+
hover: {
|
|
191
|
+
fill: { value: 'firebrick' },
|
|
192
|
+
fillOpacity: { value: 1 },
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: 'symbol',
|
|
198
|
+
from: { data: 'nullX' },
|
|
199
|
+
encode: {
|
|
200
|
+
enter: {
|
|
201
|
+
size: { value: 50 },
|
|
202
|
+
tooltip: { field: 'name' },
|
|
203
|
+
},
|
|
204
|
+
update: {
|
|
205
|
+
x: { signal: 'nullSize/2' },
|
|
206
|
+
y: { scale: 'yscale', field: 'yValue' },
|
|
207
|
+
fill: { value: '#aaa' },
|
|
208
|
+
fillOpacity: { value: 0.2 },
|
|
209
|
+
zindex: { value: 0 },
|
|
210
|
+
},
|
|
211
|
+
hover: {
|
|
212
|
+
fill: { value: 'firebrick' },
|
|
213
|
+
fillOpacity: { value: 1 },
|
|
214
|
+
zindex: { value: 1 },
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
type: 'text',
|
|
220
|
+
interactive: false,
|
|
221
|
+
from: { data: 'nullXY' },
|
|
222
|
+
encode: {
|
|
223
|
+
update: {
|
|
224
|
+
x: { signal: 'nullSize', offset: -4 },
|
|
225
|
+
y: { signal: 'height', offset: 13 },
|
|
226
|
+
text: { signal: "datum.count + ' null'" },
|
|
227
|
+
align: { value: 'right' },
|
|
228
|
+
baseline: { value: 'top' },
|
|
229
|
+
fill: { value: '#999' },
|
|
230
|
+
fontSize: { value: 9 },
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
render() {
|
|
238
|
+
return (h(Host, { key: '60005ab926b0153b3e31729a69f5a64cf6558085' }, h("div", { key: '820de3e0ddbbc2650b9764e279d87531338e72e3', id: "container", style: { width: '100%', height: '100%' } })));
|
|
239
|
+
}
|
|
240
|
+
static get is() { return "apollo-data-scatter-chart"; }
|
|
241
|
+
static get encapsulation() { return "shadow"; }
|
|
242
|
+
static get properties() {
|
|
243
|
+
return {
|
|
244
|
+
"adData": {
|
|
245
|
+
"type": "string",
|
|
246
|
+
"mutable": false,
|
|
247
|
+
"complexType": {
|
|
248
|
+
"original": "string | ScatterDataItem[]",
|
|
249
|
+
"resolved": "ScatterDataItem[] | string",
|
|
250
|
+
"references": {
|
|
251
|
+
"ScatterDataItem": {
|
|
252
|
+
"location": "local",
|
|
253
|
+
"path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-scatter/apollo-data-scatter.tsx",
|
|
254
|
+
"id": "src/components/apollo-data-scatter/apollo-data-scatter.tsx::ScatterDataItem"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"required": false,
|
|
259
|
+
"optional": false,
|
|
260
|
+
"docs": {
|
|
261
|
+
"tags": [{
|
|
262
|
+
"name": "property",
|
|
263
|
+
"text": "{string} category - Category or group name associated with the data point.\nThis can be used for legend grouping or category-based styling."
|
|
264
|
+
}, {
|
|
265
|
+
"name": "property",
|
|
266
|
+
"text": "{number} xValue - Numeric value plotted along the X-axis."
|
|
267
|
+
}, {
|
|
268
|
+
"name": "property",
|
|
269
|
+
"text": "{number} yValue - Numeric value plotted along the Y-axis."
|
|
270
|
+
}, {
|
|
271
|
+
"name": "property",
|
|
272
|
+
"text": "{PointStyle} [pointStyle] - Optional style override for this specific data point.\nIf provided, it takes precedence over default or category-level styles."
|
|
273
|
+
}],
|
|
274
|
+
"text": "Represents a single data point in the scatter chart."
|
|
275
|
+
},
|
|
276
|
+
"getter": false,
|
|
277
|
+
"setter": false,
|
|
278
|
+
"reflect": false,
|
|
279
|
+
"attribute": "ad-data",
|
|
280
|
+
"defaultValue": "[]"
|
|
281
|
+
},
|
|
282
|
+
"adSpec": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string | ScatterSpec",
|
|
287
|
+
"resolved": "ScatterSpec | string",
|
|
288
|
+
"references": {
|
|
289
|
+
"ScatterSpec": {
|
|
290
|
+
"location": "local",
|
|
291
|
+
"path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-scatter/apollo-data-scatter.tsx",
|
|
292
|
+
"id": "src/components/apollo-data-scatter/apollo-data-scatter.tsx::ScatterSpec"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"required": false,
|
|
297
|
+
"optional": false,
|
|
298
|
+
"docs": {
|
|
299
|
+
"tags": [{
|
|
300
|
+
"name": "property",
|
|
301
|
+
"text": "{string} [yAxisTitle] - Label displayed for the Y-axis."
|
|
302
|
+
}, {
|
|
303
|
+
"name": "property",
|
|
304
|
+
"text": "{string} [xAxisTitle] - Label displayed for the X-axis."
|
|
305
|
+
}, {
|
|
306
|
+
"name": "property",
|
|
307
|
+
"text": "{PointStyle} [defaultPointStyle] - Default styling applied to all scatter points (e.g., size, color, shape, opacity)."
|
|
308
|
+
}, {
|
|
309
|
+
"name": "property",
|
|
310
|
+
"text": "{PointStyle} [pointStyle] - Global point style override applied to all data points."
|
|
311
|
+
}, {
|
|
312
|
+
"name": "property",
|
|
313
|
+
"text": "{{ [categoryName: string]: PointStyle }} [categoryPointStyleMap] -\nA mapping object that allows custom point styles per category name.\nEach key represents a category, and its value defines the corresponding PointStyle."
|
|
314
|
+
}, {
|
|
315
|
+
"name": "property",
|
|
316
|
+
"text": "{'auto' | 'none'} [tooltip] - Controls tooltip behavior.\n'auto' enables default tooltip rendering, while 'none' disables tooltips."
|
|
317
|
+
}],
|
|
318
|
+
"text": "Optional specification object for customizing the scatter chart configuration."
|
|
319
|
+
},
|
|
320
|
+
"getter": false,
|
|
321
|
+
"setter": false,
|
|
322
|
+
"reflect": false,
|
|
323
|
+
"attribute": "ad-spec",
|
|
324
|
+
"defaultValue": "{}"
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
static get elementRef() { return "el"; }
|
|
329
|
+
}
|