@circutor/charts 0.1.0 → 0.2.0
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/bundler/index.d.ts +35 -0
- package/dist/bundler/index.js +1 -0
- package/dist/bundler/itic-chart.d.ts +11 -0
- package/dist/bundler/itic-chart.js +1 -0
- package/dist/charts/charts.esm.js +1 -1
- package/dist/charts/p-943aa343.entry.js +25 -0
- package/dist/charts/p-BPCJmLvQ.js +3 -0
- package/dist/cjs/charts.cjs.js +2 -2
- package/dist/cjs/{index-_N-tWlJj.js → index-dJHivNOd.js} +21 -0
- package/dist/cjs/itic-chart.cjs.entry.js +86 -24
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/itic-chart/index.js +134 -8
- package/dist/collection/components/itic-chart/itic-chart.css +5 -0
- package/dist/collection/components/itic-chart/itic-chart.options.js +42 -16
- package/dist/components/index.js +1 -1
- package/dist/components/itic-chart.js +3 -3
- package/dist/esm/charts.js +3 -3
- package/dist/esm/{index--cwjvYaF.js → index-BPCJmLvQ.js} +20 -1
- package/dist/esm/itic-chart.entry.js +86 -24
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/itic-chart/index.d.ts +26 -3
- package/dist/types/components/itic-chart/itic-chart.options.d.ts +36 -2
- package/dist/types/components.d.ts +53 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +13 -6
- package/readme.md +178 -7
- package/dist/charts/p--cwjvYaF.js +0 -3
- package/dist/charts/p-35caac53.entry.js +0 -25
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function t(t,e,n){const o="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==o;){const o=Object.getOwnPropertyDescriptor(t,e);if(o&&(!n||o.get))return o;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var o;Object.entries(null!=(o=n.o.t)?o:{}).map((([o,[l]])=>{if(31&l||32&l){const l=e[o],i=t(Object.getPrototypeOf(e),o,!0)||Object.getOwnPropertyDescriptor(e,o);i&&Object.defineProperty(e,o,{get(){return i.get.call(this)},set(t){i.set.call(this,t)},configurable:!0,enumerable:!0}),n.l.has(o)?e[o]=n.l.get(o):void 0!==l&&(e[o]=l)}}))},o=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},l=(t,e)=>{e&&(t.__stencil__getHostRef=()=>e,e.i=t,512&e.o.u&&n(t,e))},i=(t,e)=>(0,console.error)(t,e),s=new Map,r=new Map,c=new Map,u="undefined"!=typeof window?window:{},f={u:0,h:"",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)},a=t=>Promise.resolve(t),d=(()=>{try{return!!u.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),h=!!d&&(()=>!!u.document&&Object.getOwnPropertyDescriptor(u.document.adoptedStyleSheets,"length").writable)(),p=!1,m=[],v=[],b=()=>{var t;return(null==(t=u.document)?void 0:t.hidden)?setTimeout(w,16):f.raf(w)},y=(t,e)=>n=>{t.push(n),p||(p=!0,e&&4&f.u?j(w):b())},$=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){i(t)}t.length=0},w=()=>{$(m),$(v),(p=m.length>0)&&b()},j=t=>a().then(t),g=y(v,!0);function O(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(h?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}function S(t){var e,n,o;return null!=(o=null==(n=null==(e=t.head)?void 0:e.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?o:void 0}var k,M=new WeakMap,E=t=>"sc-"+t.p,C=t=>"object"==(t=typeof t)||"function"===t,T=(t,e,...n)=>{let o=null,l=null,s=!1,r=!1;const c=[],u=e=>{for(let n=0;n<e.length;n++)if(o=e[n],Array.isArray(o))u(o);else if(null!=o&&"boolean"!=typeof o){if(s="function"!=typeof t&&!C(o))o+="";else if("function"!=typeof t&&void 0===o.u){i("Invalid vNode child");continue}s&&r?c[c.length-1].m+=o:c.push(s?L(null,o):o),r=s}};if(u(n),e){e.key&&(l=e.key);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}const f=L(t,null);return f.v=e,c.length>0&&(f.$=c),f.j=l,f},L=(t,e)=>({u:0,O:t,m:null!=e?e:null,S:null,$:null,v:null,j:null}),x={},D=t=>{if(!t)return;const e=Object.keys(t);if(0===e.length)return;let n=!1;for(const o of e){if(n)break;for(const e of t[o])if("string"==typeof e){n=!0;break}}if(!n)return t;const o={};for(const n of e)o[n]=t[n].map((t=>"string"==typeof t?{[t]:0}:t));return o},N=(t,e)=>null==t||C(t)?t:1&e?t+"":t,P=t=>{var e;return null==(e=o(t))?void 0:e.$hostElement$},R=(t,e)=>{const n=P(t);return{emit:t=>H(n,e,{bubbles:!0,composed:!0,cancelable:!0,detail:t})}},H=(t,e,n)=>{const o=f.ce(e,n);return t.dispatchEvent(o),o},U=(t,e,n,o)=>{if(n!==o)if(e.toLowerCase(),"class"===e){const e=t.classList,l=W(n);let i=W(o);{let t=l.filter((t=>t&&!i.includes(t)));e.remove(...t),e.add(...i.filter((t=>t&&!l.includes(t))))}}else"key"===e||"ref"===e&&o&&K(o,t)},A=/\s/,W=t=>("object"==typeof t&&t&&"baseVal"in t&&(t=t.baseVal),t&&"string"==typeof t?t.split(A):[]),V=(t,e)=>{const n=11===e.S.nodeType&&e.S.host?e.S.host:e.S,o=t&&t.v||{},l=e.v||{};for(const t of q(Object.keys(o)))t in l||U(n,t,o[t],void 0);for(const t of q(Object.keys(l)))U(n,t,o[t],l[t])};function q(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var z=[],F=[],B=(t,e,n)=>{const o=e.$[n];let l,i,s=0;if(!u.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(l=o.S=u.document.createElement(o.O),V(null,o),o.$){const e="template"===o.O?l.content:l;for(s=0;s<o.$.length;++s)i=B(t,o,s),i&&e.appendChild(i)}return l["s-hn"]=k,l},G=(t,e,n,o,l,i)=>{let s,r=t;for(r.shadowRoot&&r.tagName===k&&(r=r.shadowRoot),"template"===n.O&&(r=r.content);l<=i;++l)o[l]&&(s=B(null,n,l),s&&(o[l].S=s,Q(r,s,e)))},I=(t,e,n)=>{for(let o=e;o<=n;++o){const e=t[o];if(e){const t=e.S;J(e),t&&t.remove()}}},Y=(t,e,n=!1)=>t.O===e.O&&(n?(n&&!t.j&&e.j&&(t.j=e.j),!0):t.j===e.j),_=(t,e,n=!1)=>{const o=e.S=t.S,l=t.$,i=e.$;V(t,e),null!==l&&null!==i?((t,e,n,o,l=!1)=>{let i,s,r=0,c=0,u=0,f=0,a=e.length-1,d=e[0],h=e[a],p=o.length-1,m=o[0],v=o[p];const b="template"===n.O?t.content:t;for(;r<=a&&c<=p;)if(null==d)d=e[++r];else if(null==h)h=e[--a];else if(null==m)m=o[++c];else if(null==v)v=o[--p];else if(Y(d,m,l))_(d,m,l),d=e[++r],m=o[++c];else if(Y(h,v,l))_(h,v,l),h=e[--a],v=o[--p];else if(Y(d,v,l))_(d,v,l),Q(b,d.S,h.S.nextSibling),d=e[++r],v=o[--p];else if(Y(h,m,l))_(h,m,l),Q(b,h.S,d.S),h=e[--a],m=o[++c];else{for(u=-1,f=r;f<=a;++f)if(e[f]&&null!==e[f].j&&e[f].j===m.j){u=f;break}u>=0?(s=e[u],s.O!==m.O?i=B(e&&e[c],n,c):(_(s,m,l),e[u]=void 0,i=s.S),m=o[++c]):(i=B(e&&e[c],n,c),m=o[++c]),i&&Q(d.S.parentNode,i,d.S)}r>a?G(t,null==o[p+1]?null:o[p+1].S,n,o,c,p):c>p&&I(e,r,a)})(o,l,e,i,n):null!==i?G(o,null,e,i,0,i.length-1):!n&&null!==l&&I(l,0,l.length-1)},J=t=>{t.v&&t.v.ref&&z.push((()=>t.v.ref(null))),t.$&&t.$.map(J)},K=(t,e)=>{F.push((()=>t(e)))},Q=(t,e,n)=>null==t?void 0:t.insertBefore(e,n),X=(t,e)=>{if(e&&!t.k&&e["s-p"]){const n=e["s-p"].push(new Promise((o=>t.k=()=>{e["s-p"].splice(n-1,1),o()})))}},Z=(t,e)=>{if(t.u|=16,4&t.u)return void(t.u|=512);X(t,t.M);const n=()=>tt(t,e);if(!e)return g(n);queueMicrotask((()=>{n()}))},tt=(t,e)=>{const n=t.$hostElement$,o=t.i;if(!o)throw 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 e?(t.C.length&&t.C.forEach((t=>t(n))),l=rt(o,"componentWillLoad",void 0,n)):l=rt(o,"componentWillUpdate",void 0,n),l=et(l,(()=>rt(o,"componentWillRender",void 0,n))),et(l,(()=>ot(t,o,e)))},et=(t,e)=>nt(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),nt=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,ot=async(t,e,n)=>{var o;const l=t.$hostElement$,i=l["s-rc"];n&&(t=>{const e=t.o,n=t.$hostElement$,o=e.u,l=((t,e)=>{var n,o,l;const i=E(e),s=c.get(i);if(!u.document)return i;if(t=11===t.nodeType?t:u.document,s)if("string"==typeof s){let l,r=M.get(t=t.head||t);if(r||M.set(t,r=new Set),!r.has(i)){l=u.document.createElement("style"),l.textContent=s;const c=null!=(n=f.T)?n:S(u.document);if(null!=c&&l.setAttribute("nonce",c),!(1&e.u))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(l,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(d){const e=new(null!=(o=t.defaultView)?o:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(s),h?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=s+e.textContent:t.prepend(l)}else t.append(l);1&e.u&&t.insertBefore(l,null),4&e.u&&(l.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),r&&r.add(i)}}else{let e=M.get(t);if(e||M.set(t,e=new Set),!e.has(i)){const n=null!=(l=t.defaultView)?l:t.ownerDocument.defaultView;let o;if(s.constructor===n.CSSStyleSheet)o=s;else{o=new n.CSSStyleSheet;for(let t=0;t<s.cssRules.length;t++)o.insertRule(s.cssRules[t].cssText,t)}h?t.adoptedStyleSheets.push(o):t.adoptedStyleSheets=[...t.adoptedStyleSheets,o],e.add(i)}}return i})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&o&&(n["s-sc"]=l,n.classList.add(l+"-h"))})(t);lt(t,e,l,n),i&&(i.map((t=>t())),l["s-rc"]=void 0);{const e=null!=(o=l["s-p"])?o:[],n=()=>it(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.u|=4,e.length=0)}},lt=(t,e,n,o)=>{try{e=e.render(),t.u&=-17,t.u|=2,((t,e,n=!1)=>{const o=t.$hostElement$,l=t.L||L(null,null),i=(t=>t&&t.O===x)(e)?e:T(null,null,e);if(k=o.tagName,n&&i.v)for(const t of Object.keys(i.v))o.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(i.v[t]=o[t]);i.O=null,i.u|=4,t.L=i,i.S=l.S=o.shadowRoot||o,_(l,i,n),z.forEach((t=>t())),z.length=0,F.forEach((t=>t())),F.length=0})(t,e,o)}catch(e){i(e,t.$hostElement$)}return null},it=t=>{const e=t.$hostElement$,n=t.i,o=t.M;rt(n,"componentDidRender",void 0,e),64&t.u?rt(n,"componentDidUpdate",void 0,e):(t.u|=64,ct(e),rt(n,"componentDidLoad",void 0,e),t.D(e),o||st()),t.k&&(t.k(),t.k=void 0),512&t.u&&j((()=>Z(t,!1))),t.u&=-517},st=()=>{j((()=>H(u,"appload",{detail:{namespace:"charts"}})))},rt=(t,e,n,o)=>{if(t&&t[e])try{return t[e](n)}catch(t){i(t,o)}},ct=t=>t.classList.add("hydrated"),ut=(t,e)=>o(t).l.get(e),ft=(t,e,n,l)=>{const s=o(t);if(!s)return;if(!s)throw Error(`Couldn't find host element for "${l.p}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`);const r=s.$hostElement$,c=s.l.get(e),u=s.u,f=s.i;if(n=N(n,l.t[e][0]),!(8&u&&void 0!==c||n===c||Number.isNaN(c)&&Number.isNaN(n))){if(s.l.set(e,n),l.N){const t=l.N[e];t&&t.map((t=>{try{const[[o,l]]=Object.entries(t);(128&u||1&l)&&(f?f[o](n,c,e):s.C.push((()=>{s.i[o](n,c,e)})))}catch(t){i(t,r)}}))}if(2&u){if(f.componentShouldUpdate&&!1===f.componentShouldUpdate(n,c,e)&&!(16&u))return;16&u||Z(s,!1)}}},at=(e,n,l)=>{var i,s;const r=e.prototype;{e.watchers&&!n.N&&(n.N=D(e.watchers)),e.deserializers&&!n.P&&(n.P=e.deserializers),e.serializers&&!n.R&&(n.R=e.serializers);const c=Object.entries(null!=(i=n.t)?i:{});if(c.map((([e,[i]])=>{if(31&i||2&l&&32&i){const{get:s,set:c}=t(r,e)||{};s&&(n.t[e][0]|=2048),c&&(n.t[e][0]|=4096),(1&l||!s)&&Object.defineProperty(r,e,{get(){{if(!(2048&n.t[e][0]))return ut(this,e);const t=o(this);return t?t.i?t.i[e]:ut(this,e):r[e]}},configurable:!0,enumerable:!0}),Object.defineProperty(r,e,{set(t){const s=o(this);if(s){if(c)return void 0===(32&i?this[e]:s.$hostElement$[e])&&s.l.get(e)&&(t=s.l.get(e)),c.call(this,N(t,i)),void ft(this,e,t=32&i?this[e]:s.$hostElement$[e],n);{if(!(1&l&&4096&n.t[e][0]))return void ft(this,e,t,n);const o=N(t,i);if(s.i){const t=s.i[e];!s.l.get(e)&&t&&s.l.set(e,t),s.i[e]=o,ft(this,e,s.i[e],n)}else s.l.set(e,o)}}}})}})),1&l){const t=new Map;r.attributeChangedCallback=function(e,l,i){f.jmp((()=>{var s;const u=t.get(e),f=o(this);if(this.hasOwnProperty(u)&&(i=this[u],delete this[u]),r.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==i)return;if(null==u){const t=null==f?void 0:f.u;if(f&&t&&!(8&t)&&i!==l){const o=f.i,r=null==(s=n.N)?void 0:s[e];null==r||r.forEach((n=>{const[[s,r]]=Object.entries(n);null!=o[s]&&(128&t||1&r)&&o[s].call(o,i,l,e)}))}return}const a=c.find((([t])=>t===u)),d=4&(a?a[1][0]:0),h=d&&null===i&&void 0===this[u];d&&(i=null!==i&&"false"!==i);const p=Object.getOwnPropertyDescriptor(r,u);h||i==this[u]||p.get&&!p.set||(this[u]=i)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n.N)?s:{}),...c.filter((([t,e])=>31&e[0])).map((([e,n])=>{const o=n[1]||e;return t.set(o,e),o}))]))}}return e},dt=async(t,e,n)=>{var o;let l;try{if(!(32&e.u)){if(e.u|=32,e.u&=-1025,n.H){const c=((t,e)=>{var n;const o=t.p.replace(/-/g,"_"),l=t.H;if(!l)return;const c=s.get(l);if(c)return c[o];const u=null!=(n=r.get(l))?n:0,f=[u>0?"s-retry="+u:"",""].filter(Boolean).join("&");
|
|
2
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
3
|
+
return import(`./${l}.entry.js${f?"?"+f:""}`).then((t=>(r.delete(l),s.set(l,t),t[o])),(t=>{r.set(l,u+1),i(t,e.$hostElement$)}))})(n,e);if(c&&"then"in c){const t=()=>{};l=await c,t()}else l=c;if(!l)throw e.u&=-33,e.U=(null!=(o=e.U)?o:0)+1,e.U<3&&(e.u|=1024),Error(`Constructor for "${n.p}#${e.A}" was not found`);l.isProxied||(n.N=D(l.watchers),n.R=l.serializers,n.P=l.deserializers,at(l,n,2),l.isProxied=!0);const u=()=>{};e.u|=8;try{new l(e)}catch(e){i(e,t)}e.u&=-9,((t,e)=>{var n;const o=t.i;if(o)for(const[l,[i]]of Object.entries(null!=(n=e.t)?n:{}))if(4096&i&&t.l.has(l)){const e=t.l.get(l);o[l]!==e&&(o[l]=e)}})(e,n),e.u|=128,u(),ht(e.i,t)}else l=t.constructor,customElements.whenDefined(t.localName).then((()=>e.u|=128));if(l&&l.style){let t;"string"==typeof l.style&&(t=l.style);const e=E(n);if(!c.has(e)){const o=()=>{};((t,e,n)=>{let o=c.get(t);d&&n?(o=o||new CSSStyleSheet,"string"==typeof o?o=e:o.replaceSync(e)):o=e,c.set(t,o)})(e,t,!!(1&n.u)),o()}}}const u=e.M,f=()=>Z(e,!0);u&&u["s-rc"]?u["s-rc"].push(f):f()}catch(n){i(n,t),e.k&&(e.k(),e.k=void 0),!e.D||1024&e.u||e.D(t)}},ht=(t,e)=>{rt(t,"connectedCallback",void 0,e)},pt=(t,e)=>{rt(t,"disconnectedCallback",void 0,e||t)},mt=(t,e={})=>{var n;if(!u.document)return void console.warn("Stencil: No document found. Skipping bootstrapping lazy components.");const l=[],i=e.exclude||[],s=u.customElements,r=u.document.head,c=r.querySelector("meta[charset]"),a=u.document.createElement("style"),d=[];let h,p=!0;if(Object.assign(f,e),f.h=new URL(e.resourcesUrl||"./",u.document.baseURI).href,t.map((t=>{t[1].map((e=>{var n,r;const c={u:e[0],p:e[1],t:e[2],W:e[3]};c.t=e[2],c.N=D(e[4]),c.R=null!=(n=e[5])?n:{},c.P=null!=(r=e[6])?r:{};const u=c.p,a=class extends HTMLElement{"s-p";"s-rc";hasRegisteredEventListeners=!1;constructor(t){if(super(t),((t,e)=>{const n={u:0,$hostElement$:t,o:e,l:new Map,V:new Map};n.q=new Promise((t=>n.D=t)),t["s-p"]=[],t["s-rc"]=[],n.C=[];const o=n;t.__stencil__getHostRef=()=>o})(t=this,c),1&c.u)if(t.shadowRoot){if("open"!==t.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${c.p}! Mode is set to ${t.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else O.call(t,c)}connectedCallback(){o(this)&&(this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),h&&(clearTimeout(h),h=null),p?d.push(this):f.jmp((()=>(t=>{if(!(1&f.u)){const e=o(t);if(!e)return;const n=e.o,l=()=>{};if(1&e.u)(null==e?void 0:e.i)?ht(e.i,t):1024&e.u?setTimeout((()=>dt(t,e,n)),1e3):(null==e?void 0:e.q)&&e.q.then((()=>ht(e.i,t)));else{e.u|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){X(e,e.M=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),dt(t,e,n)}l()}})(this))))}disconnectedCallback(){f.jmp((()=>(async t=>{if(!(1&f.u)){const e=o(t);(null==e?void 0:e.i)?pt(e.i,t):(null==e?void 0:e.q)&&e.q.then((()=>pt(e.i,t)))}M.has(t)&&M.delete(t),t.shadowRoot&&M.has(t.shadowRoot)&&M.delete(t.shadowRoot)})(this))),j((()=>{var t;const e=o(this);if(!e)return;const n=d.findIndex((t=>t===this));n>-1&&d.splice(n,1),(null==(t=null==e?void 0:e.L)?void 0:t.S)instanceof Node&&!e.L.S.isConnected&&delete e.L.S}))}componentOnReady(){var t;return null==(t=o(this))?void 0:t.q}};c.H=t[0],i.includes(u)||s.get(u)||(l.push(u),s.define(u,at(a,c,1)))}))})),l.length>0&&(a.textContent+=l.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",a.innerHTML.length)){a.setAttribute("data-styles","");const t=null!=(n=f.T)?n:S(u.document);null!=t&&a.setAttribute("nonce",t),r.insertBefore(a,c?c.nextSibling:r.firstChild)}p=!1,d.length?d.map((t=>t.connectedCallback())):f.jmp((()=>h=setTimeout(st,30)))},vt=t=>f.T=t;export{mt as b,R as c,P as g,T as h,a as p,l as r,vt as s}
|
package/dist/cjs/charts.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-dJHivNOd.js');
|
|
4
4
|
var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
5
5
|
|
|
6
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["itic-chart.cjs",[[1,"itic-chart",{"groups":[1]},null,{"groups":[{"
|
|
22
|
+
return index.bootstrapLazy([["itic-chart.cjs",[[1,"itic-chart",{"groups":[1],"xAxisName":[1,"x-axis-name"],"yAxisName":[1,"y-axis-name"],"tooltipFormatter":[16]},null,{"groups":[{"onOptionsChange":0}],"xAxisName":[{"onOptionsChange":0}],"yAxisName":[{"onOptionsChange":0}],"tooltipFormatter":[{"onOptionsChange":0}]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -473,6 +473,25 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
473
473
|
}
|
|
474
474
|
return propValue;
|
|
475
475
|
};
|
|
476
|
+
var getElement = (ref) => {
|
|
477
|
+
var _a;
|
|
478
|
+
return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
// src/runtime/event-emitter.ts
|
|
482
|
+
var createEvent = (ref, name, flags) => {
|
|
483
|
+
const elm = getElement(ref);
|
|
484
|
+
return {
|
|
485
|
+
emit: (detail) => {
|
|
486
|
+
return emitEvent(elm, name, {
|
|
487
|
+
bubbles: true,
|
|
488
|
+
composed: true,
|
|
489
|
+
cancelable: true,
|
|
490
|
+
detail
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
};
|
|
476
495
|
var emitEvent = (elm, name, opts) => {
|
|
477
496
|
const ev = plt.ce(name, opts);
|
|
478
497
|
elm.dispatchEvent(ev);
|
|
@@ -1442,6 +1461,8 @@ function transformTag(tag) {
|
|
|
1442
1461
|
}
|
|
1443
1462
|
|
|
1444
1463
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1464
|
+
exports.createEvent = createEvent;
|
|
1465
|
+
exports.getElement = getElement;
|
|
1445
1466
|
exports.h = h;
|
|
1446
1467
|
exports.promiseResolve = promiseResolve;
|
|
1447
1468
|
exports.registerInstance = registerInstance;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-dJHivNOd.js');
|
|
4
4
|
|
|
5
5
|
/*! *****************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -45143,36 +45143,63 @@ function escapeHtml(value) {
|
|
|
45143
45143
|
.replace(/"/g, '"')
|
|
45144
45144
|
.replace(/'/g, ''');
|
|
45145
45145
|
}
|
|
45146
|
-
|
|
45146
|
+
/** Default tooltip, in English. Escapes every value, since they come from the consumer. */
|
|
45147
|
+
const defaultTooltipFormatter = ({ duration, voltage, ts }, { groupName }) => {
|
|
45147
45148
|
const rows = {
|
|
45148
|
-
phase: escapeHtml(groupName),
|
|
45149
|
-
duration: `${duration} ms`,
|
|
45150
|
-
voltage: `${Math.round(voltage * 10) / 10}%`,
|
|
45151
|
-
ts: dayjs(ts).locale('en').format('DD MMM, HH:mm:ss.SSS'),
|
|
45149
|
+
phase: escapeHtml(String(groupName)),
|
|
45150
|
+
duration: `${escapeHtml(String(duration))} ms`,
|
|
45151
|
+
voltage: `${escapeHtml(String(Math.round(voltage * 10) / 10))}%`,
|
|
45152
|
+
ts: escapeHtml(dayjs(ts).locale('en').format('DD MMM, HH:mm:ss.SSS')),
|
|
45152
45153
|
};
|
|
45153
45154
|
return Object.entries(rows)
|
|
45154
45155
|
.map(([label, value]) => ` <strong>${label}</strong>: ${value}`)
|
|
45155
45156
|
.join('<br/>');
|
|
45156
|
-
}
|
|
45157
|
-
|
|
45158
|
-
|
|
45157
|
+
};
|
|
45158
|
+
const DEFAULT_SETTINGS = {
|
|
45159
|
+
xAxisName: 'Duration (ms)',
|
|
45160
|
+
yAxisName: 'Voltage (% of nominal voltage)',
|
|
45161
|
+
tooltipFormatter: defaultTooltipFormatter,
|
|
45162
|
+
};
|
|
45163
|
+
const isClickable = (point) => point.clickable !== false;
|
|
45164
|
+
function buildChartOptions(groups, settings = DEFAULT_SETTINGS) {
|
|
45165
|
+
return Object.assign(Object.assign({}, BASE_OPTIONS), { xAxis: Object.assign(Object.assign({}, BASE_OPTIONS.xAxis), { name: settings.xAxisName }), yAxis: Object.assign(Object.assign({}, BASE_OPTIONS.yAxis), { name: settings.yAxisName }), series: [
|
|
45159
45166
|
...CURVE_SERIES,
|
|
45160
|
-
...groups.map((
|
|
45167
|
+
...groups.map((group) => ({
|
|
45161
45168
|
type: 'scatter',
|
|
45162
|
-
name: groupName,
|
|
45163
|
-
|
|
45169
|
+
name: group.groupName,
|
|
45170
|
+
// ECharts 6 reads `cursor` per data item, although its types only declare it per series
|
|
45171
|
+
data: group.points.map(point => ({
|
|
45172
|
+
value: [point.duration, point.voltage],
|
|
45173
|
+
cursor: isClickable(point) ? 'pointer' : 'default',
|
|
45174
|
+
})),
|
|
45164
45175
|
symbolSize: 12,
|
|
45165
45176
|
z: 4,
|
|
45166
45177
|
itemStyle: {
|
|
45167
|
-
color,
|
|
45178
|
+
color: group.color,
|
|
45168
45179
|
opacity: 1,
|
|
45169
45180
|
},
|
|
45170
45181
|
tooltip: {
|
|
45171
|
-
formatter: params =>
|
|
45182
|
+
formatter: params => settings.tooltipFormatter(group.points[params.dataIndex], group),
|
|
45172
45183
|
},
|
|
45173
45184
|
})),
|
|
45174
45185
|
] });
|
|
45175
45186
|
}
|
|
45187
|
+
/**
|
|
45188
|
+
* Maps an ECharts click back to the original point and group, which `buildChartOptions` draws as
|
|
45189
|
+
* scatter series after the ITIC curve series, in the same order as `groups`.
|
|
45190
|
+
* Returns `undefined` for clicks outside the points and on points that aren't clickable.
|
|
45191
|
+
*/
|
|
45192
|
+
function findClickedPoint(groups, { componentType, seriesIndex, dataIndex }) {
|
|
45193
|
+
if (componentType !== 'series' || seriesIndex == null || dataIndex == null) {
|
|
45194
|
+
return undefined;
|
|
45195
|
+
}
|
|
45196
|
+
const group = groups[seriesIndex - CURVE_SERIES.length];
|
|
45197
|
+
const point = group === null || group === void 0 ? void 0 : group.points[dataIndex];
|
|
45198
|
+
if (!point || !isClickable(point)) {
|
|
45199
|
+
return undefined;
|
|
45200
|
+
}
|
|
45201
|
+
return { point, group };
|
|
45202
|
+
}
|
|
45176
45203
|
const ITIC_CURVE_PROHIBITED_REGION = [
|
|
45177
45204
|
[0.167, 500],
|
|
45178
45205
|
[1, 200],
|
|
@@ -45199,7 +45226,8 @@ const BASE_OPTIONS = {
|
|
|
45199
45226
|
},
|
|
45200
45227
|
// ECharts 6 moved the default legend to the bottom; keep it on top as in previous versions
|
|
45201
45228
|
legend: { top: 0 },
|
|
45202
|
-
|
|
45229
|
+
// Outside the shadow root, so containers with `overflow: hidden` don't clip it. Its styles are inline.
|
|
45230
|
+
tooltip: { appendTo: 'body' },
|
|
45203
45231
|
textStyle: {
|
|
45204
45232
|
fontFamily: 'CDS-Regular, Arial',
|
|
45205
45233
|
},
|
|
@@ -45207,7 +45235,6 @@ const BASE_OPTIONS = {
|
|
|
45207
45235
|
type: 'log',
|
|
45208
45236
|
min: 0.1,
|
|
45209
45237
|
max: 100000,
|
|
45210
|
-
name: 'Duration (ms)',
|
|
45211
45238
|
nameGap: 30,
|
|
45212
45239
|
nameLocation: 'middle',
|
|
45213
45240
|
nameTextStyle: {
|
|
@@ -45223,7 +45250,6 @@ const BASE_OPTIONS = {
|
|
|
45223
45250
|
fontSize: 16,
|
|
45224
45251
|
fontWeight: 'bold',
|
|
45225
45252
|
},
|
|
45226
|
-
name: 'Voltage (% of nominal voltage)',
|
|
45227
45253
|
nameRotate: 90,
|
|
45228
45254
|
nameGap: 40,
|
|
45229
45255
|
nameLocation: 'middle',
|
|
@@ -45328,18 +45354,32 @@ const CURVE_SERIES = [
|
|
|
45328
45354
|
},
|
|
45329
45355
|
];
|
|
45330
45356
|
|
|
45331
|
-
const iticChartCss = () => `:host{display:block;height:400px}.chart{width:100%;height:100%}`;
|
|
45357
|
+
const iticChartCss = () => `:host{display:block;height:400px;background:var(--itic-chart-background, transparent)}.chart{width:100%;height:100%}`;
|
|
45332
45358
|
|
|
45333
45359
|
// Register only what this chart uses, so bundles don't ship all of ECharts
|
|
45334
45360
|
use([install$9, install$7, install$5, install$1, install$4, install]);
|
|
45335
45361
|
const IticChart = class {
|
|
45336
45362
|
constructor(hostRef) {
|
|
45337
45363
|
index.registerInstance(this, hostRef);
|
|
45364
|
+
this.pointClick = index.createEvent(this, "pointClick");
|
|
45365
|
+
/**
|
|
45366
|
+
* Name of the duration (X) axis.
|
|
45367
|
+
*/
|
|
45368
|
+
this.xAxisName = DEFAULT_SETTINGS.xAxisName;
|
|
45369
|
+
/**
|
|
45370
|
+
* Name of the voltage (Y) axis.
|
|
45371
|
+
*/
|
|
45372
|
+
this.yAxisName = DEFAULT_SETTINGS.yAxisName;
|
|
45373
|
+
this.parsedGroups = [];
|
|
45338
45374
|
}
|
|
45339
|
-
|
|
45375
|
+
onOptionsChange() {
|
|
45340
45376
|
this.updateChart();
|
|
45341
45377
|
}
|
|
45342
45378
|
connectedCallback() {
|
|
45379
|
+
// The chart is a canvas: expose it as an image, labelled with `aria-label`, unless the consumer sets a role
|
|
45380
|
+
if (!this.el.hasAttribute('role')) {
|
|
45381
|
+
this.el.setAttribute('role', 'img');
|
|
45382
|
+
}
|
|
45343
45383
|
// componentDidLoad only fires once, so re-create the chart when the element is re-attached
|
|
45344
45384
|
this.initChart();
|
|
45345
45385
|
}
|
|
@@ -45358,6 +45398,12 @@ const IticChart = class {
|
|
|
45358
45398
|
return;
|
|
45359
45399
|
}
|
|
45360
45400
|
this.chart = init(this.container);
|
|
45401
|
+
this.chart.on('click', params => {
|
|
45402
|
+
const detail = findClickedPoint(this.parsedGroups, params);
|
|
45403
|
+
if (detail) {
|
|
45404
|
+
this.pointClick.emit(detail);
|
|
45405
|
+
}
|
|
45406
|
+
});
|
|
45361
45407
|
if (typeof ResizeObserver !== 'undefined') {
|
|
45362
45408
|
this.resizeObserver = new ResizeObserver(() => { var _a; return (_a = this.chart) === null || _a === void 0 ? void 0 : _a.resize(); });
|
|
45363
45409
|
this.resizeObserver.observe(this.container);
|
|
@@ -45365,24 +45411,40 @@ const IticChart = class {
|
|
|
45365
45411
|
this.updateChart();
|
|
45366
45412
|
}
|
|
45367
45413
|
updateChart() {
|
|
45414
|
+
var _a;
|
|
45368
45415
|
if (!this.chart) {
|
|
45369
45416
|
return;
|
|
45370
45417
|
}
|
|
45371
|
-
|
|
45418
|
+
this.parsedGroups = [];
|
|
45372
45419
|
try {
|
|
45373
|
-
|
|
45420
|
+
this.parsedGroups = parseGroups(this.groups);
|
|
45374
45421
|
}
|
|
45375
45422
|
catch (error) {
|
|
45376
45423
|
console.error('[itic-chart] Invalid "groups" prop:', error);
|
|
45377
45424
|
}
|
|
45378
|
-
this.
|
|
45425
|
+
const options = buildChartOptions(this.parsedGroups, {
|
|
45426
|
+
xAxisName: this.xAxisName,
|
|
45427
|
+
yAxisName: this.yAxisName,
|
|
45428
|
+
tooltipFormatter: (_a = this.tooltipFormatter) !== null && _a !== void 0 ? _a : DEFAULT_SETTINGS.tooltipFormatter,
|
|
45429
|
+
});
|
|
45430
|
+
this.chart.setOption(options, { notMerge: true });
|
|
45379
45431
|
}
|
|
45380
45432
|
render() {
|
|
45381
|
-
return index.h("div", { key: '
|
|
45433
|
+
return index.h("div", { key: '53914c2232775d69a35b846005931c5e20f2eee2', class: "chart", ref: el => (this.container = el) });
|
|
45382
45434
|
}
|
|
45435
|
+
get el() { return index.getElement(this); }
|
|
45383
45436
|
static get watchers() { return {
|
|
45384
45437
|
"groups": [{
|
|
45385
|
-
"
|
|
45438
|
+
"onOptionsChange": 0
|
|
45439
|
+
}],
|
|
45440
|
+
"xAxisName": [{
|
|
45441
|
+
"onOptionsChange": 0
|
|
45442
|
+
}],
|
|
45443
|
+
"yAxisName": [{
|
|
45444
|
+
"onOptionsChange": 0
|
|
45445
|
+
}],
|
|
45446
|
+
"tooltipFormatter": [{
|
|
45447
|
+
"onOptionsChange": 0
|
|
45386
45448
|
}]
|
|
45387
45449
|
}; }
|
|
45388
45450
|
};
|
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-dJHivNOd.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([["itic-chart.cjs",[[1,"itic-chart",{"groups":[1]},null,{"groups":[{"
|
|
9
|
+
return index.bootstrapLazy([["itic-chart.cjs",[[1,"itic-chart",{"groups":[1],"xAxisName":[1,"x-axis-name"],"yAxisName":[1,"y-axis-name"],"tooltipFormatter":[16]},null,{"groups":[{"onOptionsChange":0}],"xAxisName":[{"onOptionsChange":0}],"yAxisName":[{"onOptionsChange":0}],"tooltipFormatter":[{"onOptionsChange":0}]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -3,14 +3,29 @@ import * as echarts from "echarts/core";
|
|
|
3
3
|
import { LineChart, ScatterChart } from "echarts/charts";
|
|
4
4
|
import { GridComponent, LegendComponent, TooltipComponent } from "echarts/components";
|
|
5
5
|
import { CanvasRenderer } from "echarts/renderers";
|
|
6
|
-
import { buildChartOptions, parseGroups } from "./itic-chart.options";
|
|
6
|
+
import { buildChartOptions, DEFAULT_SETTINGS, findClickedPoint, parseGroups, } from "./itic-chart.options";
|
|
7
7
|
// Register only what this chart uses, so bundles don't ship all of ECharts
|
|
8
8
|
echarts.use([LineChart, ScatterChart, GridComponent, LegendComponent, TooltipComponent, CanvasRenderer]);
|
|
9
9
|
export class IticChart {
|
|
10
|
-
|
|
10
|
+
constructor() {
|
|
11
|
+
/**
|
|
12
|
+
* Name of the duration (X) axis.
|
|
13
|
+
*/
|
|
14
|
+
this.xAxisName = DEFAULT_SETTINGS.xAxisName;
|
|
15
|
+
/**
|
|
16
|
+
* Name of the voltage (Y) axis.
|
|
17
|
+
*/
|
|
18
|
+
this.yAxisName = DEFAULT_SETTINGS.yAxisName;
|
|
19
|
+
this.parsedGroups = [];
|
|
20
|
+
}
|
|
21
|
+
onOptionsChange() {
|
|
11
22
|
this.updateChart();
|
|
12
23
|
}
|
|
13
24
|
connectedCallback() {
|
|
25
|
+
// The chart is a canvas: expose it as an image, labelled with `aria-label`, unless the consumer sets a role
|
|
26
|
+
if (!this.el.hasAttribute('role')) {
|
|
27
|
+
this.el.setAttribute('role', 'img');
|
|
28
|
+
}
|
|
14
29
|
// componentDidLoad only fires once, so re-create the chart when the element is re-attached
|
|
15
30
|
this.initChart();
|
|
16
31
|
}
|
|
@@ -29,6 +44,12 @@ export class IticChart {
|
|
|
29
44
|
return;
|
|
30
45
|
}
|
|
31
46
|
this.chart = echarts.init(this.container);
|
|
47
|
+
this.chart.on('click', params => {
|
|
48
|
+
const detail = findClickedPoint(this.parsedGroups, params);
|
|
49
|
+
if (detail) {
|
|
50
|
+
this.pointClick.emit(detail);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
32
53
|
if (typeof ResizeObserver !== 'undefined') {
|
|
33
54
|
this.resizeObserver = new ResizeObserver(() => { var _a; return (_a = this.chart) === null || _a === void 0 ? void 0 : _a.resize(); });
|
|
34
55
|
this.resizeObserver.observe(this.container);
|
|
@@ -36,20 +57,26 @@ export class IticChart {
|
|
|
36
57
|
this.updateChart();
|
|
37
58
|
}
|
|
38
59
|
updateChart() {
|
|
60
|
+
var _a;
|
|
39
61
|
if (!this.chart) {
|
|
40
62
|
return;
|
|
41
63
|
}
|
|
42
|
-
|
|
64
|
+
this.parsedGroups = [];
|
|
43
65
|
try {
|
|
44
|
-
|
|
66
|
+
this.parsedGroups = parseGroups(this.groups);
|
|
45
67
|
}
|
|
46
68
|
catch (error) {
|
|
47
69
|
console.error('[itic-chart] Invalid "groups" prop:', error);
|
|
48
70
|
}
|
|
49
|
-
this.
|
|
71
|
+
const options = buildChartOptions(this.parsedGroups, {
|
|
72
|
+
xAxisName: this.xAxisName,
|
|
73
|
+
yAxisName: this.yAxisName,
|
|
74
|
+
tooltipFormatter: (_a = this.tooltipFormatter) !== null && _a !== void 0 ? _a : DEFAULT_SETTINGS.tooltipFormatter,
|
|
75
|
+
});
|
|
76
|
+
this.chart.setOption(options, { notMerge: true });
|
|
50
77
|
}
|
|
51
78
|
render() {
|
|
52
|
-
return h("div", { key: '
|
|
79
|
+
return h("div", { key: '53914c2232775d69a35b846005931c5e20f2eee2', class: "chart", ref: el => (this.container = el) });
|
|
53
80
|
}
|
|
54
81
|
static get is() { return "itic-chart"; }
|
|
55
82
|
static get encapsulation() { return "shadow"; }
|
|
@@ -84,19 +111,118 @@ export class IticChart {
|
|
|
84
111
|
"optional": false,
|
|
85
112
|
"docs": {
|
|
86
113
|
"tags": [],
|
|
87
|
-
"text": "
|
|
114
|
+
"text": "Point groups, as an array or a JSON string. Extra fields in groups and points are kept and passed\nback in `pointClick` and `tooltipFormatter`."
|
|
88
115
|
},
|
|
89
116
|
"getter": false,
|
|
90
117
|
"setter": false,
|
|
91
118
|
"reflect": false,
|
|
92
119
|
"attribute": "groups"
|
|
120
|
+
},
|
|
121
|
+
"xAxisName": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"mutable": false,
|
|
124
|
+
"complexType": {
|
|
125
|
+
"original": "string",
|
|
126
|
+
"resolved": "string",
|
|
127
|
+
"references": {}
|
|
128
|
+
},
|
|
129
|
+
"required": false,
|
|
130
|
+
"optional": false,
|
|
131
|
+
"docs": {
|
|
132
|
+
"tags": [],
|
|
133
|
+
"text": "Name of the duration (X) axis."
|
|
134
|
+
},
|
|
135
|
+
"getter": false,
|
|
136
|
+
"setter": false,
|
|
137
|
+
"reflect": false,
|
|
138
|
+
"attribute": "x-axis-name",
|
|
139
|
+
"defaultValue": "'Duration (ms)'"
|
|
140
|
+
},
|
|
141
|
+
"yAxisName": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"mutable": false,
|
|
144
|
+
"complexType": {
|
|
145
|
+
"original": "string",
|
|
146
|
+
"resolved": "string",
|
|
147
|
+
"references": {}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": "Name of the voltage (Y) axis."
|
|
154
|
+
},
|
|
155
|
+
"getter": false,
|
|
156
|
+
"setter": false,
|
|
157
|
+
"reflect": false,
|
|
158
|
+
"attribute": "y-axis-name",
|
|
159
|
+
"defaultValue": "'Voltage (% of nominal voltage)'"
|
|
160
|
+
},
|
|
161
|
+
"tooltipFormatter": {
|
|
162
|
+
"type": "unknown",
|
|
163
|
+
"mutable": false,
|
|
164
|
+
"complexType": {
|
|
165
|
+
"original": "ITICTooltipFormatter",
|
|
166
|
+
"resolved": "(point: ITICPoint, group: ITICChartMarks) => string",
|
|
167
|
+
"references": {
|
|
168
|
+
"ITICTooltipFormatter": {
|
|
169
|
+
"location": "import",
|
|
170
|
+
"path": "./itic-chart.options",
|
|
171
|
+
"id": "src/components/itic-chart/itic-chart.options.ts::ITICTooltipFormatter",
|
|
172
|
+
"referenceLocation": "ITICTooltipFormatter"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"required": false,
|
|
177
|
+
"optional": true,
|
|
178
|
+
"docs": {
|
|
179
|
+
"tags": [],
|
|
180
|
+
"text": "Returns the HTML of a point's tooltip. JS/React property only (not an HTML attribute).\nThe HTML is inserted as is: escaping the values is up to the formatter.\nDefaults to an English tooltip with phase, duration, voltage and timestamp."
|
|
181
|
+
},
|
|
182
|
+
"getter": false,
|
|
183
|
+
"setter": false
|
|
93
184
|
}
|
|
94
185
|
};
|
|
95
186
|
}
|
|
187
|
+
static get events() {
|
|
188
|
+
return [{
|
|
189
|
+
"method": "pointClick",
|
|
190
|
+
"name": "pointClick",
|
|
191
|
+
"bubbles": true,
|
|
192
|
+
"cancelable": true,
|
|
193
|
+
"composed": true,
|
|
194
|
+
"docs": {
|
|
195
|
+
"tags": [],
|
|
196
|
+
"text": "Emitted when a clickable point is clicked (`clickable` isn't `false`). `detail` holds the original\npoint and group objects."
|
|
197
|
+
},
|
|
198
|
+
"complexType": {
|
|
199
|
+
"original": "ITICPointClickDetail",
|
|
200
|
+
"resolved": "{ point: ITICPoint; group: ITICChartMarks; }",
|
|
201
|
+
"references": {
|
|
202
|
+
"ITICPointClickDetail": {
|
|
203
|
+
"location": "import",
|
|
204
|
+
"path": "./itic-chart.options",
|
|
205
|
+
"id": "src/components/itic-chart/itic-chart.options.ts::ITICPointClickDetail",
|
|
206
|
+
"referenceLocation": "ITICPointClickDetail"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}];
|
|
211
|
+
}
|
|
212
|
+
static get elementRef() { return "el"; }
|
|
96
213
|
static get watchers() {
|
|
97
214
|
return [{
|
|
98
215
|
"propName": "groups",
|
|
99
|
-
"methodName": "
|
|
216
|
+
"methodName": "onOptionsChange"
|
|
217
|
+
}, {
|
|
218
|
+
"propName": "xAxisName",
|
|
219
|
+
"methodName": "onOptionsChange"
|
|
220
|
+
}, {
|
|
221
|
+
"propName": "yAxisName",
|
|
222
|
+
"methodName": "onOptionsChange"
|
|
223
|
+
}, {
|
|
224
|
+
"propName": "tooltipFormatter",
|
|
225
|
+
"methodName": "onOptionsChange"
|
|
100
226
|
}];
|
|
101
227
|
}
|
|
102
228
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @prop --itic-chart-background: Background behind the whole chart. Defaults to `transparent`.
|
|
3
|
+
*/
|
|
1
4
|
:host {
|
|
2
5
|
display: block;
|
|
6
|
+
/* Default size; any rule on `itic-chart` in the page (height, min-height, flex) wins over `:host` */
|
|
3
7
|
height: 400px;
|
|
8
|
+
background: var(--itic-chart-background, transparent);
|
|
4
9
|
}
|
|
5
10
|
|
|
6
11
|
.chart {
|
|
@@ -21,36 +21,63 @@ export function escapeHtml(value) {
|
|
|
21
21
|
.replace(/"/g, '"')
|
|
22
22
|
.replace(/'/g, ''');
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/** Default tooltip, in English. Escapes every value, since they come from the consumer. */
|
|
25
|
+
export const defaultTooltipFormatter = ({ duration, voltage, ts }, { groupName }) => {
|
|
25
26
|
const rows = {
|
|
26
|
-
phase: escapeHtml(groupName),
|
|
27
|
-
duration: `${duration} ms`,
|
|
28
|
-
voltage: `${Math.round(voltage * 10) / 10}%`,
|
|
29
|
-
ts: dayjs(ts).locale('en').format('DD MMM, HH:mm:ss.SSS'),
|
|
27
|
+
phase: escapeHtml(String(groupName)),
|
|
28
|
+
duration: `${escapeHtml(String(duration))} ms`,
|
|
29
|
+
voltage: `${escapeHtml(String(Math.round(voltage * 10) / 10))}%`,
|
|
30
|
+
ts: escapeHtml(dayjs(ts).locale('en').format('DD MMM, HH:mm:ss.SSS')),
|
|
30
31
|
};
|
|
31
32
|
return Object.entries(rows)
|
|
32
33
|
.map(([label, value]) => ` <strong>${label}</strong>: ${value}`)
|
|
33
34
|
.join('<br/>');
|
|
34
|
-
}
|
|
35
|
-
export
|
|
36
|
-
|
|
35
|
+
};
|
|
36
|
+
export const DEFAULT_SETTINGS = {
|
|
37
|
+
xAxisName: 'Duration (ms)',
|
|
38
|
+
yAxisName: 'Voltage (% of nominal voltage)',
|
|
39
|
+
tooltipFormatter: defaultTooltipFormatter,
|
|
40
|
+
};
|
|
41
|
+
export const isClickable = (point) => point.clickable !== false;
|
|
42
|
+
export function buildChartOptions(groups, settings = DEFAULT_SETTINGS) {
|
|
43
|
+
return Object.assign(Object.assign({}, BASE_OPTIONS), { xAxis: Object.assign(Object.assign({}, BASE_OPTIONS.xAxis), { name: settings.xAxisName }), yAxis: Object.assign(Object.assign({}, BASE_OPTIONS.yAxis), { name: settings.yAxisName }), series: [
|
|
37
44
|
...CURVE_SERIES,
|
|
38
|
-
...groups.map((
|
|
45
|
+
...groups.map((group) => ({
|
|
39
46
|
type: 'scatter',
|
|
40
|
-
name: groupName,
|
|
41
|
-
|
|
47
|
+
name: group.groupName,
|
|
48
|
+
// ECharts 6 reads `cursor` per data item, although its types only declare it per series
|
|
49
|
+
data: group.points.map(point => ({
|
|
50
|
+
value: [point.duration, point.voltage],
|
|
51
|
+
cursor: isClickable(point) ? 'pointer' : 'default',
|
|
52
|
+
})),
|
|
42
53
|
symbolSize: 12,
|
|
43
54
|
z: 4,
|
|
44
55
|
itemStyle: {
|
|
45
|
-
color,
|
|
56
|
+
color: group.color,
|
|
46
57
|
opacity: 1,
|
|
47
58
|
},
|
|
48
59
|
tooltip: {
|
|
49
|
-
formatter: params =>
|
|
60
|
+
formatter: params => settings.tooltipFormatter(group.points[params.dataIndex], group),
|
|
50
61
|
},
|
|
51
62
|
})),
|
|
52
63
|
] });
|
|
53
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Maps an ECharts click back to the original point and group, which `buildChartOptions` draws as
|
|
67
|
+
* scatter series after the ITIC curve series, in the same order as `groups`.
|
|
68
|
+
* Returns `undefined` for clicks outside the points and on points that aren't clickable.
|
|
69
|
+
*/
|
|
70
|
+
export function findClickedPoint(groups, { componentType, seriesIndex, dataIndex }) {
|
|
71
|
+
if (componentType !== 'series' || seriesIndex == null || dataIndex == null) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const group = groups[seriesIndex - CURVE_SERIES.length];
|
|
75
|
+
const point = group === null || group === void 0 ? void 0 : group.points[dataIndex];
|
|
76
|
+
if (!point || !isClickable(point)) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return { point, group };
|
|
80
|
+
}
|
|
54
81
|
const ITIC_CURVE_PROHIBITED_REGION = [
|
|
55
82
|
[0.167, 500],
|
|
56
83
|
[1, 200],
|
|
@@ -77,7 +104,8 @@ const BASE_OPTIONS = {
|
|
|
77
104
|
},
|
|
78
105
|
// ECharts 6 moved the default legend to the bottom; keep it on top as in previous versions
|
|
79
106
|
legend: { top: 0 },
|
|
80
|
-
|
|
107
|
+
// Outside the shadow root, so containers with `overflow: hidden` don't clip it. Its styles are inline.
|
|
108
|
+
tooltip: { appendTo: 'body' },
|
|
81
109
|
textStyle: {
|
|
82
110
|
fontFamily: 'CDS-Regular, Arial',
|
|
83
111
|
},
|
|
@@ -85,7 +113,6 @@ const BASE_OPTIONS = {
|
|
|
85
113
|
type: 'log',
|
|
86
114
|
min: 0.1,
|
|
87
115
|
max: 100000,
|
|
88
|
-
name: 'Duration (ms)',
|
|
89
116
|
nameGap: 30,
|
|
90
117
|
nameLocation: 'middle',
|
|
91
118
|
nameTextStyle: {
|
|
@@ -101,7 +128,6 @@ const BASE_OPTIONS = {
|
|
|
101
128
|
fontSize: 16,
|
|
102
129
|
fontWeight: 'bold',
|
|
103
130
|
},
|
|
104
|
-
name: 'Voltage (% of nominal voltage)',
|
|
105
131
|
nameRotate: 90,
|
|
106
132
|
nameGap: 40,
|
|
107
133
|
nameLocation: 'middle',
|