33 * uni-app平台高性能跨全端图表,支持H5、APP、小程序(微信/支付宝/百度/头条/QQ/360)
44 * Copyright (c) 2019 QIUN秋云 https://www.ucharts.cn All rights reserved.
55 * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
6- *
6+ *
77 * uCharts官方网站
88 * https://www.uCharts.cn
9- *
9+ *
1010 * 开源地址:
1111 * https://gitee.com/uCharts/uCharts
12- *
12+ *
1313 * uni-app插件市场地址:
1414 * http://ext.dcloud.net.cn/plugin?id=271
15- *
15+ *
1616 */
1717
1818'use strict' ;
@@ -1046,11 +1046,11 @@ function getRoseDataPoints(series, type, minRadius, radius) {
10461046 count += item . data ;
10471047 dataArr . push ( item . data ) ;
10481048 }
1049-
1049+
10501050 var minData = Math . min . apply ( null , dataArr ) ;
10511051 var maxData = Math . max . apply ( null , dataArr ) ;
10521052 var radiusLength = radius - minRadius ;
1053-
1053+
10541054 for ( let i = 0 ; i < series . length ; i ++ ) {
10551055 let item = series [ i ] ;
10561056 item . data = item . data === null ? 0 : item . data ;
@@ -1347,7 +1347,7 @@ function getYAxisTextList(series, opts, config, stack) {
13471347 data = data . filter ( function ( item ) {
13481348 //return item !== null;
13491349 if ( typeof item === 'object' && item !== null ) {
1350- if ( item . constructor == Array ) {
1350+ if ( Array . isArray ( item ) ) {
13511351 return item !== null ;
13521352 } else {
13531353 return item . value !== null ;
@@ -1358,7 +1358,7 @@ function getYAxisTextList(series, opts, config, stack) {
13581358 } ) ;
13591359 data . map ( function ( item ) {
13601360 if ( typeof item === 'object' ) {
1361- if ( item . constructor == Array ) {
1361+ if ( Array . isArray ( item ) ) {
13621362 item . map ( function ( subitem ) {
13631363 sorted . push ( subitem ) ;
13641364 } )
@@ -2791,7 +2791,7 @@ function drawXAxis(categories, opts, config, context) {
27912791 }
27922792 context . setLineDash ( [ ] ) ;
27932793 }
2794-
2794+
27952795
27962796 //不绘制X轴
27972797 if ( opts . xAxis . disabled !== true ) {
@@ -3423,9 +3423,9 @@ function drawRadarDataPoints(series, opts, config, context) {
34233423 labelColor : '#666666' ,
34243424 opacity : 0.2
34253425 } , opts . extra . radar ) ;
3426-
3426+
34273427 var coordinateAngle = getRadarCoordinateSeries ( opts . categories . length ) ;
3428-
3428+
34293429 var centerPosition = {
34303430 x : opts . area [ 3 ] + ( opts . width - opts . area [ 1 ] - opts . area [ 3 ] ) / 2 ,
34313431 y : opts . area [ 0 ] + ( opts . height - opts . area [ 0 ] - opts . area [ 2 ] ) / 2
@@ -3513,7 +3513,7 @@ function normalInt(min, max, iter) {
35133513 for ( var i = 0 ; i < iter ; i ++ ) {
35143514 arr [ i ] = Math . random ( ) ;
35153515 } ;
3516- return Math . floor ( arr . reduce ( function ( i , j ) { return i + j } ) / iter * ( max - min ) ) + min ;
3516+ return Math . floor ( arr . reduce ( function ( i , j ) { return i + j } ) / iter * ( max - min ) ) + min ;
35173517} ;
35183518
35193519function collisionNew ( area , points , width , height ) {
@@ -3553,8 +3553,8 @@ function getBoundingBox(data) {
35533553 var longitude = coords [ j ] [ 0 ] ;
35543554 var latitude = coords [ j ] [ 1 ] ;
35553555 var point = {
3556- x : longitude ,
3557- y : latitude
3556+ x : longitude ,
3557+ y : latitude
35583558 }
35593559 bounds . xMin = bounds . xMin < point . x ? bounds . xMin : point . x ;
35603560 bounds . xMax = bounds . xMax > point . x ? bounds . xMax : point . x ;
@@ -3581,19 +3581,19 @@ function pointToCoordinate(pointY, pointX,bounds,scale,xoffset,yoffset) {
35813581}
35823582
35833583function isRayIntersectsSegment ( poi , s_poi , e_poi ) {
3584- if ( s_poi [ 1 ] == e_poi [ 1 ] ) { return false ; }
3584+ if ( s_poi [ 1 ] == e_poi [ 1 ] ) { return false ; }
35853585 if ( s_poi [ 1 ] > poi [ 1 ] && e_poi [ 1 ] > poi [ 1 ] ) { return false ; }
35863586 if ( s_poi [ 1 ] < poi [ 1 ] && e_poi [ 1 ] < poi [ 1 ] ) { return false ; }
35873587 if ( s_poi [ 1 ] == poi [ 1 ] && e_poi [ 1 ] > poi [ 1 ] ) { return false ; }
35883588 if ( e_poi [ 1 ] == poi [ 1 ] && s_poi [ 1 ] > poi [ 1 ] ) { return false ; }
35893589 if ( s_poi [ 0 ] < poi [ 0 ] && e_poi [ 1 ] < poi [ 1 ] ) { return false ; }
3590- let xseg = e_poi [ 0 ] - ( e_poi [ 0 ] - s_poi [ 0 ] ) * ( e_poi [ 1 ] - poi [ 1 ] ) / ( e_poi [ 1 ] - s_poi [ 1 ] ) ;
3590+ let xseg = e_poi [ 0 ] - ( e_poi [ 0 ] - s_poi [ 0 ] ) * ( e_poi [ 1 ] - poi [ 1 ] ) / ( e_poi [ 1 ] - s_poi [ 1 ] ) ;
35913591 if ( xseg < poi [ 0 ] ) {
35923592 return false ;
35933593 } else {
35943594 return true ;
35953595 }
3596- }
3596+ }
35973597
35983598function isPoiWithinPoly ( poi , poly ) {
35993599 let sinsc = 0 ;
@@ -3610,7 +3610,7 @@ function isPoiWithinPoly(poi,poly){
36103610 }
36113611 }
36123612 }
3613-
3613+
36143614 if ( sinsc % 2 == 1 ) {
36153615 return true ;
36163616 } else {
@@ -3731,11 +3731,11 @@ function getWordCloudPoint(opts,type){
37313731 return true ;
37323732 } else { return false } ;
37333733 } ;
3734- for ( let i = 0 ; i < points . length ; i ++ ) {
3734+ for ( let i = 0 ; i < points . length ; i ++ ) {
37353735 let text = points [ i ] . name ;
37363736 let tHeight = points [ i ] . textSize ;
37373737 let tWidth = measureText ( text , tHeight ) ;
3738- let isSpin = Spin ( ) ;
3738+ let isSpin = Spin ( ) ;
37393739 let x , y , area , areav ;
37403740 let breaknum = 0 ;
37413741 while ( true ) {
@@ -3752,7 +3752,7 @@ function getWordCloudPoint(opts,type){
37523752 y = normalInt ( - opts . height / 2 , opts . height / 2 , 5 ) + tHeight / 2 ;
37533753 area = [ x - 5 + opts . width / 2 , y - 5 - tHeight + opts . height / 2 , x + tWidth + 5 + opts . width / 2 , y + 5 + opts . height / 2 ] ;
37543754 isCollision = collisionNew ( area , points , opts . width , opts . height ) ;
3755- }
3755+ }
37563756 if ( ! isCollision ) break ;
37573757 if ( breaknum == 1000 ) {
37583758 area = [ - 1000 , - 1000 , - 1000 , - 1000 ] ;
@@ -3779,15 +3779,15 @@ function drawWordCloudDataPoints(series, opts, config, context) {
37793779 type : 'normal' ,
37803780 autoColors : true
37813781 } , opts . extra . word ) ;
3782-
3782+
37833783 context . beginPath ( ) ;
37843784 context . setFillStyle ( opts . background || '#FFFFFF' ) ;
37853785 context . rect ( 0 , 0 , opts . width , opts . height ) ;
37863786 context . fill ( ) ;
37873787 context . save ( ) ;
37883788 let points = opts . chartData . wordCloudData ;
37893789 context . translate ( opts . width / 2 , opts . height / 2 ) ;
3790-
3790+
37913791 for ( let i = 0 ; i < points . length ; i ++ ) {
37923792 context . save ( ) ;
37933793 if ( points [ i ] . rotate ) {
@@ -3810,7 +3810,7 @@ function drawWordCloudDataPoints(series, opts, config, context) {
38103810 }
38113811 } else {
38123812 context . fillText ( text , ( points [ i ] . areav [ 0 ] + 5 - opts . width / 2 ) * process - tWidth * ( 1 - process ) / 2 , ( points [ i ] . areav [ 1 ] + 5 + tHeight - opts . height / 2 ) * process ) ;
3813- }
3813+ }
38143814 }
38153815 } else {
38163816 if ( points [ i ] . area [ 0 ] > 0 ) {
@@ -3823,10 +3823,10 @@ function drawWordCloudDataPoints(series, opts, config, context) {
38233823 } else {
38243824 context . fillText ( text , ( points [ i ] . area [ 0 ] + 5 - opts . width / 2 ) * process - tWidth * ( 1 - process ) / 2 , ( points [ i ] . area [ 1 ] + 5 + tHeight - opts . height / 2 ) * process ) ;
38253825 }
3826-
3826+
38273827 }
38283828 }
3829-
3829+
38303830 context . stroke ( ) ;
38313831 context . restore ( ) ;
38323832 }
@@ -3920,11 +3920,11 @@ function drawFunnelDataPoints(series, opts, config, context) {
39203920 context . translate ( 0 , - eachSpacing )
39213921 }
39223922 context . restore ( ) ;
3923-
3923+
39243924 if ( opts . dataLabel !== false && process === 1 ) {
39253925 drawFunnelText ( series , opts , context , eachSpacing , funnelOption . labelAlign , activeWidth , centerPosition ) ;
39263926 }
3927-
3927+
39283928 return {
39293929 center : centerPosition ,
39303930 radius : radius ,
@@ -3996,7 +3996,7 @@ function drawFunnelText(series, opts, context, eachSpacing, labelAlign,activeWid
39963996 context . stroke ( ) ;
39973997 context . closePath ( ) ;
39983998 }
3999-
3999+
40004000 }
40014001}
40024002
@@ -4603,7 +4603,7 @@ var Charts = function Charts(opts) {
46034603 config$$1 . toolTipLineHeight = config . toolTipLineHeight * opts . pixelRatio ;
46044604 config$$1 . columePadding = config . columePadding * opts . pixelRatio ;
46054605 opts . $this = opts . $this ? opts . $this : this ;
4606-
4606+
46074607 this . context = uni . createCanvasContext ( opts . canvasId , opts . $this ) ;
46084608 /* 兼容原生H5
46094609 this.context = document.getElementById(opts.canvasId).getContext("2d");
0 commit comments