bin-charts
Version:
基于echarts的 vue插件,用于配合实现图表组件
7 lines (6 loc) • 3.64 kB
JavaScript
/*!
* bin-charts v3.1.0
* (c) 2021 wangbin
* @license MIT
*/
import{ref as e,onMounted as n,onBeforeUnmount as t,watch as r,openBlock as i,createBlock as o}from"vue";import*as a from"echarts";import s from"resize-observer-polyfill";function u(e,n){return function(e,n,t){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)}t&&!r&&f(),u(),void 0===t&&a>n?f():r=setTimeout(t?c:f,void 0===t?n-a:n)}}(e,n,!1)}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function f(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return c(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);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 l="undefined"==typeof window,d=function(e){for(var n,t=f(e);!(n=t()).done;){var r=n.value.target.__resizeListeners__||[];r.length&&r.forEach((function(e){e()}))}},p={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(i){var o=e(null),c=null,f=null;function p(){c&&(c.dispose(),c=null),c=a.init(o.value),h(i.options)}function _(){c&&c.resize()}function h(e){c&&c.setOption(e)}function v(){c&&c.clear()}return n((function(){var e,n;p(),f=u(_,100),e=o.value,n=f,!l&&e&&(e.__resizeListeners__||(e.__resizeListeners__=[],e.__ro__=new s(d),e.__ro__.observe(e)),e.__resizeListeners__.push(n))})),t((function(){var e,n;e=o.value,n=f,e&&e.__resizeListeners__&&(e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(n),1),e.__resizeListeners__.length||e.__ro__.disconnect()),c&&(c.dispose(),c=null)})),r((function(){return i.options}),(function(e){h(e)}),{deep:!0}),{elRef:o,resize:_,init:p,getInstance:function(){return c},refresh:function(){v(),h(i.options)},clear:v,setOptions:h,dispatchAction:function(e){c&&c.dispatchAction(e)},showLoading:function(e){c&&c.showLoading(e)},hideLoading:function(){c&&c.hideLoading()}}}};p.render=function(e,n,t,r,a,s){return i(),o("div",{class:"bin-charts",ref:"elRef",style:s.wrapStyle},null,4)},p.__file="src/components/charts/charts.vue",p.install=function(e){e.component(p.name,p)};var _={};function h(e){void 0===e&&(e="default");var n="";switch(e){case"primary":n="#0d85ff";break;case"success":n="#52c41a";break;case"warning":n="#fea638";break;case"danger":n="#ff4d4f";break;case"default":n="#35495E";break;default:n=e}return n}_.pretty=function(e,n,t){void 0===t&&(t="primary"),console.log("%c "+e+" %c "+n+" %c","background:"+h(t)+";border:1px solid "+h(t)+"; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;","border:1px solid "+h(t)+"; padding: 1px; border-radius: 0 2px 2px 0; color: "+h(t)+";","background:transparent")};var v="bin-charts",b="3.1.0",m="https://wangbin3162.gitee.io/bin-charts/",g={version:b,install:function(e,n){return void 0===n&&(n={}),e.component(p.name,p),n.disabledDoc||_.pretty("["+v+"] "+b,m),e}};export default g;export{p as Charts};