@xplortech/apollo-data 0.0.5 → 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.
Files changed (84) hide show
  1. package/README.md +15 -91
  2. package/dist/apollo-data/apollo-data.esm.js +1 -1
  3. package/dist/apollo-data/p-4d3f0792.entry.js +1 -0
  4. package/dist/apollo-data/p-C2k3WBpi.js +11 -0
  5. package/dist/apollo-data/p-D64asVrg.js +2 -0
  6. package/dist/apollo-data/{p-b7471c12.entry.js → p-e2c3a317.entry.js} +1 -1
  7. package/dist/cjs/apollo-data-bar-chart_5.cjs.entry.js +1193 -0
  8. package/dist/cjs/{apollo-data-base-CxVQ-WVP.js → apollo-data-base-COGMOEqL.js} +7 -11
  9. package/dist/cjs/apollo-data-donut-chart.cjs.entry.js +3 -3
  10. package/dist/cjs/apollo-data.cjs.js +3 -3
  11. package/dist/cjs/{index-Cl7HgRm0.js → index-Bd5risOy.js} +116 -63
  12. package/dist/cjs/loader.cjs.js +2 -2
  13. package/dist/collection/apollo-data-base.js +4 -8
  14. package/dist/collection/collection-manifest.json +5 -2
  15. package/dist/collection/components/apollo-data-bar/apollo-data-bar.js +10 -9
  16. package/dist/collection/components/apollo-data-bar/apollo-data-bar.stories.js +122 -0
  17. package/dist/collection/components/apollo-data-donut/apollo-data-donut.js +1 -1
  18. package/dist/collection/components/apollo-data-donut/apollo-data-donut.stories.js +132 -0
  19. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.js +208 -0
  20. package/dist/collection/components/apollo-data-heat-map/apollo-data-heat-map.stories.js +137 -0
  21. package/dist/collection/components/apollo-data-line/apollo-data-line.js +8 -6
  22. package/dist/collection/components/apollo-data-line/apollo-data-line.stories.js +122 -0
  23. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.js +1 -1
  24. package/dist/collection/components/apollo-data-scatter/apollo-data-scatter.stories.js +147 -0
  25. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.js +294 -0
  26. package/dist/collection/components/apollo-data-world-map/apollo-data-world-map.stories.js +126 -0
  27. package/dist/collection/examples/apollo-data-heat-map.examples.js +131 -0
  28. package/dist/collection/examples/apollo-data-world-map.examples.js +45 -0
  29. package/dist/collection/examples/index.js +2 -0
  30. package/dist/collection/utils/code-generator.js +1 -1
  31. package/dist/components/apollo-data-bar-chart.js +1 -1
  32. package/dist/components/apollo-data-donut-chart.js +1 -1
  33. package/dist/components/apollo-data-heat-map.d.ts +11 -0
  34. package/dist/components/apollo-data-heat-map.js +1 -0
  35. package/dist/components/apollo-data-line-chart.js +1 -1
  36. package/dist/components/apollo-data-scatter-chart.js +1 -1
  37. package/dist/components/apollo-data-world-map-chart.d.ts +11 -0
  38. package/dist/components/apollo-data-world-map-chart.js +1 -0
  39. package/dist/components/index.js +1 -1
  40. package/dist/components/p-CfbMSXKd.js +11 -0
  41. package/dist/components/p-gcjU8DVr.js +1 -0
  42. package/dist/esm/apollo-data-bar-chart_5.entry.js +1187 -0
  43. package/dist/esm/{apollo-data-base-BWkrM8dc.js → apollo-data-base-C2k3WBpi.js} +7 -11
  44. package/dist/esm/apollo-data-donut-chart.entry.js +3 -3
  45. package/dist/esm/apollo-data.js +4 -4
  46. package/dist/esm/{index-Bb2nY-Tf.js → index-D64asVrg.js} +116 -63
  47. package/dist/esm/loader.js +3 -3
  48. package/dist/types/apollo-data-base.d.ts +2 -2
  49. package/dist/types/components/apollo-data-bar/apollo-data-bar.stories.d.ts +5 -0
  50. package/dist/types/components/apollo-data-donut/apollo-data-donut.stories.d.ts +5 -0
  51. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.d.ts +140 -0
  52. package/dist/types/components/apollo-data-heat-map/apollo-data-heat-map.stories.d.ts +5 -0
  53. package/dist/types/components/apollo-data-line/apollo-data-line.stories.d.ts +5 -0
  54. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.d.ts +1 -3
  55. package/dist/types/components/apollo-data-scatter/apollo-data-scatter.stories.d.ts +5 -0
  56. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.d.ts +281 -0
  57. package/dist/types/components/apollo-data-world-map/apollo-data-world-map.stories.d.ts +5 -0
  58. package/dist/types/components.d.ts +128 -8
  59. package/dist/types/examples/apollo-data-heat-map.examples.d.ts +11 -0
  60. package/dist/types/examples/apollo-data-scatter.examples.d.ts +1 -1
  61. package/dist/types/examples/apollo-data-world-map.examples.d.ts +11 -0
  62. package/dist/types/examples/index.d.ts +2 -0
  63. package/dist/types/stencil-public-runtime.d.ts +23 -2
  64. package/dist/types/utils/code-generator.d.ts +1 -3
  65. package/package.json +8 -8
  66. package/src/examples/apollo-data-bar.examples.ts +157 -157
  67. package/src/examples/apollo-data-heat-map.examples.ts +147 -0
  68. package/src/examples/apollo-data-line.examples.ts +91 -91
  69. package/src/examples/apollo-data-scatter.examples.ts +1 -1
  70. package/src/examples/apollo-data-world-map.examples.ts +57 -0
  71. package/src/examples/index.ts +3 -1
  72. package/dist/apollo-data/p-2nuV5Vny.js +0 -1
  73. package/dist/apollo-data/p-4ac3c97c.entry.js +0 -1
  74. package/dist/apollo-data/p-BWkrM8dc.js +0 -11
  75. package/dist/apollo-data/p-Bb2nY-Tf.js +0 -2
  76. package/dist/apollo-data/p-e518baac.entry.js +0 -1
  77. package/dist/cjs/apollo-data-bar-chart.cjs.entry.js +0 -314
  78. package/dist/cjs/apollo-data-line-chart_2.cjs.entry.js +0 -534
  79. package/dist/cjs/constants-B3weDEpc.js +0 -5
  80. package/dist/components/p-7XF5Cax8.js +0 -11
  81. package/dist/components/p-Dws5s-Xe.js +0 -1
  82. package/dist/esm/apollo-data-bar-chart.entry.js +0 -312
  83. package/dist/esm/apollo-data-line-chart_2.entry.js +0 -531
  84. package/dist/esm/constants-2nuV5Vny.js +0 -3
