'use strict';var config={yAxisWidth:15,yAxisSplit:5,xAxisHeight:15,xAxisLineHeight:15,legendHeight:15,yAxisTitleWidth:15,padding:[10,10,10,10],pixelRatio:1,rotate:!1,columePadding:3,fontSize:13,dataPointShape:["circle","circle","circle","circle"],colors:["#1890ff","#2fc25b","#facc14","#f04864","#8543e0","#90ed7d"],pieChartLinePadding:15,pieChartTextPadding:5,xAxisTextPadding:3,titleColor:"#333333",titleFontSize:20,subtitleColor:"#999999",subtitleFontSize:15,toolTipPadding:3,toolTipBackground:"#000000",toolTipOpacity:.7,toolTipLineHeight:20,radarLabelTextMargin:15,gaugeLabelTextMargin:15};let assign=function(e,...t){function i(e,t){for(let a in t)e[a]=e[a]&&"[object Object]"===e[a].toString()?i(e[a],t[a]):e[a]=t[a];return e}if(null==e)throw new TypeError("Cannot convert undefined or null to object");return!t||0>=t.length?e:(t.forEach(t=>{e=i(e,t)}),e)};var util={toFixed:function(e,t){return t=t||2,this.isFloat(e)&&(e=e.toFixed(t)),e},isFloat:function(e){return 0!=e%1},approximatelyEqual:function(e,t){return 1e-10>Math.abs(e-t)},isSameSign:function(e,t){var i=Math.abs;return i(e)===e&&i(t)===t||i(e)!==e&&i(t)!==t},isSameXCoordinateArea:function(e,t){return this.isSameSign(e.x,t.x)},isCollision:function(e,t){e.end={},e.end.x=e.start.x+e.width,e.end.y=e.start.y-e.height,t.end={},t.end.x=t.start.x+t.width,t.end.y=t.start.y-t.height;var i=t.start.x>e.end.x||t.end.xe.start.y||t.start.yi;)i*=10,a*=10;for(e="upper"===t?Math.ceil(e*a):Math.floor(e*a);0!=e%i;)"upper"===t?e++:e--;return e/a}function calCandleMA(e,t,i,a){let o=[];for(let n,l=0;l=l-n&&(r=n-l,e.event.trigger("scrollRight")),r}function isInAngleRange(e,t,i){function a(e){for(;0>e;)e+=2*o;for(;e>2*o;)e-=2*o;return e}var o=Math.PI;return e=a(e),t=a(t),i=a(i),t>i&&(i+=2*o,e=t&&e<=i}function calRotateTranslate(e,t,i){var a=e,o=i-t,n=a+(i-o-a)/1.4142135623730951;n*=-1;return{transX:n,transY:(i-o)*(1.4142135623730951-1)-(i-o-a)/1.4142135623730951}}function createCurveControlPoints(e,t){function i(e,t){return!!(e[t-1]&&e[t+1])&&(e[t].y>=n(e[t-1].y,e[t+1].y)||e[t].y<=o(e[t-1].y,e[t+1].y))}var o=Math.min,n=Math.max,l=.2,a=.2,r=null,s=null,d=null,h=null;if(1>t?(r=e[0].x+(e[1].x-e[0].x)*l,s=e[0].y+(e[1].y-e[0].y)*l):(r=e[t].x+(e[t+1].x-e[t-1].x)*l,s=e[t].y+(e[t+1].y-e[t-1].y)*l),t>e.length-3){var x=e.length-1;d=e[x].x-(e[x].x-e[x-1].x)*a,h=e[x].y-(e[x].y-e[x-1].y)*a}else d=e[t+1].x-(e[t+2].x-e[t].x)*a,h=e[t+1].y-(e[t+2].y-e[t].y)*a;return i(e,t+1)&&(h=e[t+1].y),i(e,t)&&(s=e[t].y),(s>=n(e[t].y,e[t+1].y)||s<=o(e[t].y,e[t+1].y))&&(s=e[t].y),(h>=n(e[t].y,e[t+1].y)||h<=o(e[t].y,e[t+1].y))&&(h=e[t+1].y),{ctrA:{x:r,y:s},ctrB:{x:d,y:h}}}function convertCoordinateOrigin(e,t,i){return{x:i.x+e,y:i.y-t}}function avoidCollision(e,t){if(t)for(;util.isCollision(e,t);)0e.start.x?e.start.y++:0t.data[1]-t.data[0]?s[1]=r:(t.data[0]e[o-1][1]&&(s[2]=l),t.data[3]t&&(n=i)}),n}function findLegendIndex(e,t){let i=-1;if(isInExactLegendArea(e,t.area)){let a=t.points,o=-1;for(let t,n=0,l=a.length;nn[0]&&e.xn[1]&&e.yt.start.x&&e.xt.start.y&&e.y=t.area[3]-10&&e.y>=t.area[0]&&e.y<=t.height-t.area[2]}function findRadarChartCurrentIndex(e,t,i){var a=Math.PI,o=2*a/i,n=-1;if(isInExactPieChartArea(e,t.center,t.radius)){var l=function(e){return 0>e&&(e+=2*a),e>2*a&&(e-=2*a),e},r=Math.atan2(t.center.y-e.y,e.x-t.center.x);r=-1*r,0>r&&(r+=2*a);var s=t.angleList.map(function(e){return e=l(-1*e),e});s.forEach(function(e,t){var i=l(e-o/2),s=l(e+o/2);s=i&&r<=s||r+2*a>=i&&r+2*a<=s)&&(n=t)})}return n}function findFunnelChartCurrentIndex(e,t){for(var a,o=-1,n=0,l=t.series.length;na.funnelArea[0]&&e.xa.funnelArea[1]&&e.ya.area[0]&&e.xa.area[1]&&e.yt.width-t.padding[1]-t.padding[3]?(a.push(g),p.push(n-t.legend.itemGap),n=l,g=[i]):(n+=l,g.push(i))}if(g.length){a.push(g),p.push(n-t.legend.itemGap),l.widthArr=p;let e=o.apply(null,p);switch(t.legend.float){case"left":l.area.start.x=t.padding[3],l.area.end.x=t.padding[3]+2*r;break;case"right":l.area.start.x=t.width-t.padding[1]-e-2*r,l.area.end.x=t.width-t.padding[1];break;default:l.area.start.x=(t.width-e)/2-r,l.area.end.x=(t.width+e)/2+r;}l.area.width=e+2*r,l.area.wholeWidth=e+2*r,l.area.height=a.length*c+2*r,l.area.wholeHeight=a.length*c+2*r+2*s,l.points=a}}else{let i=e.length,a=t.height-t.padding[0]-t.padding[2]-2*s-2*r,o=Math.min(n(a/c),i);switch(l.area.height=o*c+2*r,l.area.wholeHeight=o*c+2*r,t.legend.float){case"top":l.area.start.y=t.padding[0]+s,l.area.end.y=t.padding[0]+s+l.area.height;break;case"bottom":l.area.start.y=t.height-t.padding[2]-s-l.area.height,l.area.end.y=t.height-t.padding[2]-s;break;default:l.area.start.y=(t.height-l.area.height)/2,l.area.end.y=(t.height+l.area.height)/2;}let p=0==i%o?i/o:n(i/o+1),g=[];for(let t,a=0;aa&&(a=e);l.widthArr.push(a),l.heightArr.push(i.length*c+2*r)}let e=0;for(let t=0;ta&&(o.angle=45*Math.PI/180,o.xAxisHeight=2*i.xAxisTextPadding+l*Math.sin(o.angle)),o}function getXAxisTextList(e,t){var a=Math.min,o=Math.max,n=4n&&(a.angle=45*Math.PI/180,a.xAxisHeight=2*i.xAxisTextPadding+r*Math.sin(a.angle)),!0===t.xAxis.disabled&&(a.xAxisHeight=0),a}function getRadarDataPoints(e,t,i,a,o){var n=Math.max,l=5=a.oldData?(n._endAngle_-n._oldAngle_)*o+a.oldAngle:n._oldAngle_-(n._oldAngle_-n._endAngle_)*o,2<=n._proportion_&&(n._proportion_%=2)}return e}function getPieTextMaxLength(e){e=getPieDataPoints(e);let t=0;for(let a=0;a=e.width&&(e.width=1),e.x+=(a+.5-i/2)*e.width,e)})}function fixColumeMeterData(e,t,i,a,o,n,l){return e.map(function(e){return null===e?null:(e.width=Math.ceil((t-2*o.columePadding)/2),n.extra.column&&n.extra.column.width&&0<+n.extra.column.width&&(e.width=Math.min(e.width,+n.extra.column.width)),0s.x&&(h-=measureText(a.categories[r]||"")),n.beginPath(),n.setFontSize(o.fontSize),n.setFillStyle(l.labelColor||"#666666"),n.fillText(a.categories[r]||"",h,x+o.fontSize/2),n.closePath(),n.stroke()})}function drawPieText(e,t,a,o,i,n){var l=Math.cos,r=Math.sin,s=Math.min,d=Math.max,h=Math.PI,x=a.pieChartLinePadding,c=[],p=null,g=e.map(function(e){var t=e.format?e.format(+e._proportion_.toFixed(2)):util.toFixed(100*e._proportion_.toFixed(4))+"%";e._rose_proportion_&&(e._proportion_=e._rose_proportion_);var i=2*h-(e._start_+2*h*e._proportion_/2),a=e.color,o=e._radius_;return{arc:i,text:t,color:a,radius:o,textColor:e.textColor,textSize:e.textSize}});for(let h=0;ht?m=d(f,p.start.y):0y&&(y-=u);let S={lineStart:{x:o,y:n},lineEnd:{x:t,y:i},start:{x:y,y:m},width:u,height:a.fontSize,text:e.text,color:e.color,textColor:e.textColor,textSize:e.textSize};p=avoidCollision(S,p),c.push(p)}for(let l=0;le.start.x?s.x+e.width:s.x,x=0>e.start.x?s.x-5:s.x+5;o.quadraticCurveTo(r.x,r.y,d,s.y),o.moveTo(i.x,i.y),o.stroke(),o.closePath(),o.beginPath(),o.moveTo(s.x+e.width,s.y),o.arc(d,s.y,2,0,2*h),o.closePath(),o.fill(),o.beginPath(),o.setFontSize(e.textSize||a.fontSize),o.setFillStyle(e.textColor||"#666666"),o.fillText(e.text,x,s.y+3),o.closePath(),o.stroke(),o.closePath()}}function drawToolTipSplitLine(e,t,i,a){var o=t.extra.tooltip||{};o.gridType=null==o.gridType?"solid":o.gridType,o.dashLength=null==o.dashLength?4:o.dashLength;var n=t.area[0],l=t.height-t.area[2];if("dash"==o.gridType&&a.setLineDash([o.dashLength,o.dashLength]),a.setStrokeStyle(o.gridColor||"#cccccc"),a.setLineWidth(1*t.pixelRatio),a.beginPath(),a.moveTo(e,n),a.lineTo(e,l),a.stroke(),a.setLineDash([]),o.xAxisLabel){let n=t.categories[t.tooltip.index];a.setFontSize(i.fontSize);let r=measureText(n,i.fontSize),s=e-.5*r,d=l;a.beginPath(),a.setFillStyle(hexToRgb(o.labelBgColor||i.toolTipBackground,o.labelBgOpacity||i.toolTipOpacity)),a.setStrokeStyle(o.labelBgColor||i.toolTipBackground),a.setLineWidth(1*t.pixelRatio),a.rect(s-i.toolTipPadding,d,r+2*i.toolTipPadding,i.fontSize+2*i.toolTipPadding),a.closePath(),a.stroke(),a.fill(),a.beginPath(),a.setFontSize(i.fontSize),a.setFillStyle(o.labelFontColor||i.fontColor),a.fillText(n+"",s,d+i.toolTipPadding+i.fontSize),a.closePath(),a.stroke()}}function drawMarkLine(e,t,a){let o=assign({},{type:"solid",dashLength:4,data:[]},e.extra.markLine),n=e.area[3],l=e.width-e.area[1],r=calMarkLineData(o.data,e);for(let s,d=0;di.width&&(h=!0),p+t.y>i.height&&(t.y=i.height-p),o.beginPath(),o.setFillStyle(hexToRgb(l.bgColor||a.toolTipBackground,l.bgOpacity||a.toolTipOpacity)),h?(o.moveTo(t.x,t.y+10*i.pixelRatio),o.lineTo(t.x-d,t.y+10*i.pixelRatio-5*i.pixelRatio),o.lineTo(t.x-d,t.y),o.lineTo(t.x-d-n(c),t.y),o.lineTo(t.x-d-n(c),t.y+p),o.lineTo(t.x-d,t.y+p),o.lineTo(t.x-d,t.y+10*i.pixelRatio+5*i.pixelRatio),o.lineTo(t.x,t.y+10*i.pixelRatio)):(o.moveTo(t.x,t.y+10*i.pixelRatio),o.lineTo(t.x+d,t.y+10*i.pixelRatio-5*i.pixelRatio),o.lineTo(t.x+d,t.y),o.lineTo(t.x+d+n(c),t.y),o.lineTo(t.x+d+n(c),t.y+p),o.lineTo(t.x+d,t.y+p),o.lineTo(t.x+d,t.y+10*i.pixelRatio+5*i.pixelRatio),o.lineTo(t.x,t.y+10*i.pixelRatio)),o.closePath(),o.fill(),e.forEach(function(e,i){if(null!==e.color){o.beginPath(),o.setFillStyle(e.color);var n=t.x+d+2*a.toolTipPadding,l=t.y+(a.toolTipLineHeight-a.fontSize)/2+a.toolTipLineHeight*i+a.toolTipPadding+1;h&&(n=t.x-c-d+2*a.toolTipPadding),o.fillRect(n,l,r,a.fontSize),o.closePath()}}),e.forEach(function(e,i){var n=t.x+d+2*a.toolTipPadding+r+s;h&&(n=t.x-c-d+2*a.toolTipPadding+ +r+s);var x=t.y+(a.toolTipLineHeight-a.fontSize)/2+a.toolTipLineHeight*i+a.toolTipPadding;o.beginPath(),o.setFontSize(a.fontSize),o.setFillStyle(l.fontColor),o.fillText(e.text,n,x+a.fontSize),o.closePath(),o.stroke()}))}function drawYAxisTitle(e,t,i,a){var o=i.xAxisHeight+(t.height-i.xAxisHeight-measureText(e))/2;a.save(),a.beginPath(),a.setFontSize(i.fontSize),a.setFillStyle(t.yAxis.titleFontColor||"#333333"),a.translate(0,t.height),a.rotate(-90*Math.PI/180),a.fillText(e,o,t.padding[3]+.5*i.fontSize),a.closePath(),a.stroke(),a.restore()}function drawColumnDataPoints(e,t,i,a){let o=4h&&oh&&oh&&oh&&op&&(o.moveTo(i.x,i.y),e=1),0p&&i.xx&&tx&&(a.moveTo(e.x,e.y),i=1),0x&&e.xx&&(a.moveTo(e.x,e.y),i=1),0x&&e.xx&&(a.moveTo(t.x,t.y),e=1),0x&&t.xx&&(a.moveTo(t.x,t.y),e=1),0x&&t.xh&&(a.moveTo(o.x,o.y),i=1),0h&&o.xh&&(a.moveTo(t.x,t.y),i=1),0h&&t.xc&&ng&&(a.moveTo(e.x,e.y),i=1),0g&&e.xg&&(a.moveTo(e.x,e.y),i=1),0g&&e.xg&&(a.moveTo(e.x,e.y),t=1),0g&&e.xg&&(a.moveTo(e.x,e.y),t=1),0g&&e.xt._scrollDistance_&&o.fillRect(0,0,l,d),!0==t.enableScroll&&o.fillRect(r,0,t.width,d),o.closePath(),o.stroke();var h=[];for(let l=0;l<=t.yAxis.splitNumber;l++)h.push(t.area[0]+n*l);let x=t.area[3],c=t.width-t.area[1];for(let n,l=0;le/f?o.setStrokeStyle(hexToRgb(t[0].color,1)):o.setStrokeStyle(hexToRgb(t[0].color,.3)),o.setLineWidth(3*a.pixelRatio),o.moveTo(g,0),o.lineTo(y,0),o.stroke(),o.rotate(p*n);o.restore(),t=getArcbarDataPoints(t,r,l),o.setLineWidth(r.width),o.setStrokeStyle(t[0].color),o.setLineCap("round"),o.beginPath(),o.arc(s.x,s.y,h,r.startAngle*n,t[0]._proportion_*n,!1),o.stroke();let m=d-2.5*r.width;o.save(),o.translate(s.x,s.y),o.rotate((t[0]._proportion_-1)*n),o.beginPath(),o.setLineWidth(r.width/3);let S=o.createLinearGradient(0,.6*-m,0,.6*m);S.addColorStop("0",hexToRgb("#FFFFFF",0)),S.addColorStop("0.5",hexToRgb(t[0].color,1)),S.addColorStop("1.0",hexToRgb("#FFFFFF",0)),o.setStrokeStyle(S),o.arc(0,0,m,.85*n,1.15*n,!1),o.stroke(),o.beginPath(),o.setLineWidth(1),o.setStrokeStyle(t[0].color),o.setFillStyle(t[0].color),o.moveTo(-m-r.width/3/2,-4),o.lineTo(-m-r.width/3/2-4,0),o.lineTo(-m-r.width/3/2,4),o.lineTo(-m-r.width/3/2,-4),o.stroke(),o.fill(),o.restore()}else{o.setLineWidth(r.width),o.setLineCap("butt");for(let t,a=0;at[l].area[2]||e[1]>t[l].area[3]||e[2]e[0]||0>e[1]||e[2]>a||e[3]>o){n=!0;break}else n=!1;return n}function getBoundingBox(e){var t,a={};a.xMin=180,a.xMax=0,a.yMin=90,a.yMax=0;for(var o,n=0;nh.x?a.xMax:h.x,a.yMin=a.yMinh.y?a.yMax:h.y}}}return a}function coordinateToPoint(e,t,i,a,o,n){return{x:(t-i.xMin)*a+o,y:(i.yMax-e)*a+n}}function pointToCoordinate(e,t,i,a,o,n){return{x:(t-o)/a+i.xMin,y:i.yMax-(e-n)/a}}function isRayIntersectsSegment(e,t,i){if(t[1]==i[1])return!1;if(t[1]>e[1]&&i[1]>e[1])return!1;if(t[1]e[1])return!1;if(i[1]==e[1]&&t[1]>e[1])return!1;if(t[0](e/=.5)?.5*t(e,3):.5*(t(e-2,3)+2)},linear:function(e){return e}};function Animation(e){this.isStop=!1,e.duration="undefined"==typeof e.duration?1e3:e.duration,e.timing=e.timing||"linear";var t=function(){return"undefined"==typeof setTimeout?"undefined"==typeof requestAnimationFrame?function(e){e(null)}:requestAnimationFrame:function(e,t){setTimeout(function(){var t=+new Date;e(t)},t)}}(),i=null,a=function(o){if(null===o||!0===this.isStop)return e.onProcess&&e.onProcess(1),void(e.onAnimationFinish&&e.onAnimationFinish());if(null===i&&(i=o),o-io;o++)t.area[o]=t.padding[o];var d=calLegendData(s,t,a,t.chartData),h=d.area.wholeHeight,x=d.area.wholeWidth;switch(t.legend.position){case"top":t.area[0]+=h;break;case"bottom":t.area[2]+=h;break;case"left":t.area[3]+=x;break;case"right":t.area[1]+=x;}let c={},p=0;if("line"===t.type||"column"===t.type||"area"===t.type||"mix"===t.type||"candle"===t.type){if(c=calYAxisData(n,t,a),p=c.yAxisWidth,t.yAxis.showTitle){let e=0;for(let o=0;ot;t++)e.padding[t]*=e.pixelRatio;t.yAxisWidth=config.yAxisWidth*e.pixelRatio,t.xAxisHeight=config.xAxisHeight*e.pixelRatio,e.enableScroll&&e.xAxis.scrollShow&&(t.xAxisHeight+=6*e.pixelRatio),t.xAxisLineHeight=config.xAxisLineHeight*e.pixelRatio,t.fontSize=e.fontSize,t.titleFontSize=config.titleFontSize*e.pixelRatio,t.subtitleFontSize=config.subtitleFontSize*e.pixelRatio,t.toolTipPadding=config.toolTipPadding*e.pixelRatio,t.toolTipLineHeight=config.toolTipLineHeight*e.pixelRatio,t.columePadding=config.columePadding*e.pixelRatio,e.$this=e.$this?e.$this:this,this.context=uni.createCanvasContext(e.canvasId,e.$this),e.chartData={},this.event=new Event,this.scrollOption={currentOffset:0,startTouchX:0,distance:0,lastMoveTime:0},this.opts=e,this.config=t,drawCharts.call(this,e.type,e,t,this.context)};Charts.prototype.updateData=function(){let e=0