@xplortech/apollo-data 0.0.5 → 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.
- package/README.md +15 -91
- package/dist/apollo-data/apollo-data.esm.js +1 -1
- package/dist/apollo-data/p-25841a73.entry.js +1 -0
- package/dist/apollo-data/p-839050b7.entry.js +1 -0
- package/dist/apollo-data/p-C2k3WBpi.js +11 -0
- package/dist/apollo-data/p-D64asVrg.js +2 -0
- package/dist/apollo-data/{p-b7471c12.entry.js → p-e2c3a317.entry.js} +1 -1
- package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +10 -9
- package/dist/cjs/{apollo-data-base-CxVQ-WVP.js → apollo-data-base-COGMOEqL.js} +7 -11
- package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +3 -3
- package/dist/cjs/{apollo-data-line-chart_2.cjs.entry.js → apollo-data-heat-map_4.cjs.entry.js} +358 -9
- package/dist/cjs/apollo-data.cjs.js +3 -3
- package/dist/cjs/{index-Cl7HgRm0.js → index-Bd5risOy.js} +116 -63
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/apollo-data-base.js +4 -8
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +8 -7
- package/dist/collection/components/apollo-data-bar/apollo-data-bar.stories.js +122 -0
- package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +1 -1
- package/dist/collection/components/apollo-data-donut/apollo-data-donut.stories.js +132 -0
- package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.js +208 -0
- package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.stories.js +137 -0
- package/dist/collection/components/apollo-data-line/apollo-data-line.js +8 -6
- package/dist/collection/components/apollo-data-line/apollo-data-line.stories.js +122 -0
- package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +1 -1
- package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.stories.js +147 -0
- package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.js +294 -0
- package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.stories.js +126 -0
- package/dist/collection/examples/apollo-data-heat-map.examples.js +131 -0
- package/dist/collection/examples/apollo-data-world-map.examples.js +45 -0
- package/dist/collection/examples/index.js +2 -0
- package/dist/collection/utils/code-generator.js +1 -1
- package/dist/components/apollo-data-bar-chart.js +1 -1
- package/dist/components/apollo-data-donut-chart.js +1 -1
- package/dist/components/apollo-data-heat-map.d.ts +11 -0
- package/dist/components/apollo-data-heat-map.js +1 -0
- package/dist/components/apollo-data-line-chart.js +1 -1
- package/dist/components/apollo-data-scatter-chart.js +1 -1
- package/dist/components/apollo-data-world-map-chart.d.ts +11 -0
- package/dist/components/apollo-data-world-map-chart.js +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/p-CfbMSXKd.js +11 -0
- package/dist/components/p-gcjU8DVr.js +1 -0
- package/dist/esm/apollo-data-bar-chart.entry.js +10 -9
- package/dist/esm/{apollo-data-base-BWkrM8dc.js → apollo-data-base-C2k3WBpi.js} +7 -11
- package/dist/esm/apollo-data-donut-chart.entry.js +3 -3
- package/dist/esm/{apollo-data-line-chart_2.entry.js → apollo-data-heat-map_4.entry.js} +357 -10
- package/dist/esm/apollo-data.js +4 -4
- package/dist/esm/{index-Bb2nY-Tf.js → index-D64asVrg.js} +116 -63
- package/dist/esm/loader.js +3 -3
- package/dist/types/apollo-data-base.d.ts +2 -2
- package/dist/types/components/apollo-data-bar/apollo-data-bar.stories.d.ts +5 -0
- package/dist/types/components/apollo-data-donut/apollo-data-donut.stories.d.ts +5 -0
- package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.d.ts +140 -0
- package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.stories.d.ts +5 -0
- package/dist/types/components/apollo-data-line/apollo-data-line.stories.d.ts +5 -0
- package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +1 -3
- package/dist/types/components/apollo-data-scatter/apollo-data-scatter.stories.d.ts +5 -0
- package/dist/types/components/apollo-data-world-map/apollo-data-world-map.d.ts +281 -0
- package/dist/types/components/apollo-data-world-map/apollo-data-world-map.stories.d.ts +5 -0
- package/dist/types/components.d.ts +128 -8
- package/dist/types/examples/apollo-data-heat-map.examples.d.ts +11 -0
- package/dist/types/examples/apollo-data-scatter.examples.d.ts +1 -1
- package/dist/types/examples/apollo-data-world-map.examples.d.ts +11 -0
- package/dist/types/examples/index.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +23 -2
- package/dist/types/utils/code-generator.d.ts +1 -3
- package/package.json +8 -8
- package/src/examples/apollo-data-bar.examples.ts +157 -157
- package/src/examples/apollo-data-heat-map.examples.ts +147 -0
- package/src/examples/apollo-data-line.examples.ts +91 -91
- package/src/examples/apollo-data-scatter.examples.ts +1 -1
- package/src/examples/apollo-data-world-map.examples.ts +57 -0
- package/src/examples/index.ts +3 -1
- package/dist/apollo-data/p-4ac3c97c.entry.js +0 -1
- package/dist/apollo-data/p-BWkrM8dc.js +0 -11
- package/dist/apollo-data/p-Bb2nY-Tf.js +0 -2
- package/dist/apollo-data/p-e518baac.entry.js +0 -1
- package/dist/components/p-7XF5Cax8.js +0 -11
- package/dist/components/p-Dws5s-Xe.js +0 -1
|
@@ -4,9 +4,22 @@ const NAMESPACE = 'apollo-data';
|
|
|
4
4
|
const BUILD = /* apollo-data */ { hydratedSelectorName: "hydrated", lazyLoad: true, prop: true, propChangeCallback: false, updatable: true};
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
|
-
Stencil Client Platform v4.
|
|
7
|
+
Stencil Client Platform v4.43.2 | MIT Licensed | https://stenciljs.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
// src/utils/get-prop-descriptor.ts
|
|
12
|
+
function getPropertyDescriptor(obj, memberName, getOnly) {
|
|
13
|
+
const stopAt = typeof HTMLElement !== "undefined" ? HTMLElement.prototype : null;
|
|
14
|
+
while (obj && obj !== stopAt) {
|
|
15
|
+
const desc = Object.getOwnPropertyDescriptor(obj, memberName);
|
|
16
|
+
if (desc && (!getOnly || desc.get)) return desc;
|
|
17
|
+
obj = Object.getPrototypeOf(obj);
|
|
18
|
+
}
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/utils/es2022-rewire-class-members.ts
|
|
10
23
|
var reWireGetterSetter = (instance, hostRef) => {
|
|
11
24
|
var _a;
|
|
12
25
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
@@ -14,7 +27,7 @@ var reWireGetterSetter = (instance, hostRef) => {
|
|
|
14
27
|
members.map(([memberName, [memberFlags]]) => {
|
|
15
28
|
if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
|
|
16
29
|
const ogValue = instance[memberName];
|
|
17
|
-
const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName) || Object.getOwnPropertyDescriptor(instance, memberName);
|
|
30
|
+
const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName, true) || Object.getOwnPropertyDescriptor(instance, memberName);
|
|
18
31
|
if (ogDescriptor) {
|
|
19
32
|
Object.defineProperty(instance, memberName, {
|
|
20
33
|
get() {
|
|
@@ -27,18 +40,14 @@ var reWireGetterSetter = (instance, hostRef) => {
|
|
|
27
40
|
enumerable: true
|
|
28
41
|
});
|
|
29
42
|
}
|
|
30
|
-
|
|
43
|
+
if (hostRef.$instanceValues$.has(memberName)) {
|
|
44
|
+
instance[memberName] = hostRef.$instanceValues$.get(memberName);
|
|
45
|
+
} else if (ogValue !== void 0) {
|
|
46
|
+
instance[memberName] = ogValue;
|
|
47
|
+
}
|
|
31
48
|
}
|
|
32
49
|
});
|
|
33
50
|
};
|
|
34
|
-
function getPropertyDescriptor(obj, memberName) {
|
|
35
|
-
while (obj) {
|
|
36
|
-
const desc = Object.getOwnPropertyDescriptor(obj, memberName);
|
|
37
|
-
if (desc == null ? void 0 : desc.get) return desc;
|
|
38
|
-
obj = Object.getPrototypeOf(obj);
|
|
39
|
-
}
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
51
|
|
|
43
52
|
// src/client/client-host-ref.ts
|
|
44
53
|
var getHostRef = (ref) => {
|
|
@@ -327,15 +336,45 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
|
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
338
|
}
|
|
330
|
-
} else if (memberName === "key") ; else {
|
|
339
|
+
} else if (memberName === "key") ; else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
|
|
340
|
+
const propName = memberName.slice(5);
|
|
341
|
+
let attrName;
|
|
342
|
+
{
|
|
343
|
+
const hostRef = getHostRef(elm);
|
|
344
|
+
if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
|
|
345
|
+
const memberMeta = hostRef.$cmpMeta$.$members$[propName];
|
|
346
|
+
if (memberMeta && memberMeta[1]) {
|
|
347
|
+
attrName = memberMeta[1];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!attrName) {
|
|
352
|
+
attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
353
|
+
}
|
|
354
|
+
if (newValue == null || newValue === false) {
|
|
355
|
+
if (newValue !== false || elm.getAttribute(attrName) === "") {
|
|
356
|
+
elm.removeAttribute(attrName);
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
elm.setAttribute(attrName, newValue === true ? "" : newValue);
|
|
360
|
+
}
|
|
361
|
+
return;
|
|
362
|
+
} else if (memberName[0] === "p" && memberName.startsWith("prop:")) {
|
|
363
|
+
const propName = memberName.slice(5);
|
|
364
|
+
try {
|
|
365
|
+
elm[propName] = newValue;
|
|
366
|
+
} catch (e) {
|
|
367
|
+
}
|
|
368
|
+
return;
|
|
369
|
+
} else {
|
|
331
370
|
const isComplex = isComplexType(newValue);
|
|
332
|
-
if ((isProp || isComplex && newValue !== null) &&
|
|
371
|
+
if ((isProp || isComplex && newValue !== null) && !isSvg) {
|
|
333
372
|
try {
|
|
334
373
|
if (!elm.tagName.includes("-")) {
|
|
335
374
|
const n = newValue == null ? "" : newValue;
|
|
336
375
|
if (memberName === "list") {
|
|
337
376
|
isProp = false;
|
|
338
|
-
} else if (oldValue == null || elm[memberName]
|
|
377
|
+
} else if (oldValue == null || elm[memberName] !== n) {
|
|
339
378
|
if (typeof elm.__lookupSetter__(memberName) === "function") {
|
|
340
379
|
elm[memberName] = n;
|
|
341
380
|
} else {
|
|
@@ -685,7 +724,7 @@ var updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
685
724
|
if (childrenPromises.length === 0) {
|
|
686
725
|
postUpdate();
|
|
687
726
|
} else {
|
|
688
|
-
Promise.all(childrenPromises).then(postUpdate);
|
|
727
|
+
Promise.all(childrenPromises).then(postUpdate).catch(postUpdate);
|
|
689
728
|
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
690
729
|
childrenPromises.length = 0;
|
|
691
730
|
}
|
|
@@ -787,13 +826,16 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
787
826
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
788
827
|
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
|
|
789
828
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
790
|
-
if (
|
|
829
|
+
if (flags & 2 /* hasRendered */) {
|
|
791
830
|
if (instance.componentShouldUpdate) {
|
|
792
|
-
|
|
831
|
+
const shouldUpdate = instance.componentShouldUpdate(newVal, oldVal, propName);
|
|
832
|
+
if (shouldUpdate === false && !(flags & 16 /* isQueuedForUpdate */)) {
|
|
793
833
|
return;
|
|
794
834
|
}
|
|
795
835
|
}
|
|
796
|
-
|
|
836
|
+
if (!(flags & 16 /* isQueuedForUpdate */)) {
|
|
837
|
+
scheduleUpdate(hostRef, false);
|
|
838
|
+
}
|
|
797
839
|
}
|
|
798
840
|
}
|
|
799
841
|
};
|
|
@@ -806,7 +848,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
806
848
|
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
|
|
807
849
|
members.map(([memberName, [memberFlags]]) => {
|
|
808
850
|
if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
|
|
809
|
-
const { get: origGetter, set: origSetter } =
|
|
851
|
+
const { get: origGetter, set: origSetter } = getPropertyDescriptor(prototype, memberName) || {};
|
|
810
852
|
if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
|
|
811
853
|
if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
|
|
812
854
|
if (flags & 1 /* isElementConstructor */ || !origGetter) {
|
|
@@ -936,53 +978,64 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
936
978
|
// src/runtime/initialize-component.ts
|
|
937
979
|
var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
938
980
|
let Cstr;
|
|
939
|
-
|
|
940
|
-
hostRef.$flags$
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
981
|
+
try {
|
|
982
|
+
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
983
|
+
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
984
|
+
const bundleId = cmpMeta.$lazyBundleId$;
|
|
985
|
+
if (bundleId) {
|
|
986
|
+
const CstrImport = loadModule(cmpMeta, hostRef);
|
|
987
|
+
if (CstrImport && "then" in CstrImport) {
|
|
988
|
+
const endLoad = uniqueTime();
|
|
989
|
+
Cstr = await CstrImport;
|
|
990
|
+
endLoad();
|
|
991
|
+
} else {
|
|
992
|
+
Cstr = CstrImport;
|
|
993
|
+
}
|
|
994
|
+
if (!Cstr) {
|
|
995
|
+
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
996
|
+
}
|
|
997
|
+
if (!Cstr.isProxied) {
|
|
998
|
+
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
999
|
+
Cstr.isProxied = true;
|
|
1000
|
+
}
|
|
1001
|
+
const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
|
|
1002
|
+
{
|
|
1003
|
+
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1004
|
+
}
|
|
1005
|
+
try {
|
|
1006
|
+
new Cstr(hostRef);
|
|
1007
|
+
} catch (e) {
|
|
1008
|
+
consoleError(e, elm);
|
|
1009
|
+
}
|
|
1010
|
+
{
|
|
1011
|
+
hostRef.$flags$ &= -9 /* isConstructingInstance */;
|
|
1012
|
+
}
|
|
1013
|
+
endNewInstance();
|
|
1014
|
+
{
|
|
1015
|
+
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
1016
|
+
}
|
|
948
1017
|
} else {
|
|
949
|
-
Cstr =
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
953
|
-
}
|
|
954
|
-
if (!Cstr.isProxied) {
|
|
955
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
956
|
-
Cstr.isProxied = true;
|
|
957
|
-
}
|
|
958
|
-
const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
|
|
959
|
-
{
|
|
960
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
961
|
-
}
|
|
962
|
-
try {
|
|
963
|
-
new Cstr(hostRef);
|
|
964
|
-
} catch (e) {
|
|
965
|
-
consoleError(e, elm);
|
|
966
|
-
}
|
|
967
|
-
{
|
|
968
|
-
hostRef.$flags$ &= -9 /* isConstructingInstance */;
|
|
969
|
-
}
|
|
970
|
-
endNewInstance();
|
|
971
|
-
{
|
|
972
|
-
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
1018
|
+
Cstr = elm.constructor;
|
|
1019
|
+
const cmpTag = elm.localName;
|
|
1020
|
+
customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
|
|
973
1021
|
}
|
|
1022
|
+
}
|
|
1023
|
+
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1024
|
+
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1025
|
+
if (ancestorComponent && ancestorComponent["s-rc"]) {
|
|
1026
|
+
ancestorComponent["s-rc"].push(schedule);
|
|
974
1027
|
} else {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1028
|
+
schedule();
|
|
1029
|
+
}
|
|
1030
|
+
} catch (e) {
|
|
1031
|
+
consoleError(e, elm);
|
|
1032
|
+
if (hostRef.$onRenderResolve$) {
|
|
1033
|
+
hostRef.$onRenderResolve$();
|
|
1034
|
+
hostRef.$onRenderResolve$ = void 0;
|
|
1035
|
+
}
|
|
1036
|
+
if (hostRef.$onReadyResolve$) {
|
|
1037
|
+
hostRef.$onReadyResolve$(elm);
|
|
978
1038
|
}
|
|
979
|
-
}
|
|
980
|
-
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
981
|
-
const schedule = () => scheduleUpdate(hostRef, true);
|
|
982
|
-
if (ancestorComponent && ancestorComponent["s-rc"]) {
|
|
983
|
-
ancestorComponent["s-rc"].push(schedule);
|
|
984
|
-
} else {
|
|
985
|
-
schedule();
|
|
986
1039
|
}
|
|
987
1040
|
};
|
|
988
1041
|
var fireConnectedCallback = (instance, elm) => {
|
|
@@ -1013,7 +1066,7 @@ var connectedCallback = (elm) => {
|
|
|
1013
1066
|
}
|
|
1014
1067
|
if (cmpMeta.$members$) {
|
|
1015
1068
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1016
|
-
if (memberFlags & 31 /* Prop */ &&
|
|
1069
|
+
if (memberFlags & 31 /* Prop */ && Object.prototype.hasOwnProperty.call(elm, memberName)) {
|
|
1017
1070
|
const value = elm[memberName];
|
|
1018
1071
|
delete elm[memberName];
|
|
1019
1072
|
elm[memberName] = value;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Bd5risOy.js');
|
|
4
4
|
var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
5
5
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["apollo-data-
|
|
9
|
+
return index.bootstrapLazy([["apollo-data-heat-map_4.cjs",[[513,"apollo-data-heat-map",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-line-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-scatter-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}],[513,"apollo-data-world-map-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]],["apollo-data-bar-chart.cjs",[[513,"apollo-data-bar-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]],["apollo-data-donut-chart.cjs",[[513,"apollo-data-donut-chart",{"adData":[1,"ad-data"],"adSpec":[1,"ad-spec"]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
1
|
import embed from "vega-embed";
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
4
2
|
export class ApolloBase {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
getViewData(data, spec) {
|
|
7
|
-
throw new Error('getViewData is not implemented');
|
|
8
|
-
}
|
|
9
3
|
async renderChart() {
|
|
10
4
|
// Wait for shadow DOM to be ready
|
|
11
|
-
await new Promise(resolve =>
|
|
12
|
-
|
|
5
|
+
await new Promise(resolve => {
|
|
6
|
+
setTimeout(resolve, 0);
|
|
7
|
+
});
|
|
13
8
|
const container = this.el?.shadowRoot?.querySelector('#container');
|
|
14
9
|
if (!container) {
|
|
15
10
|
return;
|
|
@@ -21,6 +16,7 @@ export class ApolloBase {
|
|
|
21
16
|
spec = typeof this.adSpec === 'string' ? JSON.parse(this.adSpec) : this.adSpec;
|
|
22
17
|
}
|
|
23
18
|
catch (err) {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
24
20
|
console.error('Error parsing data/spec', err);
|
|
25
21
|
return;
|
|
26
22
|
}
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
"entries": [
|
|
3
3
|
"components/apollo-data-bar/apollo-data-bar.js",
|
|
4
4
|
"components/apollo-data-donut/apollo-data-donut.js",
|
|
5
|
+
"components/apollo-data-heat-map/apollo-data-heat-map.js",
|
|
5
6
|
"components/apollo-data-line/apollo-data-line.js",
|
|
6
|
-
"components/apollo-data-scatter/apollo-data-scatter.js"
|
|
7
|
+
"components/apollo-data-scatter/apollo-data-scatter.js",
|
|
8
|
+
"components/apollo-data-world-map/apollo-data-world-map.js"
|
|
7
9
|
],
|
|
10
|
+
"mixins": [],
|
|
8
11
|
"compiler": {
|
|
9
12
|
"name": "@stencil/core",
|
|
10
|
-
"version": "4.
|
|
13
|
+
"version": "4.43.2",
|
|
11
14
|
"typescriptVersion": "5.8.3"
|
|
12
15
|
},
|
|
13
16
|
"collections": [],
|
|
@@ -17,12 +17,13 @@ export class ApolloDataBarChart extends ApolloBase {
|
|
|
17
17
|
await this.renderChart();
|
|
18
18
|
}
|
|
19
19
|
injectTooltipStyles() {
|
|
20
|
-
|
|
20
|
+
const chartClass = this.constructor;
|
|
21
|
+
if (chartClass.tooltipStylesInjected) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
const styleId = 'apollo-data-bar-tooltip-styles';
|
|
24
25
|
if (document.getElementById(styleId)) {
|
|
25
|
-
|
|
26
|
+
chartClass.tooltipStylesInjected = true;
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
const style = document.createElement('style');
|
|
@@ -71,16 +72,16 @@ export class ApolloDataBarChart extends ApolloBase {
|
|
|
71
72
|
}
|
|
72
73
|
`;
|
|
73
74
|
document.head.appendChild(style);
|
|
74
|
-
|
|
75
|
+
chartClass.tooltipStylesInjected = true;
|
|
75
76
|
}
|
|
76
|
-
// @ts-ignore
|
|
77
77
|
async getViewData(data, spec) {
|
|
78
|
+
const componentTag = this.el?.tagName?.toLowerCase() ?? 'apollo-data-bar-chart';
|
|
78
79
|
if (!spec) {
|
|
79
|
-
throw new Error(
|
|
80
|
+
throw new Error(`adSpec is required for ${componentTag}`);
|
|
80
81
|
}
|
|
81
82
|
const { tooltipPrefix = '', currencySymbol = '' } = spec;
|
|
82
83
|
if (!data || data.length === 0) {
|
|
83
|
-
throw new Error(
|
|
84
|
+
throw new Error(`Data is required for ${componentTag}`);
|
|
84
85
|
}
|
|
85
86
|
const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
|
|
86
87
|
const formatNumber = tooltipPrefix ? '.2f' : '.0f';
|
|
@@ -303,7 +304,7 @@ export class ApolloDataBarChart extends ApolloBase {
|
|
|
303
304
|
};
|
|
304
305
|
}
|
|
305
306
|
render() {
|
|
306
|
-
return (h(Host, { key: '
|
|
307
|
+
return (h(Host, { key: 'a0aebbff4fb177de35eb90329de81a1098663620' }, h("div", { key: '9e753e876df877d46254a02349850414914d9231', id: "container", style: { width: '100%', height: '100%' } })));
|
|
307
308
|
}
|
|
308
309
|
static get is() { return "apollo-data-bar-chart"; }
|
|
309
310
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { html } from "lit-html";
|
|
2
|
+
import { barExamples } from "../../examples/apollo-data-bar.examples";
|
|
3
|
+
import { generateReactCode, generateVueCode, generateWebComponentCode, generateInstallationDocs } from "../../utils/code-generator";
|
|
4
|
+
function getCodeForFramework(props, framework) {
|
|
5
|
+
switch (framework) {
|
|
6
|
+
case 'vue':
|
|
7
|
+
return generateVueCode('apollo-data-bar-chart', props);
|
|
8
|
+
case 'webcomponent':
|
|
9
|
+
return generateWebComponentCode('apollo-data-bar-chart', props);
|
|
10
|
+
case 'react':
|
|
11
|
+
default:
|
|
12
|
+
return generateReactCode('apollo-data-bar-chart', props);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const meta = {
|
|
16
|
+
title: 'Apollo Data/Bar Chart',
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
argTypes: {
|
|
19
|
+
adData: {
|
|
20
|
+
control: 'object',
|
|
21
|
+
description: 'Array of data items. Each item must have label (string), category (string), value (number), and periodId (string, typically a date YYYY-MM-DD).',
|
|
22
|
+
table: {
|
|
23
|
+
type: {
|
|
24
|
+
summary: 'BarDataItem[]',
|
|
25
|
+
detail: 'interface BarDataItem {\n label: string;\n category: string;\n value: number;\n periodId: string; // date string e.g. YYYY-MM-DD\n}',
|
|
26
|
+
},
|
|
27
|
+
defaultValue: { summary: '[]' },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
adSpec: {
|
|
31
|
+
control: 'object',
|
|
32
|
+
description: 'Specification object for customizing the chart appearance.',
|
|
33
|
+
table: {
|
|
34
|
+
type: {
|
|
35
|
+
summary: 'BarSpec',
|
|
36
|
+
detail: 'interface BarSpec {\n colorSet?: string[];\n tooltipPrefix?: string;\n currencySymbol?: string;\n yAxisTitle?: string;\n xAxisTitle?: string;\n}',
|
|
37
|
+
},
|
|
38
|
+
defaultValue: { summary: '{}' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
decorators: [
|
|
43
|
+
(story, context) => {
|
|
44
|
+
const framework = context.globals?.framework || 'react';
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
const doc = globalThis.document;
|
|
47
|
+
if (doc) {
|
|
48
|
+
const installSections = {
|
|
49
|
+
react: doc.querySelector('.install-react'),
|
|
50
|
+
vue: doc.querySelector('.install-vue'),
|
|
51
|
+
webcomponent: doc.querySelector('.install-webcomponent'),
|
|
52
|
+
};
|
|
53
|
+
Object.values(installSections).forEach((section) => {
|
|
54
|
+
if (section)
|
|
55
|
+
section.setAttribute('style', 'display: none;');
|
|
56
|
+
});
|
|
57
|
+
const selectedSection = installSections[framework];
|
|
58
|
+
if (selectedSection)
|
|
59
|
+
selectedSection.setAttribute('style', 'display: block;');
|
|
60
|
+
}
|
|
61
|
+
}, 0);
|
|
62
|
+
return story();
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
parameters: {
|
|
66
|
+
docs: {
|
|
67
|
+
description: {
|
|
68
|
+
component: `${generateInstallationDocs('react', 'apollo-data-bar-chart')}
|
|
69
|
+
|
|
70
|
+
${generateInstallationDocs('vue', 'apollo-data-bar-chart')}
|
|
71
|
+
|
|
72
|
+
${generateInstallationDocs('webcomponent', 'apollo-data-bar-chart')}
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Description
|
|
77
|
+
|
|
78
|
+
A stacked bar chart component built with Vega that displays data by period with interactive hover effects. Each data item has a \`label\` (shown on the x-axis), \`category\`, \`value\`, and \`periodId\` (use a date string like \`YYYY-MM-DD\` for the period). Use \`adSpec.xAxisTitle\` and \`adSpec.yAxisTitle\` to customize axis labels. The example uses the monthly sales by product preset from \`barExamples\`.
|
|
79
|
+
|
|
80
|
+
**Tip:** Use the Framework selector in the toolbar above to switch between React, Vue, and Web Component installation instructions and code examples.`,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
viewMode: 'story',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export default meta;
|
|
87
|
+
const chartWrapper = (args) => html `
|
|
88
|
+
<div style="width: 800px; height: 400px;">
|
|
89
|
+
<apollo-data-bar-chart .adData=${args.adData} .adSpec=${args.adSpec}></apollo-data-bar-chart>
|
|
90
|
+
</div>
|
|
91
|
+
`;
|
|
92
|
+
export const MonthlySalesByProduct = {
|
|
93
|
+
args: {
|
|
94
|
+
adData: barExamples[1].props.adData,
|
|
95
|
+
adSpec: barExamples[1].props.adSpec ?? {},
|
|
96
|
+
},
|
|
97
|
+
render: args => chartWrapper(args),
|
|
98
|
+
parameters: {
|
|
99
|
+
codeGenerator: (args, framework) => getCodeForFramework({ adData: args.adData ?? barExamples[1].props.adData, adSpec: args.adSpec ?? barExamples[1].props.adSpec ?? {} }, framework),
|
|
100
|
+
docs: {
|
|
101
|
+
description: { story: barExamples[1].description },
|
|
102
|
+
source: {
|
|
103
|
+
language: 'tsx',
|
|
104
|
+
type: 'dynamic',
|
|
105
|
+
transform: (_code, storyContext) => {
|
|
106
|
+
try {
|
|
107
|
+
const framework = storyContext?.globals?.framework || 'react';
|
|
108
|
+
const props = {
|
|
109
|
+
adData: storyContext?.args?.adData ?? barExamples[1].props.adData,
|
|
110
|
+
adSpec: storyContext?.args?.adSpec ?? barExamples[1].props.adSpec ?? {},
|
|
111
|
+
};
|
|
112
|
+
return getCodeForFramework(props, framework);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('Error in transform function:', error);
|
|
116
|
+
return `<apollo-data-bar-chart />`;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
@@ -397,7 +397,7 @@ export class ApolloDataDonutChart extends ApolloBase {
|
|
|
397
397
|
};
|
|
398
398
|
}
|
|
399
399
|
render() {
|
|
400
|
-
return (h(Host, { key: '
|
|
400
|
+
return (h(Host, { key: '5d9ba4976956c4f0d29b9aa8638373895c0c3f7f' }, h("div", { key: '2db6d1418492898de84a167e35ecc8b16d695942', id: "container", style: { width: '100%', height: '100%' } })));
|
|
401
401
|
}
|
|
402
402
|
static get is() { return "apollo-data-donut-chart"; }
|
|
403
403
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { html } from "lit-html";
|
|
2
|
+
import { donutExamples } from "../../examples/apollo-data-donut.examples";
|
|
3
|
+
import { generateReactCode, generateVueCode, generateWebComponentCode, generateInstallationDocs } from "../../utils/code-generator";
|
|
4
|
+
// Helper function to generate code based on framework
|
|
5
|
+
function getCodeForFramework(props, framework) {
|
|
6
|
+
switch (framework) {
|
|
7
|
+
case 'vue':
|
|
8
|
+
return generateVueCode('apollo-data-donut-chart', props);
|
|
9
|
+
case 'webcomponent':
|
|
10
|
+
return generateWebComponentCode('apollo-data-donut-chart', props);
|
|
11
|
+
case 'react':
|
|
12
|
+
default:
|
|
13
|
+
return generateReactCode('apollo-data-donut-chart', props);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const meta = {
|
|
17
|
+
title: 'Apollo Data/Donut Chart',
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
argTypes: {
|
|
20
|
+
adData: {
|
|
21
|
+
control: 'object',
|
|
22
|
+
description: 'Array of data items to display in the donut chart. Each item must have a category (string) and value (number).',
|
|
23
|
+
table: {
|
|
24
|
+
type: {
|
|
25
|
+
summary: 'DonutDataItem[]',
|
|
26
|
+
detail: 'interface DonutDataItem {\n category: string;\n value: number;\n}',
|
|
27
|
+
},
|
|
28
|
+
defaultValue: { summary: '[]' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
adSpec: {
|
|
32
|
+
control: 'object',
|
|
33
|
+
description: 'Optional specification object for customizing the chart appearance, such as custom color sets, prefix , suffix and center text',
|
|
34
|
+
table: {
|
|
35
|
+
type: {
|
|
36
|
+
summary: 'DonutSpec',
|
|
37
|
+
detail: 'interface DonutSpec {\n colorSet?: string[];\n prefix?: string;\n suffix?: string;\n centerText: string;\n}',
|
|
38
|
+
},
|
|
39
|
+
defaultValue: { summary: '{}' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
decorators: [
|
|
44
|
+
(story, context) => {
|
|
45
|
+
const framework = context.globals?.framework || 'react';
|
|
46
|
+
// Update visibility of installation sections when framework changes
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
const doc = globalThis.document;
|
|
49
|
+
if (doc) {
|
|
50
|
+
const installSections = {
|
|
51
|
+
react: doc.querySelector('.install-react'),
|
|
52
|
+
vue: doc.querySelector('.install-vue'),
|
|
53
|
+
webcomponent: doc.querySelector('.install-webcomponent'),
|
|
54
|
+
};
|
|
55
|
+
// Hide all sections first
|
|
56
|
+
Object.values(installSections).forEach((section) => {
|
|
57
|
+
if (section) {
|
|
58
|
+
section.setAttribute('style', 'display: none;');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Show only the selected framework
|
|
62
|
+
const selectedSection = installSections[framework];
|
|
63
|
+
if (selectedSection) {
|
|
64
|
+
selectedSection.setAttribute('style', 'display: block;');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, 0);
|
|
68
|
+
return story();
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
parameters: {
|
|
72
|
+
docs: {
|
|
73
|
+
description: {
|
|
74
|
+
component: `${generateInstallationDocs('react', 'apollo-data-donut-chart')}
|
|
75
|
+
|
|
76
|
+
${generateInstallationDocs('vue', 'apollo-data-donut-chart')}
|
|
77
|
+
|
|
78
|
+
${generateInstallationDocs('webcomponent', 'apollo-data-donut-chart')}
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Description
|
|
83
|
+
|
|
84
|
+
A donut chart component built with Vega that displays data in a circular format with interactive hover effects. Use the controls below to modify the data and see the code examples update automatically.
|
|
85
|
+
|
|
86
|
+
**Tip:** Use the Framework selector in the toolbar above to switch between React, Vue, and Web Component installation instructions and code examples.`,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
viewMode: 'story',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
export default meta;
|
|
93
|
+
// Single interactive story
|
|
94
|
+
export const ApolloDataDonut = {
|
|
95
|
+
args: {
|
|
96
|
+
adData: donutExamples[5].props.adData,
|
|
97
|
+
adSpec: donutExamples[5].props.adSpec || {},
|
|
98
|
+
},
|
|
99
|
+
render: args => html `
|
|
100
|
+
<div style="width: 600px; height: 400px;">
|
|
101
|
+
<apollo-data-donut-chart .adData=${args.adData} .adSpec=${args.adSpec}></apollo-data-donut-chart>
|
|
102
|
+
</div>
|
|
103
|
+
`,
|
|
104
|
+
parameters: {
|
|
105
|
+
// Code generator function for the Code addon panel
|
|
106
|
+
codeGenerator: (args, framework) => getCodeForFramework(args, framework),
|
|
107
|
+
docs: {
|
|
108
|
+
description: {
|
|
109
|
+
story: 'Interactive donut chart. Modify the data and spec using the controls below, switch between React, Vue, or Web Component using the Framework selector in the toolbar, and view the generated code in the Code tab.',
|
|
110
|
+
},
|
|
111
|
+
source: {
|
|
112
|
+
language: 'tsx',
|
|
113
|
+
type: 'dynamic',
|
|
114
|
+
transform: (_code, storyContext) => {
|
|
115
|
+
try {
|
|
116
|
+
const framework = storyContext?.globals?.framework || 'react';
|
|
117
|
+
const props = {
|
|
118
|
+
adData: storyContext?.args?.adData || [],
|
|
119
|
+
adSpec: storyContext?.args?.adSpec || {},
|
|
120
|
+
};
|
|
121
|
+
return getCodeForFramework(props, framework);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
125
|
+
console.error('Error in transform function:', error);
|
|
126
|
+
return `<apollo-data-donut-chart />`;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|