-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
1 lines (1 loc) · 1.53 KB
/
index.js
1
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("chart.js"),require("vue-demi")):"function"==typeof define&&define.amd?define(["chart.js","vue-demi"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VueChart=t(e.Chart,e.VueDemi)}(this,(function(e,t){"use strict";var n=Object.is;let{isArray:i,isObject:o}=e.helpers;function r(e,t){if(n(e,t))return e;if(i(t)){if(i(e)){let n=e.length,i=t.length;for(let o=0,s=Math.min(n,i);o<s;o++)e[o]=r(e[o],t[o]);return n>i?e.splice(i):n<i&&e.push(...t.slice(n)),e}}else if(o(t)&&o(e)){let n=new Set(Object.keys(e)),i=new Set(Object.keys(t));return new Set([...n,...i]).forEach((o=>{n.has(o)?i.has(o)?e[o]=r(e[o],t[o]):delete e[o]:i.has(o)&&(e[o]=t[o])})),e}return t}let{clone:s}=e.helpers;var a,u,l=t.defineComponent({name:"VueChart",props:{data:Object,options:Object,type:{type:String,required:!0},updateMode:String},setup(n,{refs:i}){let o,a=t.ref(null);return t.onMounted((()=>{let u=t.isVue2?i.canvas:a.value;t.watchEffect((()=>{let{data:t,options:i,type:a,updateMode:l}=n;t=s(t),i=s(i),o=(()=>{if(o){if(o.config.type===a)return r(o.data,t),o.options=i,o.update(l),o;o.destroy()}return new e.Chart(u,{type:a,data:t,options:i})})()}))})),t.onUnmounted((()=>{o&&o.destroy()})),()=>t.h("div",{style:{height:"100%",position:"relative",width:"100%"}},[t.h("canvas",{style:{bottom:0,left:0,position:"absolute",right:0,top:0},ref:t.isVue2?"canvas":a})])}});t.isVue2&&(null===(a=globalThis.window)||void 0===a||null===(u=a.Vue)||void 0===u||u.component(l.name,l));return l}));