@xplortech/apollo-data 0.0.3-draft.64d0fa1
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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/apollo-data/apollo-data.esm.js +1 -0
- package/dist/apollo-data/index.esm.js +1 -0
- package/dist/apollo-data/p-Bb2nY-Tf.js +2 -0
- package/dist/apollo-data/p-DQuL1Twl.js +1 -0
- package/dist/apollo-data/p-e6584598.entry.js +11 -0
- package/dist/cjs/apollo-data-bar-chart_2.cjs.entry.js +68368 -0
- package/dist/cjs/apollo-data.cjs.js +25 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-Cl7HgRm0.js +1198 -0
- package/dist/cjs/index.cjs.js +7 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/collection/apollo-data-base.js +38 -0
- package/dist/collection/collection-manifest.json +13 -0
- package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +367 -0
- package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +479 -0
- package/dist/collection/examples/apollo-data-bar.examples.js +160 -0
- package/dist/collection/examples/apollo-data-donut.examples.js +100 -0
- package/dist/collection/examples/index.js +2 -0
- package/dist/collection/index.js +10 -0
- package/dist/collection/utils/code-generator.js +240 -0
- package/dist/collection/utils/constants.js +2 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/components/apollo-data-bar-chart.d.ts +11 -0
- package/dist/components/apollo-data-bar-chart.js +1 -0
- package/dist/components/apollo-data-donut-chart.d.ts +11 -0
- package/dist/components/apollo-data-donut-chart.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-7XF5Cax8.js +11 -0
- package/dist/components/p-Dws5s-Xe.js +1 -0
- package/dist/esm/apollo-data-bar-chart_2.entry.js +68365 -0
- package/dist/esm/apollo-data.js +21 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-Bb2nY-Tf.js +1190 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/loader.js +11 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/apollo-data-base.d.ts +7 -0
- package/dist/types/components/apollo-data-bar/apollo-data-bar.d.ts +298 -0
- package/dist/types/components/apollo-data-donut/apollo-data-donut.d.ts +533 -0
- package/dist/types/components.d.ts +102 -0
- package/dist/types/examples/apollo-data-bar.examples.d.ts +12 -0
- package/dist/types/examples/apollo-data-donut.examples.d.ts +11 -0
- package/dist/types/examples/index.d.ts +2 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1839 -0
- package/dist/types/utils/code-generator.d.ts +12 -0
- package/dist/types/utils/constants.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +92 -0
- package/src/examples/apollo-data-bar.examples.ts +172 -0
- package/src/examples/apollo-data-donut.examples.ts +118 -0
- package/src/examples/index.ts +2 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { ApolloBase } from "../../apollo-data-base";
|
|
3
|
+
export class ApolloDataDonutChart extends ApolloBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
el = null;
|
|
8
|
+
/**
|
|
9
|
+
* Array of data items to display in the donut chart. Each item represents a segment with category and value.
|
|
10
|
+
* @property {string} category - Category name for the data segment
|
|
11
|
+
* @property {number} value - Numeric value for the donut chart segment
|
|
12
|
+
*/
|
|
13
|
+
adData = [];
|
|
14
|
+
/**
|
|
15
|
+
* Optional specification object for customizing the chart appearance
|
|
16
|
+
* @property {string[]} [colorSet] - Array of color hex codes for chart segments
|
|
17
|
+
* @property {string} [preffix] - A string added at the start of another string, like $ or a currency symbol.
|
|
18
|
+
* @property {string} [suffix] - A string added at the end of another string, like %, kg or a currency symbol.
|
|
19
|
+
* @property {string} [centerText] - A label string rendered at the center of the view.
|
|
20
|
+
*/
|
|
21
|
+
adSpec = {};
|
|
22
|
+
categories;
|
|
23
|
+
dataValues;
|
|
24
|
+
totalRevenue;
|
|
25
|
+
chartColors;
|
|
26
|
+
defaultChartColors = ['#4d1ab2', '#f99170', '#e550c8', '#ffd563', '#8857fa', '#52ebba', '#bf1d78', '#31cff8'];
|
|
27
|
+
defaultCenterText = 'Total Revenue';
|
|
28
|
+
async componentDidRender() {
|
|
29
|
+
await this.renderChart();
|
|
30
|
+
}
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
async getViewData(data, spec) {
|
|
33
|
+
const dataValues = data;
|
|
34
|
+
this.chartColors = spec?.colorSet ? spec.colorSet : this.defaultChartColors;
|
|
35
|
+
this.categories = dataValues.map(item => item.category);
|
|
36
|
+
this.dataValues = dataValues.map((item, index) => ({
|
|
37
|
+
...item,
|
|
38
|
+
order: index + 1,
|
|
39
|
+
}));
|
|
40
|
+
this.totalRevenue = Math.round(dataValues.reduce((prev, curr) => prev + curr.value, 0) * 100) / 100;
|
|
41
|
+
return {
|
|
42
|
+
$schema: 'https://vega.github.io/schema/vega/v5.json',
|
|
43
|
+
description: "Donut chart with correctly placed percentage labels and exploded 'Other' slices on hover",
|
|
44
|
+
height: 250,
|
|
45
|
+
signals: [
|
|
46
|
+
{
|
|
47
|
+
name: 'containerW',
|
|
48
|
+
update: 'min(containerSize()[0], 400)',
|
|
49
|
+
},
|
|
50
|
+
{ name: 'centerX', update: 'containerW / 2' },
|
|
51
|
+
{ name: 'centerY', update: '250 / 2' },
|
|
52
|
+
{ name: 'radius', update: 'min(containerW, 250) / 2 - 20' },
|
|
53
|
+
{
|
|
54
|
+
name: 'categoryDisplay',
|
|
55
|
+
value: null,
|
|
56
|
+
on: [
|
|
57
|
+
{
|
|
58
|
+
events: { type: 'mouseover', markname: 'mainArc' },
|
|
59
|
+
update: 'datum.category',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
events: {
|
|
63
|
+
type: 'mouseover',
|
|
64
|
+
markname: 'mainArcLabel',
|
|
65
|
+
},
|
|
66
|
+
update: 'datum.category',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
events: { type: 'mouseout', markname: 'mainArc' },
|
|
70
|
+
update: 'null',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
events: {
|
|
74
|
+
type: 'mouseout',
|
|
75
|
+
markname: 'mainArcLabel',
|
|
76
|
+
},
|
|
77
|
+
update: 'null',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
events: { type: 'mouseover', markname: 'innerArc' },
|
|
81
|
+
update: 'null',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
events: { type: 'mouseover', markname: 'outerArc' },
|
|
85
|
+
update: 'null',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
events: { type: 'mouseover', markname: 'otherArc' },
|
|
89
|
+
update: 'datum.category',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
events: { type: 'mouseout', markname: 'otherArc' },
|
|
93
|
+
update: 'null',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'displayText',
|
|
99
|
+
update: `categoryDisplay && length(categoryDisplay) > 18 ? (lastindexof(categoryDisplay, ' ') > 0 ? slice(categoryDisplay, 0, lastindexof(categoryDisplay, ' ')) + '\\n' + slice(categoryDisplay, lastindexof(categoryDisplay, ' ') + 1) : categoryDisplay) : categoryDisplay || '${spec?.centerText ? spec.centerText : this.defaultCenterText}'`,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'hoveredCategory',
|
|
103
|
+
value: null,
|
|
104
|
+
on: [
|
|
105
|
+
{
|
|
106
|
+
events: { type: 'mouseover', markname: 'mainArc' },
|
|
107
|
+
update: 'datum.category',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
events: {
|
|
111
|
+
type: 'mouseover',
|
|
112
|
+
markname: 'mainArcLabel',
|
|
113
|
+
},
|
|
114
|
+
update: 'datum.category',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
events: { type: 'mouseover', markname: 'outerArc' },
|
|
118
|
+
update: 'null',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
events: { type: 'mouseover', markname: 'innerArc' },
|
|
122
|
+
update: 'null',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
events: { type: 'mouseout', markname: 'innerArc' },
|
|
126
|
+
update: 'null',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'hoveredValue',
|
|
132
|
+
value: null,
|
|
133
|
+
on: [
|
|
134
|
+
{
|
|
135
|
+
events: { type: 'mouseover', markname: 'mainArc' },
|
|
136
|
+
update: 'datum.value',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
events: {
|
|
140
|
+
type: 'mouseover',
|
|
141
|
+
markname: 'mainArcLabel',
|
|
142
|
+
},
|
|
143
|
+
update: 'datum.value',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
events: { type: 'mouseout', markname: 'mainArc' },
|
|
147
|
+
update: 'null',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
events: { type: 'mouseover', markname: 'otherArc' },
|
|
151
|
+
update: 'datum.value',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
events: { type: 'mouseout', markname: 'otherArc' },
|
|
155
|
+
update: 'null',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
width: { signal: 'containerW' },
|
|
161
|
+
data: [
|
|
162
|
+
{
|
|
163
|
+
name: 'table',
|
|
164
|
+
values: this.dataValues,
|
|
165
|
+
transform: [
|
|
166
|
+
{
|
|
167
|
+
type: 'joinaggregate',
|
|
168
|
+
fields: ['value'],
|
|
169
|
+
ops: ['sum'],
|
|
170
|
+
as: ['total'],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
type: 'formula',
|
|
174
|
+
as: 'percent',
|
|
175
|
+
expr: 'datum.value / datum.total',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: 'collect',
|
|
179
|
+
sort: { field: 'order', order: 'descending' },
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: 'pie',
|
|
183
|
+
field: 'value',
|
|
184
|
+
as: ['startAngle', 'endAngle'],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
type: 'formula',
|
|
188
|
+
as: 'midAngle',
|
|
189
|
+
expr: '((datum.startAngle + datum.endAngle) + 9.418) / 2',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: 'formula',
|
|
193
|
+
as: 'labelX',
|
|
194
|
+
expr: 'centerX + (radius * 1.2 * cos(datum.midAngle))',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: 'formula',
|
|
198
|
+
as: 'labelY',
|
|
199
|
+
expr: 'centerY + (radius * 1.2 * sin(datum.midAngle))',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
type: 'formula',
|
|
203
|
+
as: 'percentLabel',
|
|
204
|
+
expr: `format(datum.value / ${this.totalRevenue} * 100, '.1f') + '%'`,
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'defaultCenterText',
|
|
210
|
+
values: [
|
|
211
|
+
{
|
|
212
|
+
category: spec?.centerText ? spec.centerText : this.defaultCenterText,
|
|
213
|
+
value: this.totalRevenue,
|
|
214
|
+
order: 4,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
transform: [
|
|
218
|
+
{ type: 'filter', expr: 'hoveredCategory === null' },
|
|
219
|
+
{
|
|
220
|
+
type: 'formula',
|
|
221
|
+
as: 'textDisplay',
|
|
222
|
+
expr: `'${spec?.prefix ?? '$'}' + format(floor(datum.value), ',') + '${spec?.suffix ?? ''}' `,
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
scales: [
|
|
228
|
+
{
|
|
229
|
+
name: 'mainColor',
|
|
230
|
+
type: 'ordinal',
|
|
231
|
+
domain: this.categories,
|
|
232
|
+
range: this.chartColors,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
legends: [
|
|
236
|
+
{
|
|
237
|
+
fill: 'mainColor',
|
|
238
|
+
orient: 'bottom',
|
|
239
|
+
direction: 'horizontal',
|
|
240
|
+
columns: 2,
|
|
241
|
+
title: '',
|
|
242
|
+
padding: 10,
|
|
243
|
+
symbolType: 'square',
|
|
244
|
+
symbolSize: 100,
|
|
245
|
+
labelFontSize: 12,
|
|
246
|
+
labelColor: '#6A6D7D',
|
|
247
|
+
rowPadding: 8,
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
marks: [
|
|
251
|
+
{
|
|
252
|
+
type: 'rule',
|
|
253
|
+
name: 'labelLines',
|
|
254
|
+
from: { data: 'table' },
|
|
255
|
+
encode: {
|
|
256
|
+
enter: {
|
|
257
|
+
stroke: { value: 'black' }, // line color
|
|
258
|
+
strokeWidth: { value: 1 },
|
|
259
|
+
x: {
|
|
260
|
+
signal: 'centerX + (radius * 0.9) * cos(datum.midAngle)',
|
|
261
|
+
},
|
|
262
|
+
y: {
|
|
263
|
+
signal: 'centerY + (radius * 0.9) * sin(datum.midAngle)',
|
|
264
|
+
},
|
|
265
|
+
x2: {
|
|
266
|
+
signal: 'datum.labelX - 12 * cos(datum.midAngle)', // <-- added offset
|
|
267
|
+
},
|
|
268
|
+
y2: {
|
|
269
|
+
signal: 'datum.labelY - 12 * sin(datum.midAngle)', // <-- added offset
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
update: {
|
|
273
|
+
opacity: { value: 1 },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
zindex: 5,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
type: 'arc',
|
|
280
|
+
name: 'mainArc',
|
|
281
|
+
from: { data: 'table' },
|
|
282
|
+
encode: {
|
|
283
|
+
enter: {
|
|
284
|
+
fill: { scale: 'mainColor', field: 'category' },
|
|
285
|
+
x: { signal: 'centerX' },
|
|
286
|
+
y: { signal: 'centerY' },
|
|
287
|
+
startAngle: { field: 'startAngle' },
|
|
288
|
+
endAngle: { field: 'endAngle' },
|
|
289
|
+
innerRadius: { signal: 'radius * 0.5' },
|
|
290
|
+
outerRadius: { signal: 'radius * 0.9' },
|
|
291
|
+
padAngle: { value: 0.03 },
|
|
292
|
+
cornerRadius: { value: 1 },
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
interactive: true,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
type: 'arc',
|
|
299
|
+
name: 'innerArc',
|
|
300
|
+
from: { data: 'table' },
|
|
301
|
+
encode: {
|
|
302
|
+
enter: {
|
|
303
|
+
fill: { value: 'transparent' },
|
|
304
|
+
x: { signal: 'centerX' },
|
|
305
|
+
y: { signal: 'centerY' },
|
|
306
|
+
startAngle: { field: 'startAngle' },
|
|
307
|
+
endAngle: { field: 'endAngle' },
|
|
308
|
+
innerRadius: { signal: 'radius * 0.4' },
|
|
309
|
+
outerRadius: { signal: 'radius * 0.5' },
|
|
310
|
+
padAngle: { value: 0.03 },
|
|
311
|
+
cornerRadius: { value: 1 },
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
zindex: 1,
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
type: 'arc',
|
|
318
|
+
name: 'outerArc',
|
|
319
|
+
from: { data: 'table' },
|
|
320
|
+
encode: {
|
|
321
|
+
enter: {
|
|
322
|
+
fill: { value: 'transparent' },
|
|
323
|
+
x: { signal: 'centerX' },
|
|
324
|
+
y: { signal: 'centerY' },
|
|
325
|
+
startAngle: { field: 'startAngle' },
|
|
326
|
+
endAngle: { field: 'endAngle' },
|
|
327
|
+
innerRadius: { signal: 'radius * 0.91' },
|
|
328
|
+
outerRadius: { signal: 'radius * 1.30' },
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
zindex: 1,
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
type: 'text',
|
|
335
|
+
name: 'mainArcLabel',
|
|
336
|
+
from: { data: 'table' },
|
|
337
|
+
encode: {
|
|
338
|
+
enter: {
|
|
339
|
+
text: { field: 'percentLabel' },
|
|
340
|
+
align: { value: 'center' },
|
|
341
|
+
baseline: { value: 'middle' },
|
|
342
|
+
fill: { value: '#302D3B' },
|
|
343
|
+
fontSize: { value: 10 },
|
|
344
|
+
x: { field: 'labelX' },
|
|
345
|
+
y: { field: 'labelY' },
|
|
346
|
+
font: {
|
|
347
|
+
value: "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif",
|
|
348
|
+
},
|
|
349
|
+
fontWeight: 600,
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
type: 'text',
|
|
355
|
+
encode: {
|
|
356
|
+
enter: {
|
|
357
|
+
text: { value: '$850,000' },
|
|
358
|
+
x: { signal: 'centerX' },
|
|
359
|
+
y: { signal: 'centerY' },
|
|
360
|
+
align: { value: 'center' },
|
|
361
|
+
baseline: { value: 'middle' },
|
|
362
|
+
fontSize: { value: 16 },
|
|
363
|
+
fontWeight: { value: 'bold' },
|
|
364
|
+
fill: { value: '#302D3B' },
|
|
365
|
+
font: {
|
|
366
|
+
value: "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif",
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
update: {
|
|
370
|
+
text: {
|
|
371
|
+
signal: `hoveredValue ? '${spec?.prefix ?? '$'}' + format(floor(hoveredValue), ',') + '${spec?.suffix ?? ''}' : '${spec?.prefix ?? '$'}' + format(floor(${this.totalRevenue ?? 1}), ',') + '${spec?.suffix ?? ''}'`,
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
type: 'text',
|
|
378
|
+
encode: {
|
|
379
|
+
enter: {
|
|
380
|
+
x: { signal: 'centerX' },
|
|
381
|
+
y: { signal: 'centerY + 15' },
|
|
382
|
+
align: { value: 'center' },
|
|
383
|
+
baseline: { value: 'middle' },
|
|
384
|
+
fontSize: { value: 10 },
|
|
385
|
+
fill: { value: '#6A6D7D' },
|
|
386
|
+
font: {
|
|
387
|
+
value: "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif",
|
|
388
|
+
},
|
|
389
|
+
fontWeight: 400,
|
|
390
|
+
limit: { value: 100 },
|
|
391
|
+
lineBreak: { value: '\\n' },
|
|
392
|
+
},
|
|
393
|
+
update: { text: { signal: 'displayText' } },
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
render() {
|
|
400
|
+
return (h(Host, { key: 'fb26a6b02b83b0ce64a8301149b66f5d09a4a7b4' }, h("div", { key: 'fc08cdc3c0c0fda7f7c13149532eb61f511aa035', id: "container", style: { width: '100%', height: '100%' } })));
|
|
401
|
+
}
|
|
402
|
+
static get is() { return "apollo-data-donut-chart"; }
|
|
403
|
+
static get encapsulation() { return "shadow"; }
|
|
404
|
+
static get properties() {
|
|
405
|
+
return {
|
|
406
|
+
"adData": {
|
|
407
|
+
"type": "string",
|
|
408
|
+
"mutable": false,
|
|
409
|
+
"complexType": {
|
|
410
|
+
"original": "string | DonutDataItem[]",
|
|
411
|
+
"resolved": "DonutDataItem[] | string",
|
|
412
|
+
"references": {
|
|
413
|
+
"DonutDataItem": {
|
|
414
|
+
"location": "local",
|
|
415
|
+
"path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-donut/apollo-data-donut.tsx",
|
|
416
|
+
"id": "src/components/apollo-data-donut/apollo-data-donut.tsx::DonutDataItem"
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"required": false,
|
|
421
|
+
"optional": false,
|
|
422
|
+
"docs": {
|
|
423
|
+
"tags": [{
|
|
424
|
+
"name": "property",
|
|
425
|
+
"text": "{string} category - Category name for the data segment"
|
|
426
|
+
}, {
|
|
427
|
+
"name": "property",
|
|
428
|
+
"text": "{number} value - Numeric value for the donut chart segment"
|
|
429
|
+
}],
|
|
430
|
+
"text": "Array of data items to display in the donut chart. Each item represents a segment with category and value."
|
|
431
|
+
},
|
|
432
|
+
"getter": false,
|
|
433
|
+
"setter": false,
|
|
434
|
+
"reflect": false,
|
|
435
|
+
"attribute": "ad-data",
|
|
436
|
+
"defaultValue": "[]"
|
|
437
|
+
},
|
|
438
|
+
"adSpec": {
|
|
439
|
+
"type": "string",
|
|
440
|
+
"mutable": false,
|
|
441
|
+
"complexType": {
|
|
442
|
+
"original": "string | DonutSpec",
|
|
443
|
+
"resolved": "DonutSpec | string",
|
|
444
|
+
"references": {
|
|
445
|
+
"DonutSpec": {
|
|
446
|
+
"location": "local",
|
|
447
|
+
"path": "/home/runner/work/apollo/apollo/packages/apollo-data/src/components/apollo-data-donut/apollo-data-donut.tsx",
|
|
448
|
+
"id": "src/components/apollo-data-donut/apollo-data-donut.tsx::DonutSpec"
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
"required": false,
|
|
453
|
+
"optional": false,
|
|
454
|
+
"docs": {
|
|
455
|
+
"tags": [{
|
|
456
|
+
"name": "property",
|
|
457
|
+
"text": "{string[]} [colorSet] - Array of color hex codes for chart segments"
|
|
458
|
+
}, {
|
|
459
|
+
"name": "property",
|
|
460
|
+
"text": "{string} [preffix] - A string added at the start of another string, like $ or a currency symbol."
|
|
461
|
+
}, {
|
|
462
|
+
"name": "property",
|
|
463
|
+
"text": "{string} [suffix] - A string added at the end of another string, like %, kg or a currency symbol."
|
|
464
|
+
}, {
|
|
465
|
+
"name": "property",
|
|
466
|
+
"text": "{string} [centerText] - A label string rendered at the center of the view."
|
|
467
|
+
}],
|
|
468
|
+
"text": "Optional specification object for customizing the chart appearance"
|
|
469
|
+
},
|
|
470
|
+
"getter": false,
|
|
471
|
+
"setter": false,
|
|
472
|
+
"reflect": false,
|
|
473
|
+
"attribute": "ad-spec",
|
|
474
|
+
"defaultValue": "{}"
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
static get elementRef() { return "el"; }
|
|
479
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/** periodId should be a date string (YYYY-MM-DD) representing the period. */
|
|
2
|
+
export const barExamples = [
|
|
3
|
+
{
|
|
4
|
+
name: 'Revenue and Expenses by Day',
|
|
5
|
+
description: 'A stacked bar chart showing daily revenue and expenses over a week',
|
|
6
|
+
props: {
|
|
7
|
+
adData: [
|
|
8
|
+
{ label: 'Mon', category: 'Revenue', value: 5000, periodId: '2024-01-01' },
|
|
9
|
+
{ label: 'Mon', category: 'Expenses', value: 2000, periodId: '2024-01-01' },
|
|
10
|
+
{ label: 'Tue', category: 'Revenue', value: 6000, periodId: '2024-01-02' },
|
|
11
|
+
{ label: 'Tue', category: 'Expenses', value: 2500, periodId: '2024-01-02' },
|
|
12
|
+
{ label: 'Wed', category: 'Revenue', value: 5500, periodId: '2024-01-03' },
|
|
13
|
+
{ label: 'Wed', category: 'Expenses', value: 2200, periodId: '2024-01-03' },
|
|
14
|
+
{ label: 'Thu', category: 'Revenue', value: 7000, periodId: '2024-01-04' },
|
|
15
|
+
{ label: 'Thu', category: 'Expenses', value: 3000, periodId: '2024-01-04' },
|
|
16
|
+
{ label: 'Fri', category: 'Revenue', value: 6500, periodId: '2024-01-05' },
|
|
17
|
+
{ label: 'Fri', category: 'Expenses', value: 2800, periodId: '2024-01-05' },
|
|
18
|
+
],
|
|
19
|
+
adSpec: {
|
|
20
|
+
tooltipPrefix: '$',
|
|
21
|
+
currencySymbol: '$',
|
|
22
|
+
yAxisTitle: 'Amount',
|
|
23
|
+
colorSet: ['#FF8DF4', '#74FBD0'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'Monthly Sales by Product',
|
|
29
|
+
description: 'Stacked bar chart showing sales across multiple products by month',
|
|
30
|
+
props: {
|
|
31
|
+
adData: [
|
|
32
|
+
{ label: 'Jan', category: 'Product A', value: 12000, periodId: '2024-01-01' },
|
|
33
|
+
{ label: 'Jan', category: 'Product B', value: 8000, periodId: '2024-01-01' },
|
|
34
|
+
{ label: 'Jan', category: 'Product C', value: 6000, periodId: '2024-01-01' },
|
|
35
|
+
{ label: 'Feb', category: 'Product A', value: 15000, periodId: '2024-02-01' },
|
|
36
|
+
{ label: 'Feb', category: 'Product B', value: 9000, periodId: '2024-02-01' },
|
|
37
|
+
{ label: 'Feb', category: 'Product C', value: 7000, periodId: '2024-02-01' },
|
|
38
|
+
{ label: 'Mar', category: 'Product A', value: 13000, periodId: '2024-03-01' },
|
|
39
|
+
{ label: 'Mar', category: 'Product B', value: 10000, periodId: '2024-03-01' },
|
|
40
|
+
{ label: 'Mar', category: 'Product C', value: 5500, periodId: '2024-03-01' },
|
|
41
|
+
{ label: 'Apr', category: 'Product A', value: 14000, periodId: '2024-04-01' },
|
|
42
|
+
{ label: 'Apr', category: 'Product B', value: 9500, periodId: '2024-04-01' },
|
|
43
|
+
{ label: 'Apr', category: 'Product C', value: 6500, periodId: '2024-04-01' },
|
|
44
|
+
],
|
|
45
|
+
adSpec: {
|
|
46
|
+
tooltipPrefix: '$',
|
|
47
|
+
currencySymbol: '$',
|
|
48
|
+
yAxisTitle: 'Monthly Sales',
|
|
49
|
+
colorSet: ['#FF8DF4', '#74FBD0', '#ECFD91'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Weekly Revenue by Category',
|
|
55
|
+
description: 'Stacked bar chart showing revenue across Sales, Marketing, and Product',
|
|
56
|
+
props: {
|
|
57
|
+
adData: [
|
|
58
|
+
{ label: 'W1', category: 'Sales', value: 3500, periodId: '2024-01-01' },
|
|
59
|
+
{ label: 'W1', category: 'Marketing', value: 2200, periodId: '2024-01-01' },
|
|
60
|
+
{ label: 'W1', category: 'Product A', value: 1800, periodId: '2024-01-01' },
|
|
61
|
+
{ label: 'W2', category: 'Sales', value: 4200, periodId: '2024-01-08' },
|
|
62
|
+
{ label: 'W2', category: 'Marketing', value: 2800, periodId: '2024-01-08' },
|
|
63
|
+
{ label: 'W2', category: 'Product A', value: 2000, periodId: '2024-01-08' },
|
|
64
|
+
{ label: 'W3', category: 'Sales', value: 3800, periodId: '2024-01-15' },
|
|
65
|
+
{ label: 'W3', category: 'Marketing', value: 2500, periodId: '2024-01-15' },
|
|
66
|
+
{ label: 'W3', category: 'Product A', value: 1900, periodId: '2024-01-15' },
|
|
67
|
+
],
|
|
68
|
+
adSpec: {
|
|
69
|
+
tooltipPrefix: '$',
|
|
70
|
+
currencySymbol: '$',
|
|
71
|
+
yAxisTitle: 'Weekly Revenue',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'Yearly Regional Revenue',
|
|
77
|
+
description: 'Stacked bar chart showing revenue across regions by year',
|
|
78
|
+
props: {
|
|
79
|
+
adData: [
|
|
80
|
+
{ label: '2019', category: 'North America', value: 450000, periodId: '2019-01-01' },
|
|
81
|
+
{ label: '2019', category: 'Europe', value: 320000, periodId: '2019-01-01' },
|
|
82
|
+
{ label: '2019', category: 'Asia Pacific', value: 280000, periodId: '2019-01-01' },
|
|
83
|
+
{ label: '2020', category: 'North America', value: 380000, periodId: '2020-01-01' },
|
|
84
|
+
{ label: '2020', category: 'Europe', value: 290000, periodId: '2020-01-01' },
|
|
85
|
+
{ label: '2020', category: 'Asia Pacific', value: 310000, periodId: '2020-01-01' },
|
|
86
|
+
{ label: '2021', category: 'North America', value: 520000, periodId: '2021-01-01' },
|
|
87
|
+
{ label: '2021', category: 'Europe', value: 410000, periodId: '2021-01-01' },
|
|
88
|
+
{ label: '2021', category: 'Asia Pacific', value: 450000, periodId: '2021-01-01' },
|
|
89
|
+
{ label: '2022', category: 'North America', value: 580000, periodId: '2022-01-01' },
|
|
90
|
+
{ label: '2022', category: 'Europe', value: 460000, periodId: '2022-01-01' },
|
|
91
|
+
{ label: '2022', category: 'Asia Pacific', value: 520000, periodId: '2022-01-01' },
|
|
92
|
+
],
|
|
93
|
+
adSpec: {
|
|
94
|
+
tooltipPrefix: '$',
|
|
95
|
+
currencySymbol: '$',
|
|
96
|
+
yAxisTitle: 'Regional Revenue',
|
|
97
|
+
colorSet: ['#4d1ab2', '#f99170', '#e550c8'],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'Order Counts by Channel',
|
|
103
|
+
description: 'Bar chart showing order counts by channel without currency formatting',
|
|
104
|
+
props: {
|
|
105
|
+
adData: [
|
|
106
|
+
{ label: 'Mon', category: 'Website', value: 1250, periodId: '2024-05-01' },
|
|
107
|
+
{ label: 'Mon', category: 'Mobile App', value: 890, periodId: '2024-05-01' },
|
|
108
|
+
{ label: 'Mon', category: 'In-Store', value: 450, periodId: '2024-05-01' },
|
|
109
|
+
{ label: 'Tue', category: 'Website', value: 1380, periodId: '2024-05-02' },
|
|
110
|
+
{ label: 'Tue', category: 'Mobile App', value: 920, periodId: '2024-05-02' },
|
|
111
|
+
{ label: 'Tue', category: 'In-Store', value: 480, periodId: '2024-05-02' },
|
|
112
|
+
{ label: 'Wed', category: 'Website', value: 1150, periodId: '2024-05-03' },
|
|
113
|
+
{ label: 'Wed', category: 'Mobile App', value: 850, periodId: '2024-05-03' },
|
|
114
|
+
{ label: 'Wed', category: 'In-Store', value: 420, periodId: '2024-05-03' },
|
|
115
|
+
],
|
|
116
|
+
adSpec: {
|
|
117
|
+
yAxisTitle: 'Order Count',
|
|
118
|
+
colorSet: ['#8857fa', '#52ebba', '#31cff8'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'Single Category',
|
|
124
|
+
description: 'Bar chart with a single category showing visitor counts by day',
|
|
125
|
+
props: {
|
|
126
|
+
adData: [
|
|
127
|
+
{ label: 'Mon', category: 'Visitors', value: 2450, periodId: '2024-04-01' },
|
|
128
|
+
{ label: 'Tue', category: 'Visitors', value: 2680, periodId: '2024-04-02' },
|
|
129
|
+
{ label: 'Wed', category: 'Visitors', value: 2320, periodId: '2024-04-03' },
|
|
130
|
+
{ label: 'Thu', category: 'Visitors', value: 2890, periodId: '2024-04-04' },
|
|
131
|
+
{ label: 'Fri', category: 'Visitors', value: 3150, periodId: '2024-04-05' },
|
|
132
|
+
{ label: 'Sat', category: 'Visitors', value: 3420, periodId: '2024-04-06' },
|
|
133
|
+
{ label: 'Sun', category: 'Visitors', value: 3280, periodId: '2024-04-07' },
|
|
134
|
+
],
|
|
135
|
+
adSpec: {
|
|
136
|
+
yAxisTitle: 'Daily Visitors',
|
|
137
|
+
colorSet: ['#6366f1'],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'Custom Axis Titles',
|
|
143
|
+
description: 'Chart with custom x-axis and y-axis titles via xAxisTitle and yAxisTitle',
|
|
144
|
+
props: {
|
|
145
|
+
adData: [
|
|
146
|
+
{ label: 'Mon', category: 'Inbound', value: 120, periodId: '2024-06-01' },
|
|
147
|
+
{ label: 'Mon', category: 'Outbound', value: 80, periodId: '2024-06-01' },
|
|
148
|
+
{ label: 'Tue', category: 'Inbound', value: 95, periodId: '2024-06-02' },
|
|
149
|
+
{ label: 'Tue', category: 'Outbound', value: 110, periodId: '2024-06-02' },
|
|
150
|
+
{ label: 'Wed', category: 'Inbound', value: 130, periodId: '2024-06-03' },
|
|
151
|
+
{ label: 'Wed', category: 'Outbound', value: 70, periodId: '2024-06-03' },
|
|
152
|
+
],
|
|
153
|
+
adSpec: {
|
|
154
|
+
yAxisTitle: 'Calls',
|
|
155
|
+
xAxisTitle: 'Support queue (by day)',
|
|
156
|
+
colorSet: ['#4d1ab2', '#f99170'],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
];
|