@@ -1 +0,0 @@
1
- var t,e=(t,e)=>{var n;Object.entries(null!=(n=e.o.t)?n:{}).map((([n,[o]])=>{if(31&o||32&o){const o=t[n],l=function(t,e){for(;t;){const n=Object.getOwnPropertyDescriptor(t,e);if(null==n?void 0:n.get)return n;t=Object.getPrototypeOf(t)}}(Object.getPrototypeOf(t),n)||Object.getOwnPropertyDescriptor(t,n);l&&Object.defineProperty(t,n,{get(){return l.get.call(this)},set(t){l.set.call(this,t)},configurable:!0,enumerable:!0}),t[n]=e.l.has(n)?e.l.get(n):o}}))},n=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},o=(t,e)=>(0,console.error)(t,e),l="undefined"!=typeof window?window:{},s=l.HTMLElement||class{},r={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,o)=>t.addEventListener(e,n,o),rel:(t,e,n,o)=>t.removeEventListener(e,n,o),ce:(t,e)=>new CustomEvent(t,e)},i=!!(()=>{try{return!!l.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})()&&(()=>!!l.document&&Object.getOwnPropertyDescriptor(l.document.adoptedStyleSheets,"length").writable)(),c=!1,u=[],a=[],f=(t,e)=>n=>{t.push(n),c||(c=!0,e&&4&r.i?m(h):r.raf(h))},d=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){o(t)}t.length=0},h=()=>{d(u),d(a),(c=u.length>0)&&r.raf(h)},m=t=>Promise.resolve(undefined).then(t),p=f(a,!0),b=t=>{const e=new URL(t,r.u);return e.origin!==l.location.origin?e.href:e.pathname},$=t=>r.u=t;function v(){const e=this.attachShadow({mode:"open"});void 0===t&&(t=null),t&&(i?e.adoptedStyleSheets.push(t):e.adoptedStyleSheets=[...e.adoptedStyleSheets,t])}var y,w=new WeakMap,j=t=>"object"==(t=typeof t)||"function"===t,O=(t,e,...n)=>{let o=null,l=null,s=!1,r=!1;const i=[],c=e=>{for(let n=0;n<e.length;n++)o=e[n],Array.isArray(o)?c(o):null!=o&&"boolean"!=typeof o&&((s="function"!=typeof t&&!j(o))&&(o=String(o)),s&&r?i[i.length-1].h+=o:i.push(s?g(null,o):o),r=s)};c(n),e&&e.key&&(l=e.key);const u=g(t,null);return u.m=e,i.length>0&&(u.p=i),u.$=l,u},g=(t,e)=>({i:0,v:t,h:null!=e?e:null,j:null,p:null,m:null,$:null}),S={},k=(t,e)=>null==t||j(t)?t:1&e?String(t):t,M=(t,e,n,o,l,s)=>{if(n===o)return;let r=((t,e)=>e in t)(t,e);if(e.toLowerCase(),"style"===e){for(const e in n)o&&null!=o[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in o)n&&o[e]===n[e]||(e.includes("-")?t.style.setProperty(e,o[e]):t.style[e]=o[e])}else if("key"===e);else{const i=j(o);if(r||i&&null!==o)try{if(t.tagName.includes("-"))t[e]!==o&&(t[e]=o);else{const l=null==o?"":o;"list"===e?r=!1:null!=n&&t[e]==l||("function"==typeof t.__lookupSetter__(e)?t[e]=l:t.setAttribute(e,l))}}catch(t){}null==o||!1===o?!1===o&&""!==t.getAttribute(e)||t.removeAttribute(e):(!r||4&s||l)&&!i&&1===t.nodeType&&t.setAttribute(e,o=!0===o?"":o)}},E=(t,e,n)=>{const o=11===e.j.nodeType&&e.j.host?e.j.host:e.j,l=t&&t.m||{},s=e.m||{};for(const t of C(Object.keys(l)))t in s||M(o,t,l[t],void 0,n,e.i);for(const t of C(Object.keys(s)))M(o,t,l[t],s[t],n,e.i)};function C(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var _=!1,x=(t,e,n)=>{const o=e.p[n];let s,r,i=0;if(!l.document)throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(s=o.j=l.document.createElement(o.v),E(null,o,_),o.p){const e="template"===o.v?s.content:s;for(i=0;i<o.p.length;++i)r=x(t,o,i),r&&e.appendChild(r)}return s["s-hn"]=y,s},P=(t,e,n,o,l,s)=>{let r,i=t;for(i.shadowRoot&&i.tagName===y&&(i=i.shadowRoot),"template"===n.v&&(i=i.content);l<=s;++l)o[l]&&(r=x(null,n,l),r&&(o[l].j=r,L(i,r,e)))},U=(t,e,n)=>{for(let o=e;o<=n;++o){const e=t[o];if(e){const t=e.j;t&&t.remove()}}},A=(t,e,n=!1)=>t.v===e.v&&(n?(n&&!t.$&&e.$&&(t.$=e.$),!0):t.$===e.$),D=(t,e,n=!1)=>{const o=e.j=t.j,l=t.p,s=e.p;E(t,e,_),null!==l&&null!==s?((t,e,n,o,l=!1)=>{let s,r,i=0,c=0,u=0,a=0,f=e.length-1,d=e[0],h=e[f],m=o.length-1,p=o[0],b=o[m];const $="template"===n.v?t.content:t;for(;i<=f&&c<=m;)if(null==d)d=e[++i];else if(null==h)h=e[--f];else if(null==p)p=o[++c];else if(null==b)b=o[--m];else if(A(d,p,l))D(d,p,l),d=e[++i],p=o[++c];else if(A(h,b,l))D(h,b,l),h=e[--f],b=o[--m];else if(A(d,b,l))D(d,b,l),L($,d.j,h.j.nextSibling),d=e[++i],b=o[--m];else if(A(h,p,l))D(h,p,l),L($,h.j,d.j),h=e[--f],p=o[++c];else{for(u=-1,a=i;a<=f;++a)if(e[a]&&null!==e[a].$&&e[a].$===p.$){u=a;break}u>=0?(r=e[u],r.v!==p.v?s=x(e&&e[c],n,u):(D(r,p,l),e[u]=void 0,s=r.j),p=o[++c]):(s=x(e&&e[c],n,c),p=o[++c]),s&&L(d.j.parentNode,s,d.j)}i>f?P(t,null==o[m+1]?null:o[m+1].j,n,o,c,m):c>m&&U(e,i,f)})(o,l,e,s,n):null!==s?P(o,null,e,s,0,s.length-1):!n&&null!==l&&U(l,0,l.length-1)},L=(t,e,n)=>t.__insertBefore?t.__insertBefore(e,n):null==t?void 0:t.insertBefore(e,n),R=(t,e,n=!1)=>{const o=t.$hostElement$,l=t.O||g(null,null);var s;const r=(s=e)&&s.v===S?e:O(null,null,e);if(y=o.tagName,n&&r.m)for(const t of Object.keys(r.m))o.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(r.m[t]=o[t]);r.v=null,r.i|=4,t.O=r,r.j=l.j=o.shadowRoot||o,D(l,r,n)},W=(t,e)=>{if(e&&!t.S&&e["s-p"]){const n=e["s-p"].push(new Promise((o=>t.S=()=>{e["s-p"].splice(n-1,1),o()})))}},H=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);W(t,t.k);const n=()=>N(t,e);if(!e)return p(n);queueMicrotask((()=>{n()}))},N=(t,e)=>{const n=t.$hostElement$,o=n;if(!o)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let l;return l=G(o,e?"componentWillLoad":"componentWillUpdate",void 0,n),l=q(l,(()=>G(o,"componentWillRender",void 0,n))),q(l,(()=>V(t,o,e)))},q=(t,e)=>F(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),F=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,V=async(t,e,n)=>{var o;const l=t.$hostElement$,s=l["s-rc"];z(t,e,l,n),s&&(s.map((t=>t())),l["s-rc"]=void 0);{const e=null!=(o=l["s-p"])?o:[],n=()=>Y(t);0===e.length?n():(Promise.all(e).then(n),t.i|=4,e.length=0)}},z=(t,e,n,l)=>{try{e=e.render(),t.i&=-17,t.i|=2,R(t,e,l)}catch(e){o(e,t.$hostElement$)}return null},Y=t=>{const e=t.$hostElement$,n=e,o=t.k;G(n,"componentDidRender",void 0,e),64&t.i?G(n,"componentDidUpdate",void 0,e):(t.i|=64,I(e),G(n,"componentDidLoad",void 0,e),t.M(e),o||B()),t.S&&(t.S(),t.S=void 0),512&t.i&&m((()=>H(t,!1))),t.i&=-517},B=()=>{m((()=>(t=>{const e=r.ce("appload",{detail:{namespace:"apollo-data"}});return t.dispatchEvent(e),e})(l)))},G=(t,e,n,l)=>{if(t&&t[e])try{return t[e](n)}catch(t){o(t,l)}},I=t=>t.classList.add("hydrated"),J=(t,e,o,l)=>{const s=n(t);if(!s)return;const r=t,i=s.l.get(e),c=s.i,u=r;o=k(o,l.t[e][0]);const a=Number.isNaN(i)&&Number.isNaN(o);if(o!==i&&!a&&(s.l.set(e,o),2==(18&c))){if(u.componentShouldUpdate&&!1===u.componentShouldUpdate(o,i,e))return;H(s,!1)}},K=(t,e)=>{var o,l;const s=t.prototype;if(e.t){const i=Object.entries(null!=(o=e.t)?o:{});i.map((([t,[o]])=>{if(31&o||32&o){const{get:l,set:r}=Object.getOwnPropertyDescriptor(s,t)||{};l&&(e.t[t][0]|=2048),r&&(e.t[t][0]|=4096),Object.defineProperty(s,t,{get(){return l?l.apply(this):(e=t,n(this).l.get(e));var e},configurable:!0,enumerable:!0}),Object.defineProperty(s,t,{set(l){const s=n(this);if(s){if(r)return void 0===(32&o?this[t]:s.$hostElement$[t])&&s.l.get(t)&&(l=s.l.get(t)),r.apply(this,[k(l,o)]),void J(this,t,l=32&o?this[t]:s.$hostElement$[t],e);J(this,t,l,e)}}})}}));{const o=new Map;s.attributeChangedCallback=function(t,l,c){r.jmp((()=>{var r;const u=o.get(t),a=n(this);if(this.hasOwnProperty(u),s.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==c)return;if(null==u){const n=null==a?void 0:a.i;if(a&&n&&!(8&n)&&c!==l){const o=this,s=null==(r=e.C)?void 0:r[t];null==s||s.forEach((e=>{const[[s,r]]=Object.entries(e);null!=o[s]&&(128&n||1&r)&&o[s].call(o,c,l,t)}))}return}const f=i.find((([t])=>t===u));f&&4&f[1][0]&&(c=null!==c&&"false"!==c);const d=Object.getOwnPropertyDescriptor(s,u);c==this[u]||d.get&&!d.set||(this[u]=c)}))},t.observedAttributes=Array.from(new Set([...Object.keys(null!=(l=e.C)?l:{}),...i.filter((([t,e])=>31&e[0])).map((([t,e])=>{const n=e[1]||t;return o.set(n,t),n}))]))}}return t},Q=(t,o)=>{const l={i:o[0],_:o[1]};l.t=o[2];const s=t.prototype.connectedCallback,i=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,n)=>{const o={i:0,$hostElement$:t,o:n,l:new Map,P:new Map};o.U=new Promise((t=>o.M=t)),t["s-p"]=[],t["s-rc"]=[];const l=o;t.__stencil__getHostRef=()=>l,512&n.i&&e(t,o)})(this,l)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!n(this))return;this.__hasHostListenerAttached=!0}(t=>{if(!(1&r.i)){const e=n(t);if(!e)return;const o=e.o,l=()=>{};if(1&e.i)(null==e?void 0:e.A)||(null==e?void 0:e.U)&&e.U.then((()=>{}));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){W(e,e.k=n);break}}o.t&&Object.entries(o.t).map((([e,[n]])=>{if(31&n&&e in t&&t[e]!==Object.prototype[e]){const n=t[e];delete t[e],t[e]=n}})),(async(t,e)=>{32&e.i||(e.i|=32,customElements.whenDefined(t.localName).then((()=>e.i|=128)));const n=e.k,o=()=>H(e,!0);n&&n["s-rc"]?n["s-rc"].push(o):o()})(t,e)}l()}})(this),s&&s.call(this)},disconnectedCallback(){(async t=>{1&r.i||n(t),w.has(t)&&w.delete(t),t.shadowRoot&&w.has(t.shadowRoot)&&w.delete(t.shadowRoot)})(this),i&&i.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${l._}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else v.call(this,l)}}),t.is=l._,K(t,l)},T=t=>r.D=t,X=t=>Object.assign(r,t);function Z(t,e){R({$hostElement$:e},t)}function tt(t){return t}export{S as H,T as a,X as b,s as c,b as g,O as h,Q as p,Z as r,$ as s,tt as t}
@@ -1,312 +0,0 @@
1
- import { r as registerInstance, g as getElement, h, H as Host } from './index-Bb2nY-Tf.js';
2
- import { A as ApolloBase } from './apollo-data-base-BWkrM8dc.js';
3
- import { C as CHART_COLORS } from './constants-2nuV5Vny.js';
4
-
5
- const FONT_FAMILY = "apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
6
- const ApolloDataBarChart = class extends ApolloBase {
7
- constructor(hostRef) {
8
- super();
9
- registerInstance(this, hostRef);
10
- }
11
- get el() { return getElement(this); }
12
- adData = [];
13
- adSpec = null;
14
- static tooltipStylesInjected = false;
15
- componentDidLoad() {
16
- this.injectTooltipStyles();
17
- }
18
- async componentDidRender() {
19
- await this.renderChart();
20
- }
21
- injectTooltipStyles() {
22
- if (ApolloDataBarChart.tooltipStylesInjected) {
23
- return;
24
- }
25
- const styleId = 'apollo-data-bar-tooltip-styles';
26
- if (document.getElementById(styleId)) {
27
- ApolloDataBarChart.tooltipStylesInjected = true;
28
- return;
29
- }
30
- const style = document.createElement('style');
31
- style.id = styleId;
32
- style.textContent = `
33
- #vg-tooltip-element {
34
- background-color: #ffffff;
35
- border: 1px solid #e1e2e8;
36
- border-radius: 0.25rem;
37
- box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.05);
38
- font-family: apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif;
39
- font-weight: 500;
40
- padding: 0.25rem 0.75rem;
41
- pointer-events: none;
42
- text-align: center;
43
- transform: translateY(20%);
44
- white-space: pre;
45
- z-index: 999999999;
46
- }
47
-
48
- #vg-tooltip-element table tr td.key {
49
- color: #6a6d7d;
50
- text-align: center;
51
- }
52
-
53
- #vg-tooltip-element table tr td.value {
54
- text-align: center;
55
- }
56
-
57
- #vg-tooltip-element.dark-theme {
58
- background-color: #292632;
59
- border: 1px solid #6a6d7d;
60
- box-shadow: 0 4px 6px -1px rgba(48, 45, 59, 0.1), 0 2px 4px -1px rgba(48, 45, 59, 0.5);
61
- color: #ffffff;
62
- }
63
-
64
- #vg-tooltip-element::after {
65
- border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
66
- border-style: solid;
67
- border-width: 9px;
68
- bottom: -17px;
69
- content: '';
70
- left: 50%;
71
- position: absolute;
72
- transform: translateX(-50%);
73
- }
74
- `;
75
- document.head.appendChild(style);
76
- ApolloDataBarChart.tooltipStylesInjected = true;
77
- }
78
- // @ts-ignore
79
- async getViewData(data, spec) {
80
- if (!spec) {
81
- throw new Error('adSpec is required for apollo-data-bar-chart');
82
- }
83
- const { tooltipPrefix = '', currencySymbol = '' } = spec;
84
- if (!data || data.length === 0) {
85
- throw new Error('Data is required for apollo-data-bar-chart');
86
- }
87
- const uniqueCategories = Array.from(new Set(data.map(item => item.category)));
88
- const formatNumber = tooltipPrefix ? '.2f' : '.0f';
89
- const currencyPrefix = tooltipPrefix ? currencySymbol : '';
90
- return {
91
- $schema: 'https://vega.github.io/schema/vega/v5.json',
92
- config: {
93
- text: {
94
- fill: '#6a6d7d',
95
- font: FONT_FAMILY,
96
- labelFontSize: 12,
97
- labelFontWeight: 400,
98
- },
99
- axis: {
100
- labelColor: '#6a6d7d',
101
- titleColor: '#6a6d7d',
102
- labelFont: FONT_FAMILY,
103
- titleFont: FONT_FAMILY,
104
- titleFontWeight: 400,
105
- },
106
- legend: {
107
- labelColor: '#6a6d7d',
108
- titleColor: '#6a6d7d',
109
- labelFont: FONT_FAMILY,
110
- titleFont: FONT_FAMILY,
111
- labelFontSize: 12,
112
- labelLimit: 95,
113
- },
114
- title: {
115
- color: '#6a6d7d',
116
- font: FONT_FAMILY,
117
- labelFontSize: 12,
118
- labelFontWeight: 400,
119
- },
120
- },
121
- height: 250,
122
- autosize: { type: 'fit-x', contains: 'padding', resize: true },
123
- signals: [
124
- {
125
- name: 'containerW',
126
- update: 'max(containerSize()[0], 400)',
127
- },
128
- {
129
- name: 'legendColumns',
130
- update: 'ceil(containerW / 140)',
131
- },
132
- {
133
- name: 'hoveredPeriod',
134
- value: null,
135
- on: [
136
- { events: 'rect:mouseover', update: 'datum.period' },
137
- { events: 'rect:mouseout', update: 'null' },
138
- ],
139
- },
140
- ],
141
- width: { signal: 'containerW' },
142
- data: [
143
- {
144
- name: 'raw',
145
- values: data,
146
- },
147
- {
148
- name: 'periodTotals',
149
- source: 'raw',
150
- transform: [
151
- {
152
- type: 'aggregate',
153
- groupby: ['periodId'],
154
- fields: ['value'],
155
- ops: ['sum'],
156
- as: ['total'],
157
- },
158
- ],
159
- },
160
- {
161
- name: 'table',
162
- source: 'raw',
163
- transform: [
164
- {
165
- type: 'lookup',
166
- from: 'periodTotals',
167
- key: 'periodId',
168
- fields: ['periodId'],
169
- values: ['total'],
170
- as: ['total'],
171
- },
172
- {
173
- type: 'stack',
174
- groupby: ['periodId'],
175
- sort: { field: 'category' },
176
- field: 'value',
177
- },
178
- {
179
- type: 'formula',
180
- as: 'periodId',
181
- expr: 'datum.periodId',
182
- },
183
- {
184
- type: 'formula',
185
- as: 'labelOnly',
186
- expr: 'datum.label',
187
- },
188
- ],
189
- },
190
- {
191
- name: 'periodLabels',
192
- source: 'raw',
193
- transform: [
194
- {
195
- type: 'aggregate',
196
- groupby: ['periodId', 'label'],
197
- },
198
- ],
199
- },
200
- ],
201
- scales: [
202
- {
203
- name: 'x',
204
- type: 'band',
205
- domain: { data: 'table', field: 'periodId' },
206
- range: 'width',
207
- paddingInner: 0.35,
208
- paddingOuter: 0.02,
209
- },
210
- {
211
- name: 'xLabels',
212
- type: 'ordinal',
213
- domain: { data: 'periodLabels', field: 'periodId' },
214
- range: { data: 'periodLabels', field: 'label' },
215
- },
216
- {
217
- name: 'y',
218
- type: 'linear',
219
- domain: { data: 'table', field: 'y1' },
220
- nice: true,
221
- zero: true,
222
- range: 'height',
223
- },
224
- {
225
- name: 'color',
226
- type: 'ordinal',
227
- domain: uniqueCategories,
228
- range: spec?.colorSet ?? CHART_COLORS,
229
- },
230
- ],
231
- axes: [
232
- {
233
- orient: 'bottom',
234
- scale: 'x',
235
- title: spec?.xAxisTitle,
236
- labelPadding: 12,
237
- titlePadding: 12,
238
- labelAngle: -90,
239
- labelAlign: 'right',
240
- labelBaseline: 'middle',
241
- tickSize: 3,
242
- labelFontSize: 12,
243
- titleFontSize: 14,
244
- ticks: false,
245
- domain: false,
246
- encode: {
247
- labels: {
248
- update: {
249
- text: { signal: "scale('xLabels', datum.value)" },
250
- },
251
- },
252
- },
253
- },
254
- {
255
- orient: 'left',
256
- scale: 'y',
257
- title: spec?.yAxisTitle || '',
258
- format: ',.0f',
259
- grid: true,
260
- tickCount: 6,
261
- labelFontSize: 12,
262
- titleFontSize: 14,
263
- ticks: false,
264
- domain: false,
265
- tickBand: 'extent',
266
- labelPadding: 10,
267
- },
268
- ],
269
- legends: [
270
- {
271
- fill: 'color',
272
- orient: 'bottom',
273
- direction: 'horizontal',
274
- columns: { signal: 'legendColumns' },
275
- title: null,
276
- symbolType: 'square',
277
- rowPadding: 8,
278
- symbolOffset: -35,
279
- symbolSize: 100,
280
- labelOffset: 8,
281
- labelLimit: 95,
282
- },
283
- ],
284
- marks: [
285
- {
286
- type: 'rect',
287
- from: { data: 'table' },
288
- encode: {
289
- enter: {
290
- x: { scale: 'x', field: 'periodId' },
291
- width: { scale: 'x', band: 1 },
292
- y: { scale: 'y', field: 'y1' },
293
- y2: { scale: 'y', field: 'y0' },
294
- fill: { scale: 'color', field: 'category' },
295
- tooltip: {
296
- signal: `datum.category + ': ${currencyPrefix}' + format(datum.value, ',${formatNumber}') + '\\nTotal: ${currencyPrefix}' + format(datum.total, ',${formatNumber}')`,
297
- },
298
- },
299
- update: {
300
- opacity: [{ test: 'hoveredPeriod && datum.period !== hoveredPeriod', value: 0.2 }, { value: 1 }],
301
- },
302
- },
303
- },
304
- ],
305
- };
306
- }
307
- render() {
308
- return (h(Host, { key: '86ed2e74e5abd57e684a93bc9cf6a014b3ed081c' }, h("div", { key: '96e5f7dd2dfa6a104ca709d1399308a86041c2f3', id: "container", style: { width: '100%', height: '100%' } })));
309
- }
310
- };
311
-
312
- export { ApolloDataBarChart as apollo_data_bar_chart };