bin-charts
Version:
基于echarts的 vue插件,用于配合实现图表组件
7 lines (6 loc) • 3.92 kB
JavaScript
/*!
* bin-charts v3.1.0
* (c) 2021 wangbin
* @license MIT
*/
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("echarts"),n=require("resize-observer-polyfill");function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){t[n]=e[n]})),t.default=e,Object.freeze(t)}var o=i(t),a=r(n);function s(e,t){return function(e,t,n){var r,i=0;return function(){var o=this,a=Number(new Date)-i,s=arguments;function u(){r&&clearTimeout(r)}function c(){r=void 0}function f(){i=Number(new Date),e.apply(o,s)}n&&!r&&f(),u(),void 0===n&&a>t?f():r=setTimeout(n?c:f,void 0===n?t-a:t)}}(e,t,!1)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f="undefined"==typeof window,l=function(e){for(var t,n=c(e);!(t=n()).done;){var r=t.value.target.__resizeListeners__||[];r.length&&r.forEach((function(e){e()}))}},d={name:"BCharts",props:{width:{type:String,default:"100%"},height:{type:String,default:"350px"},options:{type:Object,required:!0}},computed:{wrapStyle:function(){return{width:this.width,height:this.height}}},setup:function(t){var n=e.ref(null),r=null,i=null;function u(){r&&(r.dispose(),r=null),r=o.init(n.value),d(t.options)}function c(){r&&r.resize()}function d(e){r&&r.setOption(e)}function p(){r&&r.clear()}return e.onMounted((function(){var e,t;u(),i=s(c,100),e=n.value,t=i,!f&&e&&(e.__resizeListeners__||(e.__resizeListeners__=[],e.__ro__=new a(l),e.__ro__.observe(e)),e.__resizeListeners__.push(t))})),e.onBeforeUnmount((function(){var e,t;e=n.value,t=i,e&&e.__resizeListeners__&&(e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(t),1),e.__resizeListeners__.length||e.__ro__.disconnect()),r&&(r.dispose(),r=null)})),e.watch((function(){return t.options}),(function(e){d(e)}),{deep:!0}),{elRef:n,resize:c,init:u,getInstance:function(){return r},refresh:function(){p(),d(t.options)},clear:p,setOptions:d,dispatchAction:function(e){r&&r.dispatchAction(e)},showLoading:function(e){r&&r.showLoading(e)},hideLoading:function(){r&&r.hideLoading()}}}};d.render=function(t,n,r,i,o,a){return e.openBlock(),e.createBlock("div",{class:"bin-charts",ref:"elRef",style:a.wrapStyle},null,4)},d.__file="src/components/charts/charts.vue",d.install=function(e){e.component(d.name,d)};var p={};function _(e){void 0===e&&(e="default");var t="";switch(e){case"primary":t="#0d85ff";break;case"success":t="#52c41a";break;case"warning":t="#fea638";break;case"danger":t="#ff4d4f";break;case"default":t="#35495E";break;default:t=e}return t}p.pretty=function(e,t,n){void 0===n&&(n="primary"),console.log("%c "+e+" %c "+t+" %c","background:"+_(n)+";border:1px solid "+_(n)+"; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;","border:1px solid "+_(n)+"; padding: 1px; border-radius: 0 2px 2px 0; color: "+_(n)+";","background:transparent")};var h="bin-charts",v="3.1.0",b="https://wangbin3162.gitee.io/bin-charts/",y={version:v,install:function(e,t){return void 0===t&&(t={}),e.component(d.name,d),t.disabledDoc||p.pretty("["+h+"] "+v,b),e}};exports.Charts=d,exports.default=y;