UNPKG

uplot-vue

Version:

Vue.js wrapper for uPlot that allows you to work with charts declaratively inside your favorite framework

2 lines 3.05 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue"),require("uplot")):"function"==typeof define&&define.amd?define(["vue","uplot"],e):"object"==typeof exports?exports.UplotVue=e(require("vue"),require("uplot")):t.UplotVue=e(t.Vue,t.uPlot)}(this,((t,e)=>(()=>{"use strict";var r={207:t=>{t.exports=e},327:e=>{e.exports=t}},o={};function n(t){var e=o[t];if(void 0!==e)return e.exports;var i=o[t]={exports:{}};return r[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};return(()=>{n.d(i,{default:()=>a});var t=n(327),e=n(207),r=n.n(e),o=function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(r[o[n]]=t[o[n]])}return r};Object.is||Object.defineProperty(Object,"is",{value:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e}});const a=(t.defineComponent?t.defineComponent:function(t){return t})({name:"UplotVue",props:{options:{type:Object,required:!0},data:{type:Array,required:!0},target:{validator:function(t){return null==t||t instanceof HTMLElement||"function"==typeof t},default:void 0,required:!1},resetScales:{type:Boolean,required:!1,default:!0},class:{type:String,required:!1}},data:function(){return{_chart:null}},watch:{options:function(t,e){var r=function(t,e){var r=t.width,n=t.height,i=o(t,["width","height"]),a=e.width,s=e.height,u=o(e,["width","height"]),c="keep";if(n===s&&r===a||(c="update"),Object.keys(i).length!==Object.keys(u).length)return"create";for(var h=0,p=Object.keys(i);h<p.length;h++){var f=p[h];if(!Object.is(i[f],u[f])){c="create";break}}return c}(e,t);this._chart&&"create"!==r?"update"===r&&this._chart.setSize({width:t.width,height:t.height}):(this._destroy(),this._create())},target:function(){this._destroy(),this._create()},data:function(t,e){var r,o;this._chart?(o=t,(r=e).length===o.length&&r.every((function(t,e){var r=o[e];return t.length===r.length&&t.every((function(t,e){return t===r[e]}))}))||(this.$props.resetScales?this._chart.setData(t):(this._chart.setData(t,!1),this._chart.redraw()))):this._create()}},mounted:function(){this._create()},beforeUnmount:function(){this._destroy()},beforeDestroy:function(){this._destroy()},methods:{_destroy:function(){this._chart&&(this.$emit("delete",this._chart),this._chart.destroy(),this._chart=null)},_create:function(){this._chart=new(r())(this.$props.options,this.$props.data,this.$props.target||this.$refs.targetRef),this.$emit("create",this._chart)}},render:function(e){return this.$props.target?null:(t.createVNode?t.createVNode:e)("div",{ref:"targetRef",class:this.$props.class})}})})(),i.default})())); //# sourceMappingURL=uplot-vue.min.js.map