UniEcCanvas.js 6.5 KB

1234567891011
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/UniEcCanvas"],{429:function(t,e,n){"use strict";n.r(e);var r=n(430),i=n(432);for(var a in i)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(a);n(435);var c,s=n(40),o=Object(s["default"])(i["default"],r["render"],r["staticRenderFns"],!1,null,null,null,!1,r["components"],c);o.options.__file="components/UniEcCanvas.vue",e["default"]=o.exports},430:function(t,e,n){"use strict";n.r(e);var r=n(431);n.d(e,"render",(function(){return r["render"]})),n.d(e,"staticRenderFns",(function(){return r["staticRenderFns"]})),n.d(e,"recyclableRender",(function(){return r["recyclableRender"]})),n.d(e,"components",(function(){return r["components"]}))},431:function(t,e,n){"use strict";var r;n.r(e),n.d(e,"render",(function(){return i})),n.d(e,"staticRenderFns",(function(){return c})),n.d(e,"recyclableRender",(function(){return a})),n.d(e,"components",(function(){return r}));var i=function(){var t=this,e=t.$createElement;t._self._c},a=!1,c=[];i._withStripped=!0},432:function(t,e,n){"use strict";n.r(e);var r=n(433),i=n.n(r);for(var a in r)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(a);e["default"]=i.a},433:function(t,e,n){"use strict";(function(t){var r=n(4),i=n(13);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a,c=r(n(434)),s=u(n(53));function o(t){if("function"!==typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(o=function(t){return t?n:e})(t)}function u(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==i(t)&&"function"!==typeof t)return{default:t};var n=o(e);if(n&&n.has(t))return n.get(t);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in t)if("default"!==c&&Object.prototype.hasOwnProperty.call(t,c)){var s=a?Object.getOwnPropertyDescriptor(t,c):null;s&&(s.get||s.set)?Object.defineProperty(r,c,s):r[c]=t[c]}return r.default=t,n&&n.set(t,r),r}function h(t){for(var e=0;e<t.touches.length;++e){var n=t.touches[e];n.offsetX=n.x,n.offsetY=n.y}return t}var f={props:{canvasId:{type:String,default:function(){return"ec-canvas"}},ec:{type:Object},forceUseOldCanvas:{type:Boolean,value:!1}},data:function(){return{$curChart:{},toHandleList:[],isUseNewCanvas:!0}},watch:{"ec.option":{deep:!0,handler:function(t,e){this.setOption(t)}}},onReady:function(){this.ec?this.ec.lazyLoad||this.init():console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>')},methods:{compareVersion:function(t,e){t=t.split("."),e=e.split(".");var n=Math.max(t.length,e.length);while(t.length<n)t.push("0");while(e.length<n)e.push("0");for(var r=0;r<n;r++){var i=parseInt(t[r]),a=parseInt(e[r]);if(i>a)return 1;if(i<a)return-1}return 0},init:function(e){var n=t.getSystemInfoSync().SDKVersion,r=this.compareVersion(n,"2.9.0")>=0;if(this.forceUseOldCanvas&&(r&&console.warn("开发者强制使用旧canvas,建议关闭"),r=!1),this.isUseNewCanvas=r&&!this.forceUseOldCanvas,this.isUseNewCanvas)console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>'),this.initByNewWay(e);else{var i=this.compareVersion(n,"1.9.91")>=0;if(!i)return void console.error("微信基础库版本过低,需大于等于 1.9.91。参见:https://github.com/ecomfe/echarts-for-weixin#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82");console.warn("建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能"),this.initByOldWay(e)}},initByOldWay:function(e){a=t.createCanvasContext(this.canvasId,this);var n=new c.default(a,this.canvasId,!1),r=this;s.setCanvasCreator((function(){return n}));var i=1,o=t.createSelectorQuery().in(this);o.select(".ec-canvas").boundingClientRect((function(t){"function"===typeof e?r.$curChart=e(n,t.width,t.height,i):r.ec?r.initChart(n,t.width,t.height,i):r.triggerEvent("init",{canvas:n,width:t.width,height:t.height,devicePixelRatio:i})})).exec()},initByNewWay:function(e){var n=this,r=t.createSelectorQuery().in(this);r.select(".ec-canvas").fields({node:!0,size:!0}).exec((function(r){var i=r[0].node,a=t.getSystemInfoSync().pixelRatio,o=r[0].width,u=r[0].height,h=i.getContext("2d"),f=new c.default(h,n.canvasId,!0,i);s.setCanvasCreator((function(){return f})),"function"===typeof e?n.$curChart=e(f,o,u,a):n.ec?n.initChart(f,o,u,a):n.triggerEvent("init",{canvas:f,width:o,height:u,devicePixelRatio:a})}))},setOption:function(t){this.$curChart&&this.$curChart.setOption?this.$curChart.setOption(t):this.toHandleList.push(t)},canvasToTempFilePath:function(e){var n=this;if(this.isUseNewCanvas){var r=t.createSelectorQuery().in(this);r.select(".ec-canvas").fields({node:!0,size:!0}).exec((function(n){var r=n[0].node;e.canvas=r,t.canvasToTempFilePath(e)}))}else e.canvasId||(e.canvasId=this.canvasId),a.draw(!0,(function(){t.canvasToTempFilePath(e,n)}))},touchStart:function(t){if(this.ec.stopTouchEvent)return t.preventDefault(),void t.stopPropagation();if(this.$emit("touchstart",t),this.$curChart&&t.touches.length>0){var e=t.touches[0],n=this.$curChart.getZr().handler;n&&(n.dispatch("mousedown",{zrX:e.x,zrY:e.y}),n.dispatch("mousemove",{zrX:e.x,zrY:e.y}),n.processGesture(h(t),"start"))}},touchMove:function(t){if(this.ec.stopTouchEvent)return t.preventDefault(),void t.stopPropagation();if(this.$emit("touchmove",t),this.$curChart&&t.touches.length>0){var e=t.touches[0],n=this.$curChart.getZr().handler;n&&(n.dispatch("mousemove",{zrX:e.x,zrY:e.y}),n.processGesture(h(t),"change"))}},touchEnd:function(t){if(this.ec.stopTouchEvent)return t.preventDefault(),void t.stopPropagation();if(this.$emit("touchend",t),this.$curChart){var e=t.changedTouches?t.changedTouches[0]:{},n=this.$curChart.getZr().handler;n&&(n.dispatch("mouseup",{zrX:e.x,zrY:e.y}),n.dispatch("click",{zrX:e.x,zrY:e.y}),n.processGesture(h(t),"end"))}},initChart:function(t,e,n,r){this.$curChart=s.init(t,null,{width:e,height:n,devicePixelRatio:r}),t.setChart(this.$curChart),this.$curChart.setOption(this.ec.option)}}};e.default=f}).call(this,n(1)["default"])},435:function(t,e,n){"use strict";n.r(e);var r=n(436),i=n.n(r);for(var a in r)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(a);e["default"]=i.a},436:function(t,e,n){}}]);
  2. //# sourceMappingURL=../../.sourcemap/mp-weixin/components/UniEcCanvas.js.map
  3. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  4. 'components/UniEcCanvas-create-component',
  5. {
  6. 'components/UniEcCanvas-create-component':(function(module, exports, __webpack_require__){
  7. __webpack_require__('2')['createComponent'](__webpack_require__(429))
  8. })
  9. },
  10. [['components/UniEcCanvas-create-component']]
  11. ]);