@10yun/cv-mobile-ui 0.4.11 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/package.json +1 -1
  2. package/plugins/MessageBox.js +2 -2
  3. package/plugins/MessageTip.js +4 -4
  4. package/plugins/request.js +54 -39
  5. package/plugins/storage.js +1 -4
  6. package/plugins/utils.js +13 -0
  7. package/ui-cv/cv-draw-barcode/barcode.js +225 -202
  8. package/ui-cv/cv-draw-barcode/barcodes/Barcode.js +14 -17
  9. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128.js +202 -164
  10. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128A.js +58 -35
  11. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128B.js +58 -36
  12. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128C.js +58 -34
  13. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128_AUTO.js +50 -41
  14. package/ui-cv/cv-draw-barcode/barcodes/CODE128/auto.js +43 -57
  15. package/ui-cv/cv-draw-barcode/barcodes/CODE128/constants.js +71 -30
  16. package/ui-cv/cv-draw-barcode/barcodes/CODE128/index.js +11 -29
  17. package/ui-cv/cv-draw-barcode/barcodes/CODE39/index.js +150 -77
  18. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN.js +122 -90
  19. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN13.js +169 -111
  20. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN2.js +77 -56
  21. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN5.js +84 -60
  22. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN8.js +133 -74
  23. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/UPC.js +174 -156
  24. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/UPCE.js +220 -174
  25. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/constants.js +80 -21
  26. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/encoder.js +18 -24
  27. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/index.js +15 -39
  28. package/ui-cv/cv-draw-barcode/barcodes/GenericBarcode/index.js +80 -55
  29. package/ui-cv/cv-draw-barcode/barcodes/ITF/ITF.js +99 -69
  30. package/ui-cv/cv-draw-barcode/barcodes/ITF/ITF14.js +73 -45
  31. package/ui-cv/cv-draw-barcode/barcodes/ITF/constants.js +8 -8
  32. package/ui-cv/cv-draw-barcode/barcodes/ITF/index.js +6 -18
  33. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI.js +86 -66
  34. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI10.js +40 -33
  35. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI1010.js +41 -35
  36. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI11.js +42 -33
  37. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI1110.js +37 -35
  38. package/ui-cv/cv-draw-barcode/barcodes/MSI/checksums.js +22 -25
  39. package/ui-cv/cv-draw-barcode/barcodes/MSI/index.js +13 -34
  40. package/ui-cv/cv-draw-barcode/barcodes/codabar/index.js +120 -90
  41. package/ui-cv/cv-draw-barcode/barcodes/common.js +0 -0
  42. package/ui-cv/cv-draw-barcode/barcodes/index.js +32 -33
  43. package/ui-cv/cv-draw-barcode/barcodes/index.tmp.js +32 -33
  44. package/ui-cv/cv-draw-barcode/barcodes/pharmacode/index.js +93 -71
  45. package/ui-cv/cv-draw-barcode/cv-draw-barcode.vue +4 -4
  46. package/ui-cv/cv-icons/icons/default-icons.js +132 -0
  47. package/ui-cv/cv-icons/icons/icons-action.js +72 -0
  48. package/ui-cv/cv-icons/icons/icons-arrow.js +46 -0
  49. package/ui-cv/cv-icons/icons/icons-base.js +89 -0
  50. package/ui-cv/cv-icons/icons/icons-mall.js +34 -0
  51. package/ui-cv/cv-icons/icons/icons-media.js +44 -0
  52. package/ui-cv/cv-icons/icons/icons-order.js +33 -0
  53. package/ui-cv/cv-icons/icons/icons-people.js +46 -0
  54. package/ui-cv/cv-icons/icons/icons-status.js +32 -0
  55. package/ui-cv/cv-icons/icons/icons-wallet.js +15 -0
  56. package/ui-cv/cv-icons/icons.js +14 -13
  57. package/ui-cv/cv-lists-base/cv-lists-base.vue +0 -2
  58. package/ui-cv/cv-tab-lists/cv-tab-lists.vue +0 -2
  59. package/ui-uni/u-charts/u-charts.js +1093 -744
  60. package/ui-uni/uni-list/uni-refresh.wxs +1 -1
  61. package/ui-uni/uni-swipe-action-item/index.wxs +6 -6
@@ -53,7 +53,7 @@ if (Object.assign) {
53
53
  assign = Object.assign;
54
54
  } else {
55
55
  // 使用polyfill
56
- assign = function(target, varArgs) {
56
+ assign = function (target, varArgs) {
57
57
  if (target == null) {
58
58
  throw new TypeError('Cannot convert undefined or null to object');
59
59
  }
@@ -69,7 +69,7 @@ if (Object.assign) {
69
69
  }
70
70
  }
71
71
  return to;
72
- }
72
+ };
73
73
  }
74
74
 
75
75
  var util = {
@@ -87,7 +87,7 @@ var util = {
87
87
  return Math.abs(num1 - num2) < 1e-10;
88
88
  },
89
89
  isSameSign: function isSameSign(num1, num2) {
90
- return Math.abs(num1) === num1 && Math.abs(num2) === num2 || Math.abs(num1) !== num1 && Math.abs(num2) !== num2;
90
+ return (Math.abs(num1) === num1 && Math.abs(num2) === num2) || (Math.abs(num1) !== num1 && Math.abs(num2) !== num2);
91
91
  },
92
92
  isSameXCoordinateArea: function isSameXCoordinateArea(p1, p2) {
93
93
  return this.isSameSign(p1.x, p2.x);
@@ -119,7 +119,7 @@ function getH5Offset(e) {
119
119
  // hex 转 rgba
120
120
  function hexToRgb(hexValue, opc) {
121
121
  var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
122
- var hex = hexValue.replace(rgx, function(m, r, g, b) {
122
+ var hex = hexValue.replace(rgx, function (m, r, g, b) {
123
123
  return r + r + g + g + b + b;
124
124
  });
125
125
  var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
@@ -181,7 +181,7 @@ function calCandleMA(dayArr, nameArr, colorArr, kdata) {
181
181
 
182
182
  function calValidDistance(distance, chartData, config, opts) {
183
183
  var dataChartAreaWidth = opts.width - opts.area[1] - opts.area[3];
184
- var dataChartWidth = chartData.eachSpacing * (opts.chartData.xAxisData.xAxisPoints.length-1);
184
+ var dataChartWidth = chartData.eachSpacing * (opts.chartData.xAxisData.xAxisPoints.length - 1);
185
185
  var validDistance = distance;
186
186
  if (distance >= 0) {
187
187
  validDistance = 0;
@@ -226,12 +226,11 @@ function calRotateTranslate(x, y, h) {
226
226
  }
227
227
 
228
228
  function createCurveControlPoints(points, i) {
229
-
230
229
  function isNotMiddlePoint(points, i) {
231
230
  if (points[i - 1] && points[i + 1]) {
232
- return points[i].y >= Math.max(points[i - 1].y, points[i + 1].y) || points[i].y <= Math.min(points[i - 1].y,
233
- points[
234
- i + 1].y);
231
+ return (
232
+ points[i].y >= Math.max(points[i - 1].y, points[i + 1].y) || points[i].y <= Math.min(points[i - 1].y, points[i + 1].y)
233
+ );
235
234
  } else {
236
235
  return false;
237
236
  }
@@ -305,7 +304,7 @@ function avoidCollision(obj, target) {
305
304
 
306
305
  function fillSeries(series, opts, config) {
307
306
  var index = 0;
308
- return series.map(function(item) {
307
+ return series.map(function (item) {
309
308
  if (!item.color) {
310
309
  item.color = config.colors[index];
311
310
  index = (index + 1) % config.colors.length;
@@ -313,28 +312,28 @@ function fillSeries(series, opts, config) {
313
312
  if (!item.type) {
314
313
  item.type = opts.type;
315
314
  }
316
- if (typeof item.show == "undefined") {
315
+ if (typeof item.show == 'undefined') {
317
316
  item.show = true;
318
317
  }
319
318
  if (!item.type) {
320
319
  item.type = opts.type;
321
320
  }
322
321
  if (!item.pointShape) {
323
- item.pointShape = "circle";
322
+ item.pointShape = 'circle';
324
323
  }
325
324
  if (!item.legendShape) {
326
325
  switch (item.type) {
327
326
  case 'line':
328
- item.legendShape = "line";
327
+ item.legendShape = 'line';
329
328
  break;
330
329
  case 'column':
331
- item.legendShape = "rect";
330
+ item.legendShape = 'rect';
332
331
  break;
333
332
  case 'area':
334
- item.legendShape = "triangle";
333
+ item.legendShape = 'triangle';
335
334
  break;
336
335
  default:
337
- item.legendShape = "circle";
336
+ item.legendShape = 'circle';
338
337
  }
339
338
  }
340
339
  return item;
@@ -400,11 +399,11 @@ function measureText(text) {
400
399
  width += 10;
401
400
  }
402
401
  }
403
- return width * fontSize / 10;
402
+ return (width * fontSize) / 10;
404
403
  }
405
404
 
406
405
  function dataCombine(series) {
407
- return series.reduce(function(a, b) {
406
+ return series.reduce(function (a, b) {
408
407
  return (a.data ? a.data : a).concat(b.data);
409
408
  }, []);
410
409
  }
@@ -419,7 +418,7 @@ function dataCombineStack(series, len) {
419
418
  sum[j] += series[i].data[j];
420
419
  }
421
420
  }
422
- return series.reduce(function(a, b) {
421
+ return series.reduce(function (a, b) {
423
422
  return (a.data ? a.data : a).concat(b.data).concat(sum);
424
423
  }, []);
425
424
  }
@@ -429,11 +428,13 @@ function getTouches(touches, opts, e) {
429
428
  if (touches.clientX) {
430
429
  if (opts.rotate) {
431
430
  y = opts.height - touches.clientX * opts.pixelRatio;
432
- x = (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) *
431
+ x =
432
+ (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) *
433
433
  opts.pixelRatio;
434
434
  } else {
435
435
  x = touches.clientX * opts.pixelRatio;
436
- y = (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) *
436
+ y =
437
+ (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) *
437
438
  opts.pixelRatio;
438
439
  }
439
440
  } else {
@@ -448,7 +449,7 @@ function getTouches(touches, opts, e) {
448
449
  return {
449
450
  x: x,
450
451
  y: y
451
- }
452
+ };
452
453
  }
453
454
 
454
455
  function getSeriesDataItem(series, index) {
@@ -472,20 +473,20 @@ function getSeriesDataItem(series, index) {
472
473
  }
473
474
 
474
475
  function getMaxTextListLength(list) {
475
- var lengthList = list.map(function(item) {
476
+ var lengthList = list.map(function (item) {
476
477
  return measureText(item);
477
478
  });
478
479
  return Math.max.apply(null, lengthList);
479
480
  }
480
481
 
481
482
  function getRadarCoordinateSeries(length) {
482
- var eachAngle = 2 * Math.PI / length;
483
+ var eachAngle = (2 * Math.PI) / length;
483
484
  var CoordinateSeries = [];
484
485
  for (var i = 0; i < length; i++) {
485
486
  CoordinateSeries.push(eachAngle * i);
486
487
  }
487
488
 
488
- return CoordinateSeries.map(function(item) {
489
+ return CoordinateSeries.map(function (item) {
489
490
  return -1 * item + Math.PI / 2;
490
491
  });
491
492
  }
@@ -493,7 +494,7 @@ function getRadarCoordinateSeries(length) {
493
494
  function getToolTipData(seriesData, calPoints, index, categories) {
494
495
  var option = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
495
496
 
496
- var textList = seriesData.map(function(item) {
497
+ var textList = seriesData.map(function (item) {
497
498
  return {
498
499
  text: option.format ? option.format(item, categories[index]) : item.name + ': ' + item.data,
499
500
  color: item.color
@@ -524,14 +525,14 @@ function getToolTipData(seriesData, calPoints, index, categories) {
524
525
 
525
526
  function getMixToolTipData(seriesData, calPoints, index, categories) {
526
527
  var option = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
527
- var textList = seriesData.map(function(item) {
528
+ var textList = seriesData.map(function (item) {
528
529
  return {
529
530
  text: option.format ? option.format(item, categories[index]) : item.name + ': ' + item.data,
530
531
  color: item.color,
531
532
  disableLegend: item.disableLegend ? true : false
532
533
  };
533
534
  });
534
- textList = textList.filter(function(item) {
535
+ textList = textList.filter(function (item) {
535
536
  if (item.disableLegend !== true) {
536
537
  return item;
537
538
  }
@@ -571,7 +572,7 @@ function getCandleToolTipData(series, seriesData, calPoints, index, categories,
571
572
  color: null
572
573
  };
573
574
  textList.push(text0);
574
- seriesData.map(function(item) {
575
+ seriesData.map(function (item) {
575
576
  if (index == 0 && item.data[1] - item.data[0] < 0) {
576
577
  color[1] = downColor;
577
578
  } else {
@@ -628,7 +629,7 @@ function filterSeries(series) {
628
629
  let tempSeries = [];
629
630
  for (let i = 0; i < series.length; i++) {
630
631
  if (series[i].show == true) {
631
- tempSeries.push(series[i])
632
+ tempSeries.push(series[i]);
632
633
  }
633
634
  }
634
635
  return tempSeries;
@@ -638,11 +639,11 @@ function findCurrentIndex(currentPoints, xAxisPoints, opts, config) {
638
639
  var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
639
640
  var currentIndex = -1;
640
641
  var spacing = 0;
641
- if((opts.type=='line' || opts.type=='area') && opts.xAxis.boundaryGap=='justify'){
642
- spacing = opts.chartData.eachSpacing/2;
642
+ if ((opts.type == 'line' || opts.type == 'area') && opts.xAxis.boundaryGap == 'justify') {
643
+ spacing = opts.chartData.eachSpacing / 2;
643
644
  }
644
645
  if (isInExactChartArea(currentPoints, opts, config)) {
645
- xAxisPoints.forEach(function(item, index) {
646
+ xAxisPoints.forEach(function (item, index) {
646
647
  if (currentPoints.x + offset + spacing > item) {
647
648
  currentIndex = index;
648
649
  }
@@ -673,16 +674,25 @@ function findLegendIndex(currentPoints, legendData, opts) {
673
674
  }
674
675
 
675
676
  function isInExactLegendArea(currentPoints, area) {
676
- return currentPoints.x > area.start.x && currentPoints.x < area.end.x && currentPoints.y > area.start.y &&
677
- currentPoints.y < area.end.y;
677
+ return (
678
+ currentPoints.x > area.start.x &&
679
+ currentPoints.x < area.end.x &&
680
+ currentPoints.y > area.start.y &&
681
+ currentPoints.y < area.end.y
682
+ );
678
683
  }
679
684
 
680
685
  function isInExactChartArea(currentPoints, opts, config) {
681
- return currentPoints.x < opts.width - opts.area[1] + 10 && currentPoints.x > opts.area[3] -10 && currentPoints.y > opts.area[0] && currentPoints.y < opts.height - opts.area[2];
686
+ return (
687
+ currentPoints.x < opts.width - opts.area[1] + 10 &&
688
+ currentPoints.x > opts.area[3] - 10 &&
689
+ currentPoints.y > opts.area[0] &&
690
+ currentPoints.y < opts.height - opts.area[2]
691
+ );
682
692
  }
683
693
 
684
694
  function findRadarChartCurrentIndex(currentPoints, radarData, count) {
685
- var eachAngleArea = 2 * Math.PI / count;
695
+ var eachAngleArea = (2 * Math.PI) / count;
686
696
  var currentIndex = -1;
687
697
  if (isInExactPieChartArea(currentPoints, radarData.center, radarData.radius)) {
688
698
  var fixAngle = function fixAngle(angle) {
@@ -701,20 +711,19 @@ function findRadarChartCurrentIndex(currentPoints, radarData, count) {
701
711
  angle += 2 * Math.PI;
702
712
  }
703
713
 
704
- var angleList = radarData.angleList.map(function(item) {
714
+ var angleList = radarData.angleList.map(function (item) {
705
715
  item = fixAngle(-1 * item);
706
716
 
707
717
  return item;
708
718
  });
709
719
 
710
- angleList.forEach(function(item, index) {
720
+ angleList.forEach(function (item, index) {
711
721
  var rangeStart = fixAngle(item - eachAngleArea / 2);
712
722
  var rangeEnd = fixAngle(item + eachAngleArea / 2);
713
723
  if (rangeEnd < rangeStart) {
714
724
  rangeEnd += 2 * Math.PI;
715
725
  }
716
- if (angle >= rangeStart && angle <= rangeEnd || angle + 2 * Math.PI >= rangeStart && angle + 2 * Math.PI <=
717
- rangeEnd) {
726
+ if ((angle >= rangeStart && angle <= rangeEnd) || (angle + 2 * Math.PI >= rangeStart && angle + 2 * Math.PI <= rangeEnd)) {
718
727
  currentIndex = index;
719
728
  }
720
729
  });
@@ -727,7 +736,12 @@ function findFunnelChartCurrentIndex(currentPoints, funnelData) {
727
736
  var currentIndex = -1;
728
737
  for (var i = 0, len = funnelData.series.length; i < len; i++) {
729
738
  var item = funnelData.series[i];
730
- if (currentPoints.x > item.funnelArea[0] && currentPoints.x < item.funnelArea[2] && currentPoints.y > item.funnelArea[1] && currentPoints.y < item.funnelArea[3]) {
739
+ if (
740
+ currentPoints.x > item.funnelArea[0] &&
741
+ currentPoints.x < item.funnelArea[2] &&
742
+ currentPoints.y > item.funnelArea[1] &&
743
+ currentPoints.y < item.funnelArea[3]
744
+ ) {
731
745
  currentIndex = i;
732
746
  break;
733
747
  }
@@ -739,7 +753,12 @@ function findWordChartCurrentIndex(currentPoints, wordData) {
739
753
  var currentIndex = -1;
740
754
  for (var i = 0, len = wordData.length; i < len; i++) {
741
755
  var item = wordData[i];
742
- if (currentPoints.x > item.area[0] && currentPoints.x < item.area[2] && currentPoints.y > item.area[1] && currentPoints.y < item.area[3]) {
756
+ if (
757
+ currentPoints.x > item.area[0] &&
758
+ currentPoints.x < item.area[2] &&
759
+ currentPoints.y > item.area[1] &&
760
+ currentPoints.y < item.area[3]
761
+ ) {
743
762
  currentIndex = i;
744
763
  break;
745
764
  }
@@ -749,13 +768,13 @@ function findWordChartCurrentIndex(currentPoints, wordData) {
749
768
 
750
769
  function findMapChartCurrentIndex(currentPoints, opts) {
751
770
  var currentIndex = -1;
752
- var cData=opts.chartData.mapData;
753
- var data=opts.series;
754
- var tmp=pointToCoordinate(currentPoints.y, currentPoints.x,cData.bounds,cData.scale,cData.xoffset,cData.yoffset);
755
- var poi=[tmp.x, tmp.y];
771
+ var cData = opts.chartData.mapData;
772
+ var data = opts.series;
773
+ var tmp = pointToCoordinate(currentPoints.y, currentPoints.x, cData.bounds, cData.scale, cData.xoffset, cData.yoffset);
774
+ var poi = [tmp.x, tmp.y];
756
775
  for (var i = 0, len = data.length; i < len; i++) {
757
776
  var item = data[i].geometry.coordinates;
758
- if(isPoiWithinPoly(poi,item)){
777
+ if (isPoiWithinPoly(poi, item)) {
759
778
  currentIndex = i;
760
779
  break;
761
780
  }
@@ -787,7 +806,7 @@ function isInExactPieChartArea(currentPoints, center, radius) {
787
806
  function splitPoints(points) {
788
807
  var newPoints = [];
789
808
  var items = [];
790
- points.forEach(function(item, index) {
809
+ points.forEach(function (item, index) {
791
810
  if (item !== null) {
792
811
  items.push(item);
793
812
  } else {
@@ -896,7 +915,7 @@ function calLegendData(series, opts, config, chartData) {
896
915
  legendData.area.start.y = (opts.height - legendData.area.height) / 2;
897
916
  legendData.area.end.y = (opts.height + legendData.area.height) / 2;
898
917
  }
899
- let lineNum = len % maxLength === 0 ? len / maxLength : Math.floor((len / maxLength) + 1);
918
+ let lineNum = len % maxLength === 0 ? len / maxLength : Math.floor(len / maxLength + 1);
900
919
  let currentRow = [];
901
920
  for (let i = 0; i < lineNum; i++) {
902
921
  let temp = series.slice(i * maxLength, i * maxLength + maxLength);
@@ -918,7 +937,7 @@ function calLegendData(series, opts, config, chartData) {
918
937
  legendData.widthArr.push(maxWidth);
919
938
  legendData.heightArr.push(item.length * lineHeight + padding * 2);
920
939
  }
921
- let legendWidth = 0
940
+ let legendWidth = 0;
922
941
  for (let i = 0; i < legendData.widthArr.length; i++) {
923
942
  legendWidth += legendData.widthArr[i];
924
943
  }
@@ -954,13 +973,13 @@ function calCategoriesData(categories, opts, config, eachSpacing) {
954
973
  angle: 0,
955
974
  xAxisHeight: config.xAxisHeight
956
975
  };
957
- var categoriesTextLenth = categories.map(function(item) {
976
+ var categoriesTextLenth = categories.map(function (item) {
958
977
  return measureText(item);
959
978
  });
960
979
  var maxTextLength = Math.max.apply(this, categoriesTextLenth);
961
980
 
962
981
  if (opts.xAxis.rotateLabel == true && maxTextLength + 2 * config.xAxisTextPadding > eachSpacing) {
963
- result.angle = 45 * Math.PI / 180;
982
+ result.angle = (45 * Math.PI) / 180;
964
983
  result.xAxisHeight = 2 * config.xAxisTextPadding + maxTextLength * Math.sin(result.angle);
965
984
  }
966
985
  return result;
@@ -979,13 +998,16 @@ function getRadarDataPoints(angleList, center, radius, series, opts) {
979
998
  let listItem = {};
980
999
  listItem.color = each.color;
981
1000
  listItem.data = [];
982
- each.data.forEach(function(item, index) {
1001
+ each.data.forEach(function (item, index) {
983
1002
  let tmp = {};
984
1003
  tmp.angle = angleList[index];
985
1004
 
986
1005
  tmp.proportion = item / maxData;
987
- tmp.position = convertCoordinateOrigin(radius * tmp.proportion * process * Math.cos(tmp.angle), radius * tmp.proportion *
988
- process * Math.sin(tmp.angle), center);
1006
+ tmp.position = convertCoordinateOrigin(
1007
+ radius * tmp.proportion * process * Math.cos(tmp.angle),
1008
+ radius * tmp.proportion * process * Math.sin(tmp.angle),
1009
+ center
1010
+ );
989
1011
  listItem.data.push(tmp);
990
1012
  });
991
1013
 
@@ -1009,9 +1031,9 @@ function getPieDataPoints(series, radius) {
1009
1031
  let item = series[i];
1010
1032
  item.data = item.data === null ? 0 : item.data;
1011
1033
  if (count === 0) {
1012
- item._proportion_ = 1 / series.length * process;
1034
+ item._proportion_ = (1 / series.length) * process;
1013
1035
  } else {
1014
- item._proportion_ = item.data / count * process;
1036
+ item._proportion_ = (item.data / count) * process;
1015
1037
  }
1016
1038
  item._radius_ = radius;
1017
1039
  }
@@ -1026,10 +1048,12 @@ function getPieDataPoints(series, radius) {
1026
1048
 
1027
1049
  function getFunnelDataPoints(series, radius) {
1028
1050
  var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1029
- series = series.sort(function(a,b){return parseInt(b.data)-parseInt(a.data);});
1051
+ series = series.sort(function (a, b) {
1052
+ return parseInt(b.data) - parseInt(a.data);
1053
+ });
1030
1054
  for (let i = 0; i < series.length; i++) {
1031
- series[i].radius = series[i].data/series[0].data*radius*process;
1032
- series[i]._proportion_ = series[i].data/series[0].data;
1055
+ series[i].radius = (series[i].data / series[0].data) * radius * process;
1056
+ series[i]._proportion_ = series[i].data / series[0].data;
1033
1057
  }
1034
1058
  return series.reverse();
1035
1059
  }
@@ -1055,11 +1079,11 @@ function getRoseDataPoints(series, type, minRadius, radius) {
1055
1079
  let item = series[i];
1056
1080
  item.data = item.data === null ? 0 : item.data;
1057
1081
  if (count === 0 || type == 'area') {
1058
- item._proportion_ = item.data / count * process;
1059
- item._rose_proportion_ = 1 / series.length * process;
1082
+ item._proportion_ = (item.data / count) * process;
1083
+ item._rose_proportion_ = (1 / series.length) * process;
1060
1084
  } else {
1061
- item._proportion_ = item.data / count * process;
1062
- item._rose_proportion_ = item.data / count * process;
1085
+ item._proportion_ = (item.data / count) * process;
1086
+ item._rose_proportion_ = (item.data / count) * process;
1063
1087
  }
1064
1088
  item._radius_ = minRadius + radiusLength * ((item.data - minData) / (maxData - minData));
1065
1089
  }
@@ -1084,7 +1108,7 @@ function getArcbarDataPoints(series, arcbarOption) {
1084
1108
  if (arcbarOption.type == 'default') {
1085
1109
  if (arcbarOption.endAngle < arcbarOption.startAngle) {
1086
1110
  totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle;
1087
- } else{
1111
+ } else {
1088
1112
  totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
1089
1113
  }
1090
1114
  } else {
@@ -1159,7 +1183,7 @@ function getPieTextMaxLength(series) {
1159
1183
  }
1160
1184
 
1161
1185
  function fixColumeData(points, eachSpacing, columnLen, index, config, opts) {
1162
- return points.map(function(item) {
1186
+ return points.map(function (item) {
1163
1187
  if (item === null) {
1164
1188
  return null;
1165
1189
  }
@@ -1177,7 +1201,7 @@ function fixColumeData(points, eachSpacing, columnLen, index, config, opts) {
1177
1201
  }
1178
1202
 
1179
1203
  function fixColumeMeterData(points, eachSpacing, columnLen, index, config, opts, border) {
1180
- return points.map(function(item) {
1204
+ return points.map(function (item) {
1181
1205
  if (item === null) {
1182
1206
  return null;
1183
1207
  }
@@ -1195,9 +1219,7 @@ function fixColumeMeterData(points, eachSpacing, columnLen, index, config, opts,
1195
1219
  }
1196
1220
 
1197
1221
  function fixColumeStackData(points, eachSpacing, columnLen, index, config, opts, series) {
1198
-
1199
- return points.map(function(item, indexn) {
1200
-
1222
+ return points.map(function (item, indexn) {
1201
1223
  if (item === null) {
1202
1224
  return null;
1203
1225
  }
@@ -1214,18 +1236,18 @@ function getXAxisPoints(categories, opts, config) {
1214
1236
  var yAxisTotalWidth = config.yAxisWidth + config.yAxisTitleWidth;
1215
1237
  var spacingValid = opts.width - opts.area[1] - opts.area[3];
1216
1238
  var dataCount = opts.enableScroll ? Math.min(opts.xAxis.itemCount, categories.length) : categories.length;
1217
- if((opts.type=='line' || opts.type=='area') && dataCount>1 && opts.xAxis.boundaryGap=='justify'){
1218
- dataCount -=1;
1239
+ if ((opts.type == 'line' || opts.type == 'area') && dataCount > 1 && opts.xAxis.boundaryGap == 'justify') {
1240
+ dataCount -= 1;
1219
1241
  }
1220
1242
  var eachSpacing = spacingValid / dataCount;
1221
1243
 
1222
1244
  var xAxisPoints = [];
1223
1245
  var startX = opts.area[3];
1224
1246
  var endX = opts.width - opts.area[1];
1225
- categories.forEach(function(item, index) {
1247
+ categories.forEach(function (item, index) {
1226
1248
  xAxisPoints.push(startX + index * eachSpacing);
1227
1249
  });
1228
- if(opts.xAxis.boundaryGap !=='justify'){
1250
+ if (opts.xAxis.boundaryGap !== 'justify') {
1229
1251
  if (opts.enableScroll === true) {
1230
1252
  xAxisPoints.push(startX + categories.length * eachSpacing);
1231
1253
  } else {
@@ -1244,16 +1266,16 @@ function getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing,
1244
1266
  var process = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1;
1245
1267
  var points = [];
1246
1268
  var validHeight = opts.height - opts.area[0] - opts.area[2];
1247
- data.forEach(function(item, index) {
1269
+ data.forEach(function (item, index) {
1248
1270
  if (item === null) {
1249
1271
  points.push(null);
1250
1272
  } else {
1251
1273
  var cPoints = [];
1252
- item.forEach(function(items, indexs) {
1274
+ item.forEach(function (items, indexs) {
1253
1275
  var point = {};
1254
1276
  point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
1255
1277
  var value = items.value || items;
1256
- var height = validHeight * (value - minRange) / (maxRange - minRange);
1278
+ var height = (validHeight * (value - minRange)) / (maxRange - minRange);
1257
1279
  height *= process;
1258
1280
  point.y = opts.height - Math.round(height) - opts.area[2];
1259
1281
  cPoints.push(point);
@@ -1267,27 +1289,27 @@ function getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing,
1267
1289
 
1268
1290
  function getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config) {
1269
1291
  var process = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1;
1270
- var boundaryGap='center';
1271
- if (opts.type == 'line'||opts.type == 'area'){
1272
- boundaryGap=opts.xAxis.boundaryGap;
1292
+ var boundaryGap = 'center';
1293
+ if (opts.type == 'line' || opts.type == 'area') {
1294
+ boundaryGap = opts.xAxis.boundaryGap;
1273
1295
  }
1274
1296
  var points = [];
1275
1297
  var validHeight = opts.height - opts.area[0] - opts.area[2];
1276
- data.forEach(function(item, index) {
1298
+ data.forEach(function (item, index) {
1277
1299
  if (item === null) {
1278
1300
  points.push(null);
1279
1301
  } else {
1280
1302
  var point = {};
1281
1303
  point.color = item.color;
1282
1304
  point.x = xAxisPoints[index];
1283
- if(boundaryGap=='center'){
1305
+ if (boundaryGap == 'center') {
1284
1306
  point.x += Math.round(eachSpacing / 2);
1285
1307
  }
1286
1308
  var value = item;
1287
1309
  if (typeof item === 'object' && item !== null) {
1288
- value = item.value
1310
+ value = item.value;
1289
1311
  }
1290
- var height = validHeight * (value - minRange) / (maxRange - minRange);
1312
+ var height = (validHeight * (value - minRange)) / (maxRange - minRange);
1291
1313
  height *= process;
1292
1314
  point.y = opts.height - Math.round(height) - opts.area[2];
1293
1315
  points.push(point);
@@ -1302,7 +1324,7 @@ function getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing,
1302
1324
  var points = [];
1303
1325
  var validHeight = opts.height - opts.area[0] - opts.area[2];
1304
1326
 
1305
- data.forEach(function(item, index) {
1327
+ data.forEach(function (item, index) {
1306
1328
  if (item === null) {
1307
1329
  points.push(null);
1308
1330
  } else {
@@ -1316,11 +1338,11 @@ function getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing,
1316
1338
  value += stackSeries[i].data[index];
1317
1339
  }
1318
1340
  var value0 = value - item;
1319
- var height = validHeight * (value - minRange) / (maxRange - minRange);
1320
- var height0 = validHeight * (value0 - minRange) / (maxRange - minRange);
1341
+ var height = (validHeight * (value - minRange)) / (maxRange - minRange);
1342
+ var height0 = (validHeight * (value0 - minRange)) / (maxRange - minRange);
1321
1343
  } else {
1322
1344
  var value = item;
1323
- var height = validHeight * (value - minRange) / (maxRange - minRange);
1345
+ var height = (validHeight * (value - minRange)) / (maxRange - minRange);
1324
1346
  var height0 = 0;
1325
1347
  }
1326
1348
  var heightc = height0;
@@ -1344,7 +1366,7 @@ function getYAxisTextList(series, opts, config, stack) {
1344
1366
  }
1345
1367
  var sorted = [];
1346
1368
  // remove null from data
1347
- data = data.filter(function(item) {
1369
+ data = data.filter(function (item) {
1348
1370
  //return item !== null;
1349
1371
  if (typeof item === 'object' && item !== null) {
1350
1372
  if (Array.isArray(item)) {
@@ -1356,19 +1378,19 @@ function getYAxisTextList(series, opts, config, stack) {
1356
1378
  return item !== null;
1357
1379
  }
1358
1380
  });
1359
- data.map(function(item) {
1381
+ data.map(function (item) {
1360
1382
  if (typeof item === 'object') {
1361
1383
  if (Array.isArray(item)) {
1362
- item.map(function(subitem) {
1384
+ item.map(function (subitem) {
1363
1385
  sorted.push(subitem);
1364
- })
1386
+ });
1365
1387
  } else {
1366
1388
  sorted.push(item.value);
1367
1389
  }
1368
1390
  } else {
1369
1391
  sorted.push(item);
1370
1392
  }
1371
- })
1393
+ });
1372
1394
  var minData = 0;
1373
1395
  var maxData = 0;
1374
1396
  if (sorted.length > 0) {
@@ -1402,13 +1424,17 @@ function getYAxisTextList(series, opts, config, stack) {
1402
1424
 
1403
1425
  function calYAxisData(series, opts, config) {
1404
1426
  //堆叠图重算Y轴
1405
- var columnstyle = assign({}, {
1406
- type: ""
1407
- }, opts.extra.column);
1427
+ var columnstyle = assign(
1428
+ {},
1429
+ {
1430
+ type: ''
1431
+ },
1432
+ opts.extra.column
1433
+ );
1408
1434
  var ranges = getYAxisTextList(series, opts, config, columnstyle.type);
1409
1435
  var yAxisWidth = config.yAxisWidth;
1410
1436
  var yAxisFontSize = opts.yAxis.fontSize || config.fontSize;
1411
- var rangesFormat = ranges.map(function(item) {
1437
+ var rangesFormat = ranges.map(function (item) {
1412
1438
  item = util.toFixed(item, 6);
1413
1439
  item = opts.yAxis.format ? opts.yAxis.format(Number(item)) : item;
1414
1440
  yAxisWidth = Math.max(yAxisWidth, measureText(item, yAxisFontSize) + 5);
@@ -1432,7 +1458,7 @@ function calTooltipYAxisData(point, series, opts, config, eachSpacing) {
1432
1458
  let minVal = ranges[ranges.length - 1];
1433
1459
  let minAxis = opts.padding[3];
1434
1460
  let maxAxis = opts.padding[1] + spacingValid;
1435
- let item = maxVal - (maxVal - minVal) * (point - minAxis) / (maxAxis - minAxis);
1461
+ let item = maxVal - ((maxVal - minVal) * (point - minAxis)) / (maxAxis - minAxis);
1436
1462
  item = opts.yAxis.format ? opts.yAxis.format(Number(item)) : item;
1437
1463
  return item;
1438
1464
  }
@@ -1440,7 +1466,7 @@ function calTooltipYAxisData(point, series, opts, config, eachSpacing) {
1440
1466
  function calMarkLineData(minRange, maxRange, points, opts) {
1441
1467
  let spacingValid = opts.height - opts.area[0] - opts.area[2];
1442
1468
  for (let i = 0; i < points.length; i++) {
1443
- let height = spacingValid * (points[i].value - minRange) / (maxRange - minRange);
1469
+ let height = (spacingValid * (points[i].value - minRange)) / (maxRange - minRange);
1444
1470
  points[i].y = opts.height - Math.round(height) - opts.area[2];
1445
1471
  }
1446
1472
  return points;
@@ -1449,21 +1475,21 @@ function calMarkLineData(minRange, maxRange, points, opts) {
1449
1475
  function contextRotate(context, opts) {
1450
1476
  if (opts.rotateLock !== true) {
1451
1477
  context.translate(opts.height, 0);
1452
- context.rotate(90 * Math.PI / 180);
1478
+ context.rotate((90 * Math.PI) / 180);
1453
1479
  } else if (opts._rotate_ !== true) {
1454
1480
  context.translate(opts.height, 0);
1455
- context.rotate(90 * Math.PI / 180);
1481
+ context.rotate((90 * Math.PI) / 180);
1456
1482
  opts._rotate_ = true;
1457
1483
  }
1458
1484
  }
1459
1485
 
1460
1486
  function drawPointShape(points, color, shape, context, opts) {
1461
1487
  context.beginPath();
1462
- context.setStrokeStyle("#ffffff");
1488
+ context.setStrokeStyle('#ffffff');
1463
1489
  context.setLineWidth(1 * opts.pixelRatio);
1464
1490
  context.setFillStyle(color);
1465
1491
  if (shape === 'diamond') {
1466
- points.forEach(function(item, index) {
1492
+ points.forEach(function (item, index) {
1467
1493
  if (item !== null) {
1468
1494
  context.moveTo(item.x, item.y - 4.5);
1469
1495
  context.lineTo(item.x - 4.5, item.y);
@@ -1473,21 +1499,21 @@ function drawPointShape(points, color, shape, context, opts) {
1473
1499
  }
1474
1500
  });
1475
1501
  } else if (shape === 'circle') {
1476
- points.forEach(function(item, index) {
1502
+ points.forEach(function (item, index) {
1477
1503
  if (item !== null) {
1478
1504
  context.moveTo(item.x + 3.5 * opts.pixelRatio, item.y);
1479
1505
  context.arc(item.x, item.y, 4 * opts.pixelRatio, 0, 2 * Math.PI, false);
1480
1506
  }
1481
1507
  });
1482
1508
  } else if (shape === 'rect') {
1483
- points.forEach(function(item, index) {
1509
+ points.forEach(function (item, index) {
1484
1510
  if (item !== null) {
1485
1511
  context.moveTo(item.x - 3.5, item.y - 3.5);
1486
1512
  context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
1487
1513
  }
1488
1514
  });
1489
1515
  } else if (shape === 'triangle') {
1490
- points.forEach(function(item, index) {
1516
+ points.forEach(function (item, index) {
1491
1517
  if (item !== null) {
1492
1518
  context.moveTo(item.x, item.y - 4.5);
1493
1519
  context.lineTo(item.x - 4.5, item.y + 4.5);
@@ -1545,24 +1571,22 @@ function drawRingTitle(opts, config, context, center) {
1545
1571
  function drawPointText(points, series, config, context) {
1546
1572
  // 绘制数据文案
1547
1573
  var data = series.data;
1548
- points.forEach(function(item, index) {
1574
+ points.forEach(function (item, index) {
1549
1575
  if (item !== null) {
1550
1576
  //var formatVal = series.format ? series.format(data[index]) : data[index];
1551
1577
  context.beginPath();
1552
1578
  context.setFontSize(series.textSize || config.fontSize);
1553
1579
  context.setFillStyle(series.textColor || '#666666');
1554
- var value = data[index]
1580
+ var value = data[index];
1555
1581
  if (typeof data[index] === 'object' && data[index] !== null) {
1556
- value = data[index].value
1582
+ value = data[index].value;
1557
1583
  }
1558
1584
  var formatVal = series.format ? series.format(value) : value;
1559
- context.fillText(String(formatVal), item.x - measureText(formatVal, series.textSize || config.fontSize) / 2, item.y -
1560
- 2);
1585
+ context.fillText(String(formatVal), item.x - measureText(formatVal, series.textSize || config.fontSize) / 2, item.y - 2);
1561
1586
  context.closePath();
1562
1587
  context.stroke();
1563
1588
  }
1564
1589
  });
1565
-
1566
1590
  }
1567
1591
 
1568
1592
  function drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config, context) {
@@ -1597,14 +1621,13 @@ function drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config, conte
1597
1621
  }
1598
1622
  nowNumber += splitNumber;
1599
1623
  }
1600
-
1601
1624
  }
1602
1625
 
1603
1626
  function drawRadarLabel(angleList, radius, centerPosition, opts, config, context) {
1604
1627
  var radarOption = opts.extra.radar || {};
1605
1628
  radius += config.radarLabelTextMargin;
1606
1629
 
1607
- angleList.forEach(function(angle, index) {
1630
+ angleList.forEach(function (angle, index) {
1608
1631
  var pos = {
1609
1632
  x: radius * Math.cos(angle),
1610
1633
  y: radius * Math.sin(angle)
@@ -1624,7 +1647,6 @@ function drawRadarLabel(angleList, radius, centerPosition, opts, config, context
1624
1647
  context.closePath();
1625
1648
  context.stroke();
1626
1649
  });
1627
-
1628
1650
  }
1629
1651
 
1630
1652
  function drawPieText(series, opts, config, context, radius, center) {
@@ -1632,10 +1654,10 @@ function drawPieText(series, opts, config, context, radius, center) {
1632
1654
  var textObjectCollection = [];
1633
1655
  var lastTextObject = null;
1634
1656
 
1635
- var seriesConvert = series.map(function(item) {
1636
- var text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_.toFixed(4) * 100) +'%';
1637
- if(item._rose_proportion_) item._proportion_=item._rose_proportion_;
1638
- var arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._proportion_ / 2);
1657
+ var seriesConvert = series.map(function (item) {
1658
+ var text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_.toFixed(4) * 100) + '%';
1659
+ if (item._rose_proportion_) item._proportion_ = item._rose_proportion_;
1660
+ var arc = 2 * Math.PI - (item._start_ + (2 * Math.PI * item._proportion_) / 2);
1639
1661
  var color = item.color;
1640
1662
  var radius = item._radius_;
1641
1663
  return {
@@ -1644,7 +1666,7 @@ function drawPieText(series, opts, config, context, radius, center) {
1644
1666
  color: color,
1645
1667
  radius: radius,
1646
1668
  textColor: item.textColor,
1647
- textSize: item.textSize,
1669
+ textSize: item.textSize
1648
1670
  };
1649
1671
  });
1650
1672
  for (let i = 0; i < seriesConvert.length; i++) {
@@ -1663,9 +1685,12 @@ function drawPieText(series, opts, config, context, radius, center) {
1663
1685
  let textWidth = measureText(item.text);
1664
1686
  let startY = orginY3;
1665
1687
 
1666
- if (lastTextObject && util.isSameXCoordinateArea(lastTextObject.start, {
1688
+ if (
1689
+ lastTextObject &&
1690
+ util.isSameXCoordinateArea(lastTextObject.start, {
1667
1691
  x: orginX3
1668
- })) {
1692
+ })
1693
+ ) {
1669
1694
  if (orginX3 > 0) {
1670
1695
  startY = Math.min(orginY3, lastTextObject.start.y);
1671
1696
  } else if (orginX1 < 0) {
@@ -1764,10 +1789,17 @@ function drawToolTipSplitLine(offsetX, opts, config, context) {
1764
1789
  let textX = offsetX - 0.5 * textWidth;
1765
1790
  let textY = endY;
1766
1791
  context.beginPath();
1767
- context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity));
1792
+ context.setFillStyle(
1793
+ hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity)
1794
+ );
1768
1795
  context.setStrokeStyle(toolTipOption.labelBgColor || config.toolTipBackground);
1769
1796
  context.setLineWidth(1 * opts.pixelRatio);
1770
- context.rect(textX - config.toolTipPadding, textY, textWidth + 2 * config.toolTipPadding, config.fontSize + 2 * config.toolTipPadding);
1797
+ context.rect(
1798
+ textX - config.toolTipPadding,
1799
+ textY,
1800
+ textWidth + 2 * config.toolTipPadding,
1801
+ config.fontSize + 2 * config.toolTipPadding
1802
+ );
1771
1803
  context.closePath();
1772
1804
  context.stroke();
1773
1805
  context.fill();
@@ -1782,24 +1814,32 @@ function drawToolTipSplitLine(offsetX, opts, config, context) {
1782
1814
  }
1783
1815
 
1784
1816
  function drawMarkLine(minRange, maxRange, opts, config, context) {
1785
- let markLineOption = assign({}, {
1786
- type: 'solid',
1787
- dashLength: 4,
1788
- data: []
1789
- }, opts.extra.markLine);
1817
+ let markLineOption = assign(
1818
+ {},
1819
+ {
1820
+ type: 'solid',
1821
+ dashLength: 4,
1822
+ data: []
1823
+ },
1824
+ opts.extra.markLine
1825
+ );
1790
1826
  let startX = opts.area[3];
1791
1827
  let endX = opts.width - opts.padding[1];
1792
1828
  let points = calMarkLineData(minRange, maxRange, markLineOption.data, opts);
1793
1829
 
1794
1830
  for (let i = 0; i < points.length; i++) {
1795
- let item = assign({}, {
1796
- lineColor: '#DE4A42',
1797
- showLabel: false,
1798
- labelFontColor: '#666666',
1799
- labelBgColor: '#DFE8FF',
1800
- labelBgOpacity: 0.8,
1801
- yAxisIndex: 0
1802
- }, points[i]);
1831
+ let item = assign(
1832
+ {},
1833
+ {
1834
+ lineColor: '#DE4A42',
1835
+ showLabel: false,
1836
+ labelFontColor: '#666666',
1837
+ labelBgColor: '#DFE8FF',
1838
+ labelBgOpacity: 0.8,
1839
+ yAxisIndex: 0
1840
+ },
1841
+ points[i]
1842
+ );
1803
1843
 
1804
1844
  if (markLineOption.type == 'dash') {
1805
1845
  context.setLineDash([markLineOption.dashLength, markLineOption.dashLength]);
@@ -1825,7 +1865,12 @@ function drawMarkLine(minRange, maxRange, opts, config, context) {
1825
1865
  context.setStrokeStyle(item.labelBgColor);
1826
1866
  context.setLineWidth(1 * opts.pixelRatio);
1827
1867
  context.beginPath();
1828
- context.rect(bgStartX, textY - 0.5 * config.fontSize - config.toolTipPadding, bgWidth, config.fontSize + 2 * config.toolTipPadding);
1868
+ context.rect(
1869
+ bgStartX,
1870
+ textY - 0.5 * config.fontSize - config.toolTipPadding,
1871
+ bgWidth,
1872
+ config.fontSize + 2 * config.toolTipPadding
1873
+ );
1829
1874
  context.closePath();
1830
1875
  context.stroke();
1831
1876
  context.fill();
@@ -1840,10 +1885,14 @@ function drawMarkLine(minRange, maxRange, opts, config, context) {
1840
1885
  }
1841
1886
 
1842
1887
  function drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints) {
1843
- var toolTipOption = assign({}, {
1844
- gridType: 'solid',
1845
- dashLength: 4
1846
- }, opts.extra.tooltip);
1888
+ var toolTipOption = assign(
1889
+ {},
1890
+ {
1891
+ gridType: 'solid',
1892
+ dashLength: 4
1893
+ },
1894
+ opts.extra.tooltip
1895
+ );
1847
1896
 
1848
1897
  var startX = opts.area[3];
1849
1898
  var endX = opts.width - opts.padding[1];
@@ -1870,10 +1919,17 @@ function drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoin
1870
1919
  let textX = bgStartX + (bgWidth - textWidth) / 2;
1871
1920
  let textY = opts.tooltip.offset.y;
1872
1921
  context.beginPath();
1873
- context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity));
1922
+ context.setFillStyle(
1923
+ hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity)
1924
+ );
1874
1925
  context.setStrokeStyle(toolTipOption.labelBgColor || config.toolTipBackground);
1875
1926
  context.setLineWidth(1 * opts.pixelRatio);
1876
- context.rect(bgStartX, textY - 0.5 * config.fontSize - config.toolTipPadding, bgWidth, config.fontSize + 2 * config.toolTipPadding);
1927
+ context.rect(
1928
+ bgStartX,
1929
+ textY - 0.5 * config.fontSize - config.toolTipPadding,
1930
+ bgWidth,
1931
+ config.fontSize + 2 * config.toolTipPadding
1932
+ );
1877
1933
  context.closePath();
1878
1934
  context.stroke();
1879
1935
  context.fill();
@@ -1888,10 +1944,14 @@ function drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoin
1888
1944
  }
1889
1945
 
1890
1946
  function drawToolTipSplitArea(offsetX, opts, config, context, eachSpacing) {
1891
- var toolTipOption = assign({}, {
1892
- activeBgColor: '#000000',
1893
- activeBgOpacity: 0.08
1894
- }, opts.extra.tooltip);
1947
+ var toolTipOption = assign(
1948
+ {},
1949
+ {
1950
+ activeBgColor: '#000000',
1951
+ activeBgOpacity: 0.08
1952
+ },
1953
+ opts.extra.tooltip
1954
+ );
1895
1955
  var startY = opts.area[0];
1896
1956
  var endY = opts.height - opts.area[2];
1897
1957
  context.beginPath();
@@ -1902,11 +1962,15 @@ function drawToolTipSplitArea(offsetX, opts, config, context, eachSpacing) {
1902
1962
  }
1903
1963
 
1904
1964
  function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxisPoints) {
1905
- var toolTipOption = assign({}, {
1906
- bgColor: '#000000',
1907
- bgOpacity: 0.7,
1908
- fontColor: '#FFFFFF'
1909
- }, opts.extra.tooltip);
1965
+ var toolTipOption = assign(
1966
+ {},
1967
+ {
1968
+ bgColor: '#000000',
1969
+ bgOpacity: 0.7,
1970
+ fontColor: '#FFFFFF'
1971
+ },
1972
+ opts.extra.tooltip
1973
+ );
1910
1974
  var legendWidth = 4 * opts.pixelRatio;
1911
1975
  var legendMarginRight = 5 * opts.pixelRatio;
1912
1976
  var arrowWidth = 8 * opts.pixelRatio;
@@ -1915,12 +1979,15 @@ function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxis
1915
1979
  drawToolTipSplitLine(opts.tooltip.offset.x, opts, config, context);
1916
1980
  }
1917
1981
 
1918
- offset = assign({
1919
- x: 0,
1920
- y: 0
1921
- }, offset);
1982
+ offset = assign(
1983
+ {
1984
+ x: 0,
1985
+ y: 0
1986
+ },
1987
+ offset
1988
+ );
1922
1989
  offset.y -= 8 * opts.pixelRatio;
1923
- var textWidth = textList.map(function(item) {
1990
+ var textWidth = textList.map(function (item) {
1924
1991
  return measureText(item.text, config.fontSize);
1925
1992
  });
1926
1993
  var toolTipWidth = legendWidth + legendMarginRight + 4 * config.toolTipPadding + Math.max.apply(null, textWidth);
@@ -1935,7 +2002,9 @@ function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxis
1935
2002
  }
1936
2003
  // draw background rect
1937
2004
  context.beginPath();
1938
- context.setFillStyle(hexToRgb(toolTipOption.bgColor || config.toolTipBackground, toolTipOption.bgOpacity || config.toolTipOpacity));
2005
+ context.setFillStyle(
2006
+ hexToRgb(toolTipOption.bgColor || config.toolTipBackground, toolTipOption.bgOpacity || config.toolTipOpacity)
2007
+ );
1939
2008
  if (isOverRightBorder) {
1940
2009
  context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio);
1941
2010
  context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio);
@@ -1960,13 +2029,17 @@ function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxis
1960
2029
  context.fill();
1961
2030
 
1962
2031
  // draw legend
1963
- textList.forEach(function(item, index) {
2032
+ textList.forEach(function (item, index) {
1964
2033
  if (item.color !== null) {
1965
2034
  context.beginPath();
1966
2035
  context.setFillStyle(item.color);
1967
2036
  var startX = offset.x + arrowWidth + 2 * config.toolTipPadding;
1968
- var startY = offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index +
1969
- config.toolTipPadding + 1;
2037
+ var startY =
2038
+ offset.y +
2039
+ (config.toolTipLineHeight - config.fontSize) / 2 +
2040
+ config.toolTipLineHeight * index +
2041
+ config.toolTipPadding +
2042
+ 1;
1970
2043
  if (isOverRightBorder) {
1971
2044
  startX = offset.x - toolTipWidth - arrowWidth + 2 * config.toolTipPadding;
1972
2045
  }
@@ -1977,13 +2050,13 @@ function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxis
1977
2050
 
1978
2051
  // draw text list
1979
2052
 
1980
- textList.forEach(function(item, index) {
2053
+ textList.forEach(function (item, index) {
1981
2054
  var startX = offset.x + arrowWidth + 2 * config.toolTipPadding + legendWidth + legendMarginRight;
1982
2055
  if (isOverRightBorder) {
1983
2056
  startX = offset.x - toolTipWidth - arrowWidth + 2 * config.toolTipPadding + +legendWidth + legendMarginRight;
1984
2057
  }
1985
- var startY = offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index +
1986
- config.toolTipPadding;
2058
+ var startY =
2059
+ offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index + config.toolTipPadding;
1987
2060
  context.beginPath();
1988
2061
  context.setFontSize(config.fontSize);
1989
2062
  context.setFillStyle(toolTipOption.fontColor);
@@ -2000,7 +2073,7 @@ function drawYAxisTitle(title, opts, config, context) {
2000
2073
  context.setFontSize(config.fontSize);
2001
2074
  context.setFillStyle(opts.yAxis.titleFontColor || '#333333');
2002
2075
  context.translate(0, opts.height);
2003
- context.rotate(-90 * Math.PI / 180);
2076
+ context.rotate((-90 * Math.PI) / 180);
2004
2077
  context.fillText(title, startX, opts.padding[3] + 0.5 * config.fontSize);
2005
2078
  context.closePath();
2006
2079
  context.stroke();
@@ -2013,14 +2086,18 @@ function drawColumnDataPoints(series, opts, config, context) {
2013
2086
  let xAxisData = opts.chartData.xAxisData,
2014
2087
  xAxisPoints = xAxisData.xAxisPoints,
2015
2088
  eachSpacing = xAxisData.eachSpacing;
2016
- let columnOption = assign({}, {
2017
- type: 'group',
2018
- width: eachSpacing / 2,
2019
- meter: {
2020
- border: 4,
2021
- fillColor: '#FFFFFF'
2022
- }
2023
- }, opts.extra.column);
2089
+ let columnOption = assign(
2090
+ {},
2091
+ {
2092
+ type: 'group',
2093
+ width: eachSpacing / 2,
2094
+ meter: {
2095
+ border: 4,
2096
+ fillColor: '#FFFFFF'
2097
+ }
2098
+ },
2099
+ opts.extra.column
2100
+ );
2024
2101
  let minRange = ranges.pop();
2025
2102
  let maxRange = ranges.shift();
2026
2103
  let calPoints = [];
@@ -2033,27 +2110,38 @@ function drawColumnDataPoints(series, opts, config, context) {
2033
2110
  drawToolTipSplitArea(opts.tooltip.offset.x, opts, config, context, eachSpacing);
2034
2111
  }
2035
2112
 
2036
- series.forEach(function(eachSeries, seriesIndex) {
2113
+ series.forEach(function (eachSeries, seriesIndex) {
2037
2114
  var data = eachSeries.data;
2038
2115
  switch (columnOption.type) {
2039
2116
  case 'group':
2040
2117
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2041
- var tooltipPoints = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, seriesIndex, series, process);
2118
+ var tooltipPoints = getStackDataPoints(
2119
+ data,
2120
+ minRange,
2121
+ maxRange,
2122
+ xAxisPoints,
2123
+ eachSpacing,
2124
+ opts,
2125
+ config,
2126
+ seriesIndex,
2127
+ series,
2128
+ process
2129
+ );
2042
2130
  calPoints.push(tooltipPoints);
2043
2131
  points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config, opts);
2044
- points.forEach(function(item, index) {
2132
+ points.forEach(function (item, index) {
2045
2133
  if (item !== null) {
2046
2134
  context.beginPath();
2047
2135
  context.setStrokeStyle(item.color || eachSeries.color);
2048
- context.setLineWidth(1)
2136
+ context.setLineWidth(1);
2049
2137
  context.setFillStyle(item.color || eachSeries.color);
2050
2138
  var startX = item.x - item.width / 2;
2051
2139
  var height = opts.height - item.y - opts.area[2];
2052
- context.moveTo(startX-1, item.y);
2053
- context.lineTo(startX+item.width-2,item.y);
2054
- context.lineTo(startX+item.width-2,opts.height - opts.area[2]);
2055
- context.lineTo(startX,opts.height - opts.area[2]);
2056
- context.lineTo(startX,item.y);
2140
+ context.moveTo(startX - 1, item.y);
2141
+ context.lineTo(startX + item.width - 2, item.y);
2142
+ context.lineTo(startX + item.width - 2, opts.height - opts.area[2]);
2143
+ context.lineTo(startX, opts.height - opts.area[2]);
2144
+ context.lineTo(startX, item.y);
2057
2145
  //context.rect(startX, item.y, item.width, height);
2058
2146
  context.closePath();
2059
2147
  context.stroke();
@@ -2063,13 +2151,22 @@ function drawColumnDataPoints(series, opts, config, context) {
2063
2151
  break;
2064
2152
  case 'stack':
2065
2153
  // 绘制堆叠数据图
2066
- var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config,
2154
+ var points = getStackDataPoints(
2155
+ data,
2156
+ minRange,
2157
+ maxRange,
2158
+ xAxisPoints,
2159
+ eachSpacing,
2160
+ opts,
2161
+ config,
2067
2162
  seriesIndex,
2068
- series, process);
2163
+ series,
2164
+ process
2165
+ );
2069
2166
  calPoints.push(points);
2070
2167
  points = fixColumeStackData(points, eachSpacing, series.length, seriesIndex, config, opts, series);
2071
2168
 
2072
- points.forEach(function(item, index) {
2169
+ points.forEach(function (item, index) {
2073
2170
  if (item !== null) {
2074
2171
  context.beginPath();
2075
2172
  context.setFillStyle(item.color || eachSeries.color);
@@ -2090,10 +2187,9 @@ function drawColumnDataPoints(series, opts, config, context) {
2090
2187
  // 绘制温度计数据图
2091
2188
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2092
2189
  calPoints.push(points);
2093
- points = fixColumeMeterData(points, eachSpacing, series.length, seriesIndex, config, opts, columnOption.meter
2094
- .border);
2190
+ points = fixColumeMeterData(points, eachSpacing, series.length, seriesIndex, config, opts, columnOption.meter.border);
2095
2191
  if (seriesIndex == 0) {
2096
- points.forEach(function(item, index) {
2192
+ points.forEach(function (item, index) {
2097
2193
  if (item !== null) {
2098
2194
  //画背景颜色
2099
2195
  context.beginPath();
@@ -2118,7 +2214,7 @@ function drawColumnDataPoints(series, opts, config, context) {
2118
2214
  }
2119
2215
  });
2120
2216
  } else {
2121
- points.forEach(function(item, index) {
2217
+ points.forEach(function (item, index) {
2122
2218
  if (item !== null) {
2123
2219
  context.beginPath();
2124
2220
  context.setFillStyle(item.color || eachSeries.color);
@@ -2136,7 +2232,7 @@ function drawColumnDataPoints(series, opts, config, context) {
2136
2232
  });
2137
2233
 
2138
2234
  if (opts.dataLabel !== false && process === 1) {
2139
- series.forEach(function(eachSeries, seriesIndex) {
2235
+ series.forEach(function (eachSeries, seriesIndex) {
2140
2236
  var data = eachSeries.data;
2141
2237
  switch (columnOption.type) {
2142
2238
  case 'group':
@@ -2146,9 +2242,18 @@ function drawColumnDataPoints(series, opts, config, context) {
2146
2242
  drawPointText(points, eachSeries, config, context);
2147
2243
  break;
2148
2244
  case 'stack':
2149
- var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config,
2245
+ var points = getStackDataPoints(
2246
+ data,
2247
+ minRange,
2248
+ maxRange,
2249
+ xAxisPoints,
2250
+ eachSpacing,
2251
+ opts,
2252
+ config,
2150
2253
  seriesIndex,
2151
- series, process);
2254
+ series,
2255
+ process
2256
+ );
2152
2257
  drawPointText(points, eachSeries, config, context);
2153
2258
  break;
2154
2259
  case 'meter':
@@ -2172,22 +2277,34 @@ function drawColumnDataPoints(series, opts, config, context) {
2172
2277
 
2173
2278
  function drawCandleDataPoints(series, seriesMA, opts, config, context) {
2174
2279
  var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
2175
- var candleOption = assign({}, {
2176
- color: {},
2177
- average: {}
2178
- }, opts.extra.candle);
2179
- candleOption.color = assign({}, {
2180
- upLine: '#f04864',
2181
- upFill: '#f04864',
2182
- downLine: '#2fc25b',
2183
- downFill: '#2fc25b'
2184
- }, candleOption.color);
2185
- candleOption.average = assign({}, {
2186
- show: false,
2187
- name: [],
2188
- day: [],
2189
- color: config.colors
2190
- }, candleOption.average);
2280
+ var candleOption = assign(
2281
+ {},
2282
+ {
2283
+ color: {},
2284
+ average: {}
2285
+ },
2286
+ opts.extra.candle
2287
+ );
2288
+ candleOption.color = assign(
2289
+ {},
2290
+ {
2291
+ upLine: '#f04864',
2292
+ upFill: '#f04864',
2293
+ downLine: '#2fc25b',
2294
+ downFill: '#2fc25b'
2295
+ },
2296
+ candleOption.color
2297
+ );
2298
+ candleOption.average = assign(
2299
+ {},
2300
+ {
2301
+ show: false,
2302
+ name: [],
2303
+ day: [],
2304
+ color: config.colors
2305
+ },
2306
+ candleOption.average
2307
+ );
2191
2308
  opts.extra.candle = candleOption;
2192
2309
 
2193
2310
  let ranges = [].concat(opts.chartData.yAxisData.ranges);
@@ -2205,13 +2322,13 @@ function drawCandleDataPoints(series, seriesMA, opts, config, context) {
2205
2322
  }
2206
2323
  //画均线
2207
2324
  if (candleOption.average.show) {
2208
- seriesMA.forEach(function(eachSeries, seriesIndex) {
2325
+ seriesMA.forEach(function (eachSeries, seriesIndex) {
2209
2326
  var data = eachSeries.data;
2210
2327
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2211
2328
  //calPoints.push(points);
2212
2329
  var splitPointList = splitPoints(points);
2213
2330
 
2214
- splitPointList.forEach(function(points, index) {
2331
+ splitPointList.forEach(function (points, index) {
2215
2332
  context.beginPath();
2216
2333
  context.setStrokeStyle(eachSeries.color);
2217
2334
  context.setLineWidth(1);
@@ -2220,12 +2337,10 @@ function drawCandleDataPoints(series, seriesMA, opts, config, context) {
2220
2337
  context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI);
2221
2338
  } else {
2222
2339
  context.moveTo(points[0].x, points[0].y);
2223
- points.forEach(function(item, index) {
2340
+ points.forEach(function (item, index) {
2224
2341
  if (index > 0) {
2225
2342
  var ctrlPoint = createCurveControlPoints(points, index - 1);
2226
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,
2227
- item.x, item
2228
- .y);
2343
+ context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
2229
2344
  }
2230
2345
  });
2231
2346
  context.moveTo(points[0].x, points[0].y);
@@ -2236,14 +2351,14 @@ function drawCandleDataPoints(series, seriesMA, opts, config, context) {
2236
2351
  });
2237
2352
  }
2238
2353
  //画K线
2239
- series.forEach(function(eachSeries, seriesIndex) {
2354
+ series.forEach(function (eachSeries, seriesIndex) {
2240
2355
  var data = eachSeries.data;
2241
2356
  var points = getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2242
2357
  calPoints.push(points);
2243
2358
  var splitPointList = splitPoints(points);
2244
2359
  splitPointList = splitPointList[0];
2245
2360
 
2246
- splitPointList.forEach(function(points, index) {
2361
+ splitPointList.forEach(function (points, index) {
2247
2362
  context.beginPath();
2248
2363
  //如果上涨
2249
2364
  if (data[index][1] - data[index][0] > 0) {
@@ -2296,12 +2411,16 @@ function drawCandleDataPoints(series, seriesMA, opts, config, context) {
2296
2411
 
2297
2412
  function drawAreaDataPoints(series, opts, config, context) {
2298
2413
  var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
2299
- var areaOption = assign({},{
2300
- type: 'straight',
2301
- opacity: 0.2,
2302
- addLine: false,
2303
- width: 2
2304
- },opts.extra.area);
2414
+ var areaOption = assign(
2415
+ {},
2416
+ {
2417
+ type: 'straight',
2418
+ opacity: 0.2,
2419
+ addLine: false,
2420
+ width: 2
2421
+ },
2422
+ opts.extra.area
2423
+ );
2305
2424
 
2306
2425
  let ranges = [].concat(opts.chartData.yAxisData.ranges);
2307
2426
  let xAxisData = opts.chartData.xAxisData,
@@ -2318,7 +2437,7 @@ function drawAreaDataPoints(series, opts, config, context) {
2318
2437
  context.translate(opts._scrollDistance_, 0);
2319
2438
  }
2320
2439
 
2321
- series.forEach(function(eachSeries, seriesIndex) {
2440
+ series.forEach(function (eachSeries, seriesIndex) {
2322
2441
  let data = eachSeries.data;
2323
2442
  let points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2324
2443
  calPoints.push(points);
@@ -2338,14 +2457,14 @@ function drawAreaDataPoints(series, opts, config, context) {
2338
2457
 
2339
2458
  context.moveTo(firstPoint.x, firstPoint.y);
2340
2459
  if (areaOption.type === 'curve') {
2341
- points.forEach(function(item, index) {
2460
+ points.forEach(function (item, index) {
2342
2461
  if (index > 0) {
2343
2462
  let ctrlPoint = createCurveControlPoints(points, index - 1);
2344
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x, item.y);
2463
+ context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
2345
2464
  }
2346
2465
  });
2347
2466
  } else {
2348
- points.forEach(function(item, index) {
2467
+ points.forEach(function (item, index) {
2349
2468
  if (index > 0) {
2350
2469
  context.lineTo(item.x, item.y);
2351
2470
  }
@@ -2377,14 +2496,14 @@ function drawAreaDataPoints(series, opts, config, context) {
2377
2496
  } else {
2378
2497
  context.moveTo(points[0].x, points[0].y);
2379
2498
  if (areaOption.type === 'curve') {
2380
- points.forEach(function(item, index) {
2499
+ points.forEach(function (item, index) {
2381
2500
  if (index > 0) {
2382
2501
  let ctrlPoint = createCurveControlPoints(points, index - 1);
2383
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x,item.y);
2502
+ context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
2384
2503
  }
2385
2504
  });
2386
2505
  } else {
2387
- points.forEach(function(item, index) {
2506
+ points.forEach(function (item, index) {
2388
2507
  if (index > 0) {
2389
2508
  context.lineTo(item.x, item.y);
2390
2509
  }
@@ -2402,11 +2521,10 @@ function drawAreaDataPoints(series, opts, config, context) {
2402
2521
  var shape = config.dataPointShape[seriesIndex % config.dataPointShape.length];
2403
2522
  drawPointShape(points, eachSeries.color, shape, context, opts);
2404
2523
  }
2405
-
2406
2524
  });
2407
2525
 
2408
2526
  if (opts.dataLabel !== false && process === 1) {
2409
- series.forEach(function(eachSeries, seriesIndex) {
2527
+ series.forEach(function (eachSeries, seriesIndex) {
2410
2528
  var data = eachSeries.data;
2411
2529
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2412
2530
  drawPointText(points, eachSeries, config, context);
@@ -2447,13 +2565,13 @@ function drawLineDataPoints(series, opts, config, context) {
2447
2565
  context.translate(opts._scrollDistance_, 0);
2448
2566
  }
2449
2567
 
2450
- series.forEach(function(eachSeries, seriesIndex) {
2568
+ series.forEach(function (eachSeries, seriesIndex) {
2451
2569
  var data = eachSeries.data;
2452
2570
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2453
2571
  calPoints.push(points);
2454
2572
  var splitPointList = splitPoints(points);
2455
2573
 
2456
- splitPointList.forEach(function(points, index) {
2574
+ splitPointList.forEach(function (points, index) {
2457
2575
  context.beginPath();
2458
2576
  context.setStrokeStyle(eachSeries.color);
2459
2577
  context.setLineWidth(lineOption.width * opts.pixelRatio);
@@ -2463,16 +2581,14 @@ function drawLineDataPoints(series, opts, config, context) {
2463
2581
  } else {
2464
2582
  context.moveTo(points[0].x, points[0].y);
2465
2583
  if (lineOption.type === 'curve') {
2466
- points.forEach(function(item, index) {
2584
+ points.forEach(function (item, index) {
2467
2585
  if (index > 0) {
2468
2586
  var ctrlPoint = createCurveControlPoints(points, index - 1);
2469
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,
2470
- item.x, item
2471
- .y);
2587
+ context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
2472
2588
  }
2473
2589
  });
2474
2590
  } else {
2475
- points.forEach(function(item, index) {
2591
+ points.forEach(function (item, index) {
2476
2592
  if (index > 0) {
2477
2593
  context.lineTo(item.x, item.y);
2478
2594
  }
@@ -2491,7 +2607,7 @@ function drawLineDataPoints(series, opts, config, context) {
2491
2607
  });
2492
2608
 
2493
2609
  if (opts.dataLabel !== false && process === 1) {
2494
- series.forEach(function(eachSeries, seriesIndex) {
2610
+ series.forEach(function (eachSeries, seriesIndex) {
2495
2611
  var data = eachSeries.data;
2496
2612
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2497
2613
  drawPointText(points, eachSeries, config, context);
@@ -2523,7 +2639,7 @@ function drawMixDataPoints(series, opts, config, context) {
2523
2639
 
2524
2640
  var columnIndex = 0;
2525
2641
  var columnLength = 0;
2526
- series.forEach(function(eachSeries, seriesIndex) {
2642
+ series.forEach(function (eachSeries, seriesIndex) {
2527
2643
  if (eachSeries.type == 'column') {
2528
2644
  columnLength += 1;
2529
2645
  }
@@ -2533,7 +2649,7 @@ function drawMixDataPoints(series, opts, config, context) {
2533
2649
  context.translate(opts._scrollDistance_, 0);
2534
2650
  }
2535
2651
 
2536
- series.forEach(function(eachSeries, seriesIndex) {
2652
+ series.forEach(function (eachSeries, seriesIndex) {
2537
2653
  var data = eachSeries.data;
2538
2654
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2539
2655
  calPoints.push(points);
@@ -2541,20 +2657,20 @@ function drawMixDataPoints(series, opts, config, context) {
2541
2657
  // 绘制柱状数据图
2542
2658
  if (eachSeries.type == 'column') {
2543
2659
  points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config, opts);
2544
- points.forEach(function(item, index) {
2660
+ points.forEach(function (item, index) {
2545
2661
  if (item !== null) {
2546
2662
  context.beginPath();
2547
2663
  context.setStrokeStyle(item.color || eachSeries.color);
2548
- context.setLineWidth(1)
2664
+ context.setLineWidth(1);
2549
2665
  context.setFillStyle(item.color || eachSeries.color);
2550
2666
  var startX = item.x - item.width / 2;
2551
2667
  var height = opts.height - item.y - opts.area[2];
2552
2668
  context.moveTo(startX, item.y);
2553
- context.moveTo(startX-1, item.y);
2554
- context.lineTo(startX+item.width-2,item.y);
2555
- context.lineTo(startX+item.width-2,opts.height - opts.area[2]);
2556
- context.lineTo(startX,opts.height - opts.area[2]);
2557
- context.lineTo(startX,item.y);
2669
+ context.moveTo(startX - 1, item.y);
2670
+ context.lineTo(startX + item.width - 2, item.y);
2671
+ context.lineTo(startX + item.width - 2, opts.height - opts.area[2]);
2672
+ context.lineTo(startX, opts.height - opts.area[2]);
2673
+ context.lineTo(startX, item.y);
2558
2674
  //context.rect(startX, item.y, item.width, height);
2559
2675
  context.closePath();
2560
2676
  context.stroke();
@@ -2582,14 +2698,14 @@ function drawMixDataPoints(series, opts, config, context) {
2582
2698
  let lastPoint = points[points.length - 1];
2583
2699
  context.moveTo(firstPoint.x, firstPoint.y);
2584
2700
  if (eachSeries.style === 'curve') {
2585
- points.forEach(function(item, index) {
2701
+ points.forEach(function (item, index) {
2586
2702
  if (index > 0) {
2587
2703
  var ctrlPoint = createCurveControlPoints(points, index - 1);
2588
2704
  context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
2589
2705
  }
2590
2706
  });
2591
2707
  } else {
2592
- points.forEach(function(item, index) {
2708
+ points.forEach(function (item, index) {
2593
2709
  if (index > 0) {
2594
2710
  context.lineTo(item.x, item.y);
2595
2711
  }
@@ -2614,7 +2730,7 @@ function drawMixDataPoints(series, opts, config, context) {
2614
2730
  // 绘制折线数据图
2615
2731
  if (eachSeries.type == 'line') {
2616
2732
  var splitPointList = splitPoints(points);
2617
- splitPointList.forEach(function(points, index) {
2733
+ splitPointList.forEach(function (points, index) {
2618
2734
  context.beginPath();
2619
2735
  context.setStrokeStyle(eachSeries.color);
2620
2736
  context.setLineWidth(2 * opts.pixelRatio);
@@ -2624,16 +2740,14 @@ function drawMixDataPoints(series, opts, config, context) {
2624
2740
  } else {
2625
2741
  context.moveTo(points[0].x, points[0].y);
2626
2742
  if (eachSeries.style == 'curve') {
2627
- points.forEach(function(item, index) {
2743
+ points.forEach(function (item, index) {
2628
2744
  if (index > 0) {
2629
2745
  var ctrlPoint = createCurveControlPoints(points, index - 1);
2630
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,
2631
- item.x,
2632
- item.y);
2746
+ context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
2633
2747
  }
2634
2748
  });
2635
2749
  } else {
2636
- points.forEach(function(item, index) {
2750
+ points.forEach(function (item, index) {
2637
2751
  if (index > 0) {
2638
2752
  context.lineTo(item.x, item.y);
2639
2753
  }
@@ -2648,7 +2762,7 @@ function drawMixDataPoints(series, opts, config, context) {
2648
2762
 
2649
2763
  // 绘制点数据图
2650
2764
  if (eachSeries.type == 'point') {
2651
- points.forEach(function(pointsa, index) {
2765
+ points.forEach(function (pointsa, index) {
2652
2766
  if (pointsa) {
2653
2767
  context.beginPath();
2654
2768
  context.setFillStyle(eachSeries.color);
@@ -2670,7 +2784,7 @@ function drawMixDataPoints(series, opts, config, context) {
2670
2784
  });
2671
2785
  if (opts.dataLabel !== false && process === 1) {
2672
2786
  var columnIndex = 0;
2673
- series.forEach(function(eachSeries, seriesIndex) {
2787
+ series.forEach(function (eachSeries, seriesIndex) {
2674
2788
  var data = eachSeries.data;
2675
2789
  var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
2676
2790
  if (eachSeries.type !== 'column') {
@@ -2680,7 +2794,6 @@ function drawMixDataPoints(series, opts, config, context) {
2680
2794
  drawPointText(points, eachSeries, config, context);
2681
2795
  columnIndex += 1;
2682
2796
  }
2683
-
2684
2797
  });
2685
2798
  }
2686
2799
 
@@ -2697,8 +2810,13 @@ function drawMixDataPoints(series, opts, config, context) {
2697
2810
 
2698
2811
  function drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints) {
2699
2812
  var toolTipOption = opts.extra.tooltip || {};
2700
- if (toolTipOption.horizentalLine && opts.tooltip && process === 1 && (opts.type == 'line' || opts.type == 'area' || opts.type == 'column' || opts.type == 'candle' || opts.type == 'mix')) {
2701
- drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints)
2813
+ if (
2814
+ toolTipOption.horizentalLine &&
2815
+ opts.tooltip &&
2816
+ process === 1 &&
2817
+ (opts.type == 'line' || opts.type == 'area' || opts.type == 'column' || opts.type == 'candle' || opts.type == 'mix')
2818
+ ) {
2819
+ drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints);
2702
2820
  }
2703
2821
  context.save();
2704
2822
  if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
@@ -2708,19 +2826,17 @@ function drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoi
2708
2826
  drawToolTip(opts.tooltip.textList, opts.tooltip.offset, opts, config, context, eachSpacing, xAxisPoints);
2709
2827
  }
2710
2828
  context.restore();
2711
-
2712
2829
  }
2713
2830
 
2714
2831
  function drawXAxis(categories, opts, config, context) {
2715
-
2716
2832
  let xAxisData = opts.chartData.xAxisData,
2717
2833
  xAxisPoints = xAxisData.xAxisPoints,
2718
2834
  startX = xAxisData.startX,
2719
2835
  endX = xAxisData.endX,
2720
2836
  eachSpacing = xAxisData.eachSpacing;
2721
- var boundaryGap='center';
2722
- if (opts.type == 'line'||opts.type == 'area'){
2723
- boundaryGap=opts.xAxis.boundaryGap;
2837
+ var boundaryGap = 'center';
2838
+ if (opts.type == 'line' || opts.type == 'area') {
2839
+ boundaryGap = opts.xAxis.boundaryGap;
2724
2840
  }
2725
2841
  var startY = opts.height - opts.area[2];
2726
2842
  var endY = opts.area[0];
@@ -2730,15 +2846,15 @@ function drawXAxis(categories, opts, config, context) {
2730
2846
  var scrollY = opts.height - opts.area[2] + config.xAxisHeight;
2731
2847
  var scrollScreenWidth = endX - startX;
2732
2848
  var scrollTotalWidth = eachSpacing * (xAxisPoints.length - 1);
2733
- var scrollWidth = scrollScreenWidth * scrollScreenWidth / scrollTotalWidth;
2849
+ var scrollWidth = (scrollScreenWidth * scrollScreenWidth) / scrollTotalWidth;
2734
2850
  var scrollLeft = 0;
2735
2851
  if (opts._scrollDistance_) {
2736
- scrollLeft = -opts._scrollDistance_ * (scrollScreenWidth) / scrollTotalWidth;
2852
+ scrollLeft = (-opts._scrollDistance_ * scrollScreenWidth) / scrollTotalWidth;
2737
2853
  }
2738
2854
  context.beginPath();
2739
2855
  context.setLineCap('round');
2740
2856
  context.setLineWidth(6 * opts.pixelRatio);
2741
- context.setStrokeStyle(opts.xAxis.scrollBackgroundColor || "#EFEBEF");
2857
+ context.setStrokeStyle(opts.xAxis.scrollBackgroundColor || '#EFEBEF');
2742
2858
  context.moveTo(startX, scrollY);
2743
2859
  context.lineTo(endX, scrollY);
2744
2860
  context.stroke();
@@ -2746,7 +2862,7 @@ function drawXAxis(categories, opts, config, context) {
2746
2862
  context.beginPath();
2747
2863
  context.setLineCap('round');
2748
2864
  context.setLineWidth(6 * opts.pixelRatio);
2749
- context.setStrokeStyle(opts.xAxis.scrollColor || "#A6A6A6");
2865
+ context.setStrokeStyle(opts.xAxis.scrollColor || '#A6A6A6');
2750
2866
  context.moveTo(startX + scrollLeft, scrollY);
2751
2867
  context.lineTo(startX + scrollLeft + scrollWidth, scrollY);
2752
2868
  context.stroke();
@@ -2760,16 +2876,15 @@ function drawXAxis(categories, opts, config, context) {
2760
2876
  context.translate(opts._scrollDistance_, 0);
2761
2877
  }
2762
2878
 
2763
-
2764
2879
  if (opts.xAxis.disableGrid !== true) {
2765
- context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc");
2880
+ context.setStrokeStyle(opts.xAxis.gridColor || '#cccccc');
2766
2881
  context.setLineCap('butt');
2767
2882
  context.setLineWidth(1 * opts.pixelRatio);
2768
2883
  if (opts.xAxis.gridType == 'dash') {
2769
2884
  context.setLineDash([opts.xAxis.dashLength, opts.xAxis.dashLength]);
2770
2885
  }
2771
2886
  if (opts.xAxis.type === 'calibration') {
2772
- xAxisPoints.forEach(function(item, index) {
2887
+ xAxisPoints.forEach(function (item, index) {
2773
2888
  if (index > 0) {
2774
2889
  context.beginPath();
2775
2890
  context.moveTo(item - eachSpacing / 2, startY);
@@ -2780,7 +2895,7 @@ function drawXAxis(categories, opts, config, context) {
2780
2895
  });
2781
2896
  } else {
2782
2897
  opts.xAxis.gridEval = opts.xAxis.gridEval || 1;
2783
- xAxisPoints.forEach(function(item, index) {
2898
+ xAxisPoints.forEach(function (item, index) {
2784
2899
  if (index % opts.xAxis.gridEval == 0) {
2785
2900
  context.beginPath();
2786
2901
  context.moveTo(item, startY);
@@ -2792,7 +2907,6 @@ function drawXAxis(categories, opts, config, context) {
2792
2907
  context.setLineDash([]);
2793
2908
  }
2794
2909
 
2795
-
2796
2910
  //不绘制X轴
2797
2911
  if (opts.xAxis.disabled !== true) {
2798
2912
  // 对X轴列表做抽稀处理
@@ -2803,7 +2917,7 @@ function drawXAxis(categories, opts, config, context) {
2803
2917
  if (opts.xAxis.labelCount) {
2804
2918
  //如果设置X轴密度
2805
2919
  if (opts.xAxis.itemCount) {
2806
- maxXAxisListLength = Math.ceil(categories.length / opts.xAxis.itemCount * opts.xAxis.labelCount);
2920
+ maxXAxisListLength = Math.ceil((categories.length / opts.xAxis.itemCount) * opts.xAxis.labelCount);
2807
2921
  } else {
2808
2922
  maxXAxisListLength = opts.xAxis.labelCount;
2809
2923
  }
@@ -2816,7 +2930,7 @@ function drawXAxis(categories, opts, config, context) {
2816
2930
  let cgLength = categories.length;
2817
2931
  for (let i = 0; i < cgLength; i++) {
2818
2932
  if (i % ratio !== 0) {
2819
- newCategories.push("");
2933
+ newCategories.push('');
2820
2934
  } else {
2821
2935
  newCategories.push(categories[i]);
2822
2936
  }
@@ -2825,10 +2939,10 @@ function drawXAxis(categories, opts, config, context) {
2825
2939
 
2826
2940
  var xAxisFontSize = opts.xAxis.fontSize || config.fontSize;
2827
2941
  if (config._xAxisTextAngle_ === 0) {
2828
- newCategories.forEach(function(item, index) {
2829
- var offset = - measureText(item, xAxisFontSize) / 2;
2830
- if(boundaryGap == 'center'){
2831
- offset+=eachSpacing / 2;
2942
+ newCategories.forEach(function (item, index) {
2943
+ var offset = -measureText(item, xAxisFontSize) / 2;
2944
+ if (boundaryGap == 'center') {
2945
+ offset += eachSpacing / 2;
2832
2946
  }
2833
2947
  context.beginPath();
2834
2948
  context.setFontSize(xAxisFontSize);
@@ -2837,19 +2951,22 @@ function drawXAxis(categories, opts, config, context) {
2837
2951
  context.closePath();
2838
2952
  context.stroke();
2839
2953
  });
2840
-
2841
2954
  } else {
2842
- newCategories.forEach(function(item, index) {
2955
+ newCategories.forEach(function (item, index) {
2843
2956
  context.save();
2844
2957
  context.beginPath();
2845
2958
  context.setFontSize(xAxisFontSize);
2846
2959
  context.setFillStyle(opts.xAxis.fontColor || '#666666');
2847
2960
  var textWidth = measureText(item);
2848
- var offset = - textWidth;
2849
- if(boundaryGap == 'center'){
2850
- offset+=eachSpacing / 2;
2961
+ var offset = -textWidth;
2962
+ if (boundaryGap == 'center') {
2963
+ offset += eachSpacing / 2;
2851
2964
  }
2852
- var _calRotateTranslate = calRotateTranslate(xAxisPoints[index] + eachSpacing / 2, startY + xAxisFontSize / 2 + 5, opts.height),
2965
+ var _calRotateTranslate = calRotateTranslate(
2966
+ xAxisPoints[index] + eachSpacing / 2,
2967
+ startY + xAxisFontSize / 2 + 5,
2968
+ opts.height
2969
+ ),
2853
2970
  transX = _calRotateTranslate.transX,
2854
2971
  transY = _calRotateTranslate.transY;
2855
2972
 
@@ -2863,7 +2980,6 @@ function drawXAxis(categories, opts, config, context) {
2863
2980
  }
2864
2981
  }
2865
2982
  context.restore();
2866
-
2867
2983
  }
2868
2984
 
2869
2985
  function drawYAxisGrid(categories, opts, config, context) {
@@ -2891,9 +3007,9 @@ function drawYAxisGrid(categories, opts, config, context) {
2891
3007
  if (opts.yAxis.gridType == 'dash') {
2892
3008
  context.setLineDash([opts.yAxis.dashLength, opts.yAxis.dashLength]);
2893
3009
  }
2894
- context.setStrokeStyle(opts.yAxis.gridColor || "#cccccc");
3010
+ context.setStrokeStyle(opts.yAxis.gridColor || '#cccccc');
2895
3011
  context.setLineWidth(1 * opts.pixelRatio);
2896
- points.forEach(function(item, index) {
3012
+ points.forEach(function (item, index) {
2897
3013
  context.beginPath();
2898
3014
  context.moveTo(startX, item);
2899
3015
  context.lineTo(endX, item);
@@ -2924,7 +3040,7 @@ function drawYAxis(series, opts, config, context) {
2924
3040
  if (opts._scrollDistance_ < 0) {
2925
3041
  context.fillRect(0, 0, startX, fillEndY);
2926
3042
  }
2927
- if(opts.enableScroll == true){
3043
+ if (opts.enableScroll == true) {
2928
3044
  context.fillRect(endX, 0, opts.width, fillEndY);
2929
3045
  }
2930
3046
  context.closePath();
@@ -2936,7 +3052,7 @@ function drawYAxis(series, opts, config, context) {
2936
3052
  }
2937
3053
 
2938
3054
  var yAxisFontSize = opts.yAxis.fontSize || config.fontSize;
2939
- rangesFormat.forEach(function(item, index) {
3055
+ rangesFormat.forEach(function (item, index) {
2940
3056
  var pos = points[index] ? points[index] : endY;
2941
3057
  context.beginPath();
2942
3058
  context.setFontSize(yAxisFontSize);
@@ -2976,7 +3092,7 @@ function drawLegend(series, opts, config, context, chartData) {
2976
3092
  context.fill();
2977
3093
  context.stroke();
2978
3094
 
2979
- legendList.forEach(function(itemList, listIndex) {
3095
+ legendList.forEach(function (itemList, listIndex) {
2980
3096
  let width = 0;
2981
3097
  let height = 0;
2982
3098
  width = legendData.widthArr[listIndex];
@@ -3053,7 +3169,7 @@ function drawLegend(series, opts, config, context, chartData) {
3053
3169
  startX += measureText(item.name, fontSize) + itemGap;
3054
3170
  item.area[2] = startX;
3055
3171
  } else {
3056
- item.area[2] = startX + measureText(item.name, fontSize) + itemGap;;
3172
+ item.area[2] = startX + measureText(item.name, fontSize) + itemGap;
3057
3173
  startX -= shapeWidth + shapeRight;
3058
3174
  startY += lineHeight;
3059
3175
  }
@@ -3063,16 +3179,20 @@ function drawLegend(series, opts, config, context, chartData) {
3063
3179
 
3064
3180
  function drawPieDataPoints(series, opts, config, context) {
3065
3181
  var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
3066
- var pieOption = assign({}, {
3067
- activeOpacity: 0.5,
3068
- activeRadius: 10 * opts.pixelRatio,
3069
- offsetAngle: 0,
3070
- labelWidth: 15 * opts.pixelRatio,
3071
- ringWidth: 0,
3072
- border:false,
3073
- borderWidth:2,
3074
- borderColor:'#FFFFFF'
3075
- }, opts.extra.pie);
3182
+ var pieOption = assign(
3183
+ {},
3184
+ {
3185
+ activeOpacity: 0.5,
3186
+ activeRadius: 10 * opts.pixelRatio,
3187
+ offsetAngle: 0,
3188
+ labelWidth: 15 * opts.pixelRatio,
3189
+ ringWidth: 0,
3190
+ border: false,
3191
+ borderWidth: 2,
3192
+ borderColor: '#FFFFFF'
3193
+ },
3194
+ opts.extra.pie
3195
+ );
3076
3196
  var centerPosition = {
3077
3197
  x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
3078
3198
  y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
@@ -3081,36 +3201,52 @@ function drawPieDataPoints(series, opts, config, context) {
3081
3201
  config.pieChartLinePadding = pieOption.activeRadius;
3082
3202
  }
3083
3203
 
3084
- var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding - config._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding);
3204
+ var radius = Math.min(
3205
+ (opts.width - opts.area[1] - opts.area[3]) / 2 -
3206
+ config.pieChartLinePadding -
3207
+ config.pieChartTextPadding -
3208
+ config._pieTextMaxLength_,
3209
+ (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding
3210
+ );
3085
3211
 
3086
3212
  series = getPieDataPoints(series, radius, process);
3087
3213
 
3088
3214
  var activeRadius = pieOption.activeRadius;
3089
3215
 
3090
- series = series.map(function(eachSeries) {
3091
- eachSeries._start_ += (pieOption.offsetAngle) * Math.PI / 180;
3216
+ series = series.map(function (eachSeries) {
3217
+ eachSeries._start_ += (pieOption.offsetAngle * Math.PI) / 180;
3092
3218
  return eachSeries;
3093
3219
  });
3094
- series.forEach(function(eachSeries, seriesIndex) {
3220
+ series.forEach(function (eachSeries, seriesIndex) {
3095
3221
  if (opts.tooltip) {
3096
3222
  if (opts.tooltip.index == seriesIndex) {
3097
3223
  context.beginPath();
3098
3224
  context.setFillStyle(hexToRgb(eachSeries.color, opts.extra.pie.activeOpacity || 0.5));
3099
3225
  context.moveTo(centerPosition.x, centerPosition.y);
3100
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_ + activeRadius, eachSeries._start_,
3101
- eachSeries._start_ + 2 *
3102
- eachSeries._proportion_ * Math.PI);
3226
+ context.arc(
3227
+ centerPosition.x,
3228
+ centerPosition.y,
3229
+ eachSeries._radius_ + activeRadius,
3230
+ eachSeries._start_,
3231
+ eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI
3232
+ );
3103
3233
  context.closePath();
3104
3234
  context.fill();
3105
3235
  }
3106
3236
  }
3107
3237
  context.beginPath();
3108
3238
  context.setLineWidth(pieOption.borderWidth * opts.pixelRatio);
3109
- context.lineJoin = "round";
3239
+ context.lineJoin = 'round';
3110
3240
  context.setStrokeStyle(pieOption.borderColor);
3111
3241
  context.setFillStyle(eachSeries.color);
3112
3242
  context.moveTo(centerPosition.x, centerPosition.y);
3113
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI);
3243
+ context.arc(
3244
+ centerPosition.x,
3245
+ centerPosition.y,
3246
+ eachSeries._radius_,
3247
+ eachSeries._start_,
3248
+ eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI
3249
+ );
3114
3250
  context.closePath();
3115
3251
  context.fill();
3116
3252
  if (pieOption.border == true) {
@@ -3158,16 +3294,20 @@ function drawPieDataPoints(series, opts, config, context) {
3158
3294
 
3159
3295
  function drawRoseDataPoints(series, opts, config, context) {
3160
3296
  var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
3161
- var roseOption = assign({}, {
3162
- type: 'area',
3163
- activeOpacity: 0.5,
3164
- activeRadius: 10 * opts.pixelRatio,
3165
- offsetAngle: 0,
3166
- labelWidth: 15 * opts.pixelRatio,
3167
- border:false,
3168
- borderWidth:2,
3169
- borderColor:'#FFFFFF'
3170
- }, opts.extra.rose);
3297
+ var roseOption = assign(
3298
+ {},
3299
+ {
3300
+ type: 'area',
3301
+ activeOpacity: 0.5,
3302
+ activeRadius: 10 * opts.pixelRatio,
3303
+ offsetAngle: 0,
3304
+ labelWidth: 15 * opts.pixelRatio,
3305
+ border: false,
3306
+ borderWidth: 2,
3307
+ borderColor: '#FFFFFF'
3308
+ },
3309
+ opts.extra.rose
3310
+ );
3171
3311
  if (config.pieChartLinePadding == 0) {
3172
3312
  config.pieChartLinePadding = roseOption.activeRadius;
3173
3313
  }
@@ -3175,38 +3315,54 @@ function drawRoseDataPoints(series, opts, config, context) {
3175
3315
  x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
3176
3316
  y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
3177
3317
  };
3178
- var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding - config._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding);
3318
+ var radius = Math.min(
3319
+ (opts.width - opts.area[1] - opts.area[3]) / 2 -
3320
+ config.pieChartLinePadding -
3321
+ config.pieChartTextPadding -
3322
+ config._pieTextMaxLength_,
3323
+ (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding
3324
+ );
3179
3325
  var minRadius = roseOption.minRadius || radius * 0.5;
3180
3326
 
3181
3327
  series = getRoseDataPoints(series, roseOption.type, minRadius, radius, process);
3182
3328
 
3183
3329
  var activeRadius = roseOption.activeRadius;
3184
3330
 
3185
- series = series.map(function(eachSeries) {
3186
- eachSeries._start_ += (roseOption.offsetAngle || 0) * Math.PI / 180;
3331
+ series = series.map(function (eachSeries) {
3332
+ eachSeries._start_ += ((roseOption.offsetAngle || 0) * Math.PI) / 180;
3187
3333
  return eachSeries;
3188
3334
  });
3189
3335
 
3190
- series.forEach(function(eachSeries, seriesIndex) {
3336
+ series.forEach(function (eachSeries, seriesIndex) {
3191
3337
  if (opts.tooltip) {
3192
3338
  if (opts.tooltip.index == seriesIndex) {
3193
3339
  context.beginPath();
3194
3340
  context.setFillStyle(hexToRgb(eachSeries.color, roseOption.activeOpacity || 0.5));
3195
3341
  context.moveTo(centerPosition.x, centerPosition.y);
3196
- context.arc(centerPosition.x, centerPosition.y, activeRadius + eachSeries._radius_, eachSeries._start_,
3197
- eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI);
3342
+ context.arc(
3343
+ centerPosition.x,
3344
+ centerPosition.y,
3345
+ activeRadius + eachSeries._radius_,
3346
+ eachSeries._start_,
3347
+ eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI
3348
+ );
3198
3349
  context.closePath();
3199
3350
  context.fill();
3200
3351
  }
3201
3352
  }
3202
3353
  context.beginPath();
3203
3354
  context.setLineWidth(roseOption.borderWidth * opts.pixelRatio);
3204
- context.lineJoin = "round";
3355
+ context.lineJoin = 'round';
3205
3356
  context.setStrokeStyle(roseOption.borderColor);
3206
3357
  context.setFillStyle(eachSeries.color);
3207
3358
  context.moveTo(centerPosition.x, centerPosition.y);
3208
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 *
3209
- eachSeries._rose_proportion_ * Math.PI);
3359
+ context.arc(
3360
+ centerPosition.x,
3361
+ centerPosition.y,
3362
+ eachSeries._radius_,
3363
+ eachSeries._start_,
3364
+ eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI
3365
+ );
3210
3366
  context.closePath();
3211
3367
  context.fill();
3212
3368
  if (roseOption.border == true) {
@@ -3237,12 +3393,16 @@ function drawRoseDataPoints(series, opts, config, context) {
3237
3393
 
3238
3394
  function drawArcbarDataPoints(series, opts, config, context) {
3239
3395
  var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
3240
- var arcbarOption = assign({}, {
3241
- startAngle: 0.75,
3242
- endAngle: 0.25,
3243
- type: 'default',
3244
- width: 12 * opts.pixelRatio
3245
- }, opts.extra.arcbar);
3396
+ var arcbarOption = assign(
3397
+ {},
3398
+ {
3399
+ startAngle: 0.75,
3400
+ endAngle: 0.25,
3401
+ type: 'default',
3402
+ width: 12 * opts.pixelRatio
3403
+ },
3404
+ opts.extra.arcbar
3405
+ );
3246
3406
 
3247
3407
  series = getArcbarDataPoints(series, arcbarOption, process);
3248
3408
  var centerPosition = {
@@ -3259,8 +3419,14 @@ function drawArcbarDataPoints(series, opts, config, context) {
3259
3419
  context.setLineCap('round');
3260
3420
  context.beginPath();
3261
3421
  if (arcbarOption.type == 'default') {
3262
- context.arc(centerPosition.x, centerPosition.y, radius, arcbarOption.startAngle * Math.PI, arcbarOption.endAngle *
3263
- Math.PI, false);
3422
+ context.arc(
3423
+ centerPosition.x,
3424
+ centerPosition.y,
3425
+ radius,
3426
+ arcbarOption.startAngle * Math.PI,
3427
+ arcbarOption.endAngle * Math.PI,
3428
+ false
3429
+ );
3264
3430
  } else {
3265
3431
  context.arc(centerPosition.x, centerPosition.y, radius, 0, 2 * Math.PI, false);
3266
3432
  }
@@ -3272,8 +3438,14 @@ function drawArcbarDataPoints(series, opts, config, context) {
3272
3438
  context.setStrokeStyle(eachSeries.color);
3273
3439
  context.setLineCap('round');
3274
3440
  context.beginPath();
3275
- context.arc(centerPosition.x, centerPosition.y, radius, arcbarOption.startAngle * Math.PI, eachSeries._proportion_ *
3276
- Math.PI, false);
3441
+ context.arc(
3442
+ centerPosition.x,
3443
+ centerPosition.y,
3444
+ radius,
3445
+ arcbarOption.startAngle * Math.PI,
3446
+ eachSeries._proportion_ * Math.PI,
3447
+ false
3448
+ );
3277
3449
  context.stroke();
3278
3450
  }
3279
3451
 
@@ -3288,23 +3460,27 @@ function drawArcbarDataPoints(series, opts, config, context) {
3288
3460
 
3289
3461
  function drawGaugeDataPoints(categories, series, opts, config, context) {
3290
3462
  var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
3291
- var gaugeOption = assign({}, {
3292
- startAngle: 0.75,
3293
- endAngle: 0.25,
3294
- width: 15,
3295
- splitLine: {
3296
- fixRadius: 0,
3297
- splitNumber: 10,
3463
+ var gaugeOption = assign(
3464
+ {},
3465
+ {
3466
+ startAngle: 0.75,
3467
+ endAngle: 0.25,
3298
3468
  width: 15,
3299
- color: '#FFFFFF',
3300
- childNumber: 5,
3301
- childWidth: 5
3469
+ splitLine: {
3470
+ fixRadius: 0,
3471
+ splitNumber: 10,
3472
+ width: 15,
3473
+ color: '#FFFFFF',
3474
+ childNumber: 5,
3475
+ childWidth: 5
3476
+ },
3477
+ pointer: {
3478
+ width: 15,
3479
+ color: 'auto'
3480
+ }
3302
3481
  },
3303
- pointer: {
3304
- width: 15,
3305
- color: 'auto'
3306
- }
3307
- }, opts.extra.gauge);
3482
+ opts.extra.gauge
3483
+ );
3308
3484
 
3309
3485
  if (gaugeOption.oldAngle == undefined) {
3310
3486
  gaugeOption.oldAngle = gaugeOption.startAngle;
@@ -3330,8 +3506,14 @@ function drawGaugeDataPoints(categories, series, opts, config, context) {
3330
3506
  let eachCategories = categories[i];
3331
3507
  context.beginPath();
3332
3508
  context.setStrokeStyle(eachCategories.color);
3333
- context.arc(centerPosition.x, centerPosition.y, radius, eachCategories._startAngle_ * Math.PI, eachCategories._endAngle_ *
3334
- Math.PI, false);
3509
+ context.arc(
3510
+ centerPosition.x,
3511
+ centerPosition.y,
3512
+ radius,
3513
+ eachCategories._startAngle_ * Math.PI,
3514
+ eachCategories._endAngle_ * Math.PI,
3515
+ false
3516
+ );
3335
3517
  context.stroke();
3336
3518
  }
3337
3519
  context.save();
@@ -3418,11 +3600,15 @@ function drawGaugeDataPoints(categories, series, opts, config, context) {
3418
3600
 
3419
3601
  function drawRadarDataPoints(series, opts, config, context) {
3420
3602
  var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
3421
- var radarOption = assign({},{
3422
- gridColor: '#cccccc',
3423
- labelColor: '#666666',
3424
- opacity: 0.2
3425
- },opts.extra.radar);
3603
+ var radarOption = assign(
3604
+ {},
3605
+ {
3606
+ gridColor: '#cccccc',
3607
+ labelColor: '#666666',
3608
+ opacity: 0.2
3609
+ },
3610
+ opts.extra.radar
3611
+ );
3426
3612
 
3427
3613
  var coordinateAngle = getRadarCoordinateSeries(opts.categories.length);
3428
3614
 
@@ -3431,8 +3617,10 @@ function drawRadarDataPoints(series, opts, config, context) {
3431
3617
  y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
3432
3618
  };
3433
3619
 
3434
- var radius = Math.min(centerPosition.x - (getMaxTextListLength(opts.categories) + config.radarLabelTextMargin),
3435
- centerPosition.y - config.radarLabelTextMargin);
3620
+ var radius = Math.min(
3621
+ centerPosition.x - (getMaxTextListLength(opts.categories) + config.radarLabelTextMargin),
3622
+ centerPosition.y - config.radarLabelTextMargin
3623
+ );
3436
3624
  //TODO逻辑不对
3437
3625
  radius -= opts.padding[1];
3438
3626
 
@@ -3440,7 +3628,7 @@ function drawRadarDataPoints(series, opts, config, context) {
3440
3628
  context.beginPath();
3441
3629
  context.setLineWidth(1 * opts.pixelRatio);
3442
3630
  context.setStrokeStyle(radarOption.gridColor);
3443
- coordinateAngle.forEach(function(angle) {
3631
+ coordinateAngle.forEach(function (angle) {
3444
3632
  var pos = convertCoordinateOrigin(radius * Math.cos(angle), radius * Math.sin(angle), centerPosition);
3445
3633
  context.moveTo(centerPosition.x, centerPosition.y);
3446
3634
  context.lineTo(pos.x, pos.y);
@@ -3454,9 +3642,12 @@ function drawRadarDataPoints(series, opts, config, context) {
3454
3642
  context.beginPath();
3455
3643
  context.setLineWidth(1 * opts.pixelRatio);
3456
3644
  context.setStrokeStyle(radarOption.gridColor);
3457
- coordinateAngle.forEach(function(angle, index) {
3458
- var pos = convertCoordinateOrigin(radius / config.radarGridCount * i * Math.cos(angle), radius / config.radarGridCount *
3459
- i * Math.sin(angle), centerPosition);
3645
+ coordinateAngle.forEach(function (angle, index) {
3646
+ var pos = convertCoordinateOrigin(
3647
+ (radius / config.radarGridCount) * i * Math.cos(angle),
3648
+ (radius / config.radarGridCount) * i * Math.sin(angle),
3649
+ centerPosition
3650
+ );
3460
3651
  if (index === 0) {
3461
3652
  startPos = pos;
3462
3653
  context.moveTo(pos.x, pos.y);
@@ -3475,11 +3666,11 @@ function drawRadarDataPoints(series, opts, config, context) {
3475
3666
 
3476
3667
  var radarDataPoints = getRadarDataPoints(coordinateAngle, centerPosition, radius, series, opts, process);
3477
3668
 
3478
- radarDataPoints.forEach(function(eachSeries, seriesIndex) {
3669
+ radarDataPoints.forEach(function (eachSeries, seriesIndex) {
3479
3670
  // 绘制区域数据
3480
3671
  context.beginPath();
3481
3672
  context.setFillStyle(hexToRgb(eachSeries.color, radarOption.opacity));
3482
- eachSeries.data.forEach(function(item, index) {
3673
+ eachSeries.data.forEach(function (item, index) {
3483
3674
  if (index === 0) {
3484
3675
  context.moveTo(item.position.x, item.position.y);
3485
3676
  } else {
@@ -3491,7 +3682,7 @@ function drawRadarDataPoints(series, opts, config, context) {
3491
3682
 
3492
3683
  if (opts.dataPointShape !== false) {
3493
3684
  var shape = config.dataPointShape[seriesIndex % config.dataPointShape.length];
3494
- var points = eachSeries.data.map(function(item) {
3685
+ var points = eachSeries.data.map(function (item) {
3495
3686
  return item.position;
3496
3687
  });
3497
3688
  drawPointShape(points, eachSeries.color, shape, context, opts);
@@ -3508,139 +3699,168 @@ function drawRadarDataPoints(series, opts, config, context) {
3508
3699
  }
3509
3700
 
3510
3701
  function normalInt(min, max, iter) {
3511
- iter = iter==0?1:iter;
3512
- var arr = [];
3513
- for (var i = 0; i < iter; i++) {
3514
- arr[i] = Math.random();
3515
- };
3516
- return Math.floor(arr.reduce(function(i,j){return i+j})/iter*(max-min))+min;
3517
- };
3702
+ iter = iter == 0 ? 1 : iter;
3703
+ var arr = [];
3704
+ for (var i = 0; i < iter; i++) {
3705
+ arr[i] = Math.random();
3706
+ }
3707
+ return (
3708
+ Math.floor(
3709
+ (arr.reduce(function (i, j) {
3710
+ return i + j;
3711
+ }) /
3712
+ iter) *
3713
+ (max - min)
3714
+ ) + min
3715
+ );
3716
+ }
3518
3717
 
3519
- function collisionNew(area,points,width,height){
3520
- var isIn=false;
3521
- for(let i=0;i<points.length;i++){
3522
- if(points[i].area){
3523
- if(area[3]<points[i].area[1]||area[0]>points[i].area[2]||area[1]>points[i].area[3]||area[2]<points[i].area[0]){
3524
- if(area[0]<0 || area[1]<0 || area[2]>width || area[3]>height){
3525
- isIn=true;
3526
- break;
3527
- }else{
3528
- isIn=false;
3529
- }
3530
- }else{
3531
- isIn=true;
3718
+ function collisionNew(area, points, width, height) {
3719
+ var isIn = false;
3720
+ for (let i = 0; i < points.length; i++) {
3721
+ if (points[i].area) {
3722
+ if (
3723
+ area[3] < points[i].area[1] ||
3724
+ area[0] > points[i].area[2] ||
3725
+ area[1] > points[i].area[3] ||
3726
+ area[2] < points[i].area[0]
3727
+ ) {
3728
+ if (area[0] < 0 || area[1] < 0 || area[2] > width || area[3] > height) {
3729
+ isIn = true;
3532
3730
  break;
3731
+ } else {
3732
+ isIn = false;
3533
3733
  }
3734
+ } else {
3735
+ isIn = true;
3736
+ break;
3534
3737
  }
3535
3738
  }
3536
- return isIn;
3537
- };
3739
+ }
3740
+ return isIn;
3741
+ }
3538
3742
 
3539
3743
  function getBoundingBox(data) {
3540
- var bounds = {}, coords;
3744
+ var bounds = {},
3745
+ coords;
3541
3746
  bounds.xMin = 180;
3542
3747
  bounds.xMax = 0;
3543
3748
  bounds.yMin = 90;
3544
- bounds.yMax = 0
3749
+ bounds.yMax = 0;
3545
3750
  for (var i = 0; i < data.length; i++) {
3546
- var coorda = data[i].geometry.coordinates
3547
- for (var k = 0; k < coorda.length; k++) {
3548
- coords = coorda[k];
3549
- if (coords.length == 1) {
3550
- coords = coords[0]
3551
- }
3552
- for (var j = 0; j < coords.length; j++) {
3553
- var longitude = coords[j][0];
3554
- var latitude = coords[j][1];
3555
- var point = {
3556
- x: longitude,
3557
- y: latitude
3558
- }
3559
- bounds.xMin = bounds.xMin < point.x ? bounds.xMin : point.x;
3560
- bounds.xMax = bounds.xMax > point.x ? bounds.xMax : point.x;
3561
- bounds.yMin = bounds.yMin < point.y ? bounds.yMin : point.y;
3562
- bounds.yMax = bounds.yMax > point.y ? bounds.yMax : point.y;
3563
- }
3751
+ var coorda = data[i].geometry.coordinates;
3752
+ for (var k = 0; k < coorda.length; k++) {
3753
+ coords = coorda[k];
3754
+ if (coords.length == 1) {
3755
+ coords = coords[0];
3756
+ }
3757
+ for (var j = 0; j < coords.length; j++) {
3758
+ var longitude = coords[j][0];
3759
+ var latitude = coords[j][1];
3760
+ var point = {
3761
+ x: longitude,
3762
+ y: latitude
3763
+ };
3764
+ bounds.xMin = bounds.xMin < point.x ? bounds.xMin : point.x;
3765
+ bounds.xMax = bounds.xMax > point.x ? bounds.xMax : point.x;
3766
+ bounds.yMin = bounds.yMin < point.y ? bounds.yMin : point.y;
3767
+ bounds.yMax = bounds.yMax > point.y ? bounds.yMax : point.y;
3564
3768
  }
3769
+ }
3565
3770
  }
3566
3771
  return bounds;
3567
3772
  }
3568
3773
 
3569
- function coordinateToPoint(latitude, longitude,bounds,scale,xoffset,yoffset) {
3774
+ function coordinateToPoint(latitude, longitude, bounds, scale, xoffset, yoffset) {
3570
3775
  return {
3571
- x: (longitude - bounds.xMin) * scale+xoffset,
3572
- y: (bounds.yMax - latitude) * scale+yoffset
3776
+ x: (longitude - bounds.xMin) * scale + xoffset,
3777
+ y: (bounds.yMax - latitude) * scale + yoffset
3573
3778
  };
3574
3779
  }
3575
3780
 
3576
- function pointToCoordinate(pointY, pointX,bounds,scale,xoffset,yoffset) {
3781
+ function pointToCoordinate(pointY, pointX, bounds, scale, xoffset, yoffset) {
3577
3782
  return {
3578
- x: (pointX-xoffset)/scale+bounds.xMin,
3579
- y: bounds.yMax - (pointY-yoffset)/scale
3783
+ x: (pointX - xoffset) / scale + bounds.xMin,
3784
+ y: bounds.yMax - (pointY - yoffset) / scale
3580
3785
  };
3581
3786
  }
3582
3787
 
3583
- function isRayIntersectsSegment(poi,s_poi,e_poi){
3584
- if (s_poi[1]==e_poi[1]){return false;}
3585
- if (s_poi[1]>poi[1] && e_poi[1]>poi[1]){return false;}
3586
- if (s_poi[1]<poi[1] && e_poi[1]<poi[1]){return false;}
3587
- if (s_poi[1]==poi[1] && e_poi[1]>poi[1]){return false;}
3588
- if (e_poi[1]==poi[1] && s_poi[1]>poi[1]){return false;}
3589
- 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]);
3591
- if (xseg<poi[0]){
3592
- return false;
3593
- }else{
3594
- return true;
3595
- }
3788
+ function isRayIntersectsSegment(poi, s_poi, e_poi) {
3789
+ if (s_poi[1] == e_poi[1]) {
3790
+ return false;
3791
+ }
3792
+ if (s_poi[1] > poi[1] && e_poi[1] > poi[1]) {
3793
+ return false;
3794
+ }
3795
+ if (s_poi[1] < poi[1] && e_poi[1] < poi[1]) {
3796
+ return false;
3797
+ }
3798
+ if (s_poi[1] == poi[1] && e_poi[1] > poi[1]) {
3799
+ return false;
3800
+ }
3801
+ if (e_poi[1] == poi[1] && s_poi[1] > poi[1]) {
3802
+ return false;
3803
+ }
3804
+ if (s_poi[0] < poi[0] && e_poi[1] < poi[1]) {
3805
+ return false;
3806
+ }
3807
+ let xseg = e_poi[0] - ((e_poi[0] - s_poi[0]) * (e_poi[1] - poi[1])) / (e_poi[1] - s_poi[1]);
3808
+ if (xseg < poi[0]) {
3809
+ return false;
3810
+ } else {
3811
+ return true;
3812
+ }
3596
3813
  }
3597
3814
 
3598
- function isPoiWithinPoly(poi,poly){
3599
- let sinsc=0;
3600
- for (let i=0;i<poly.length;i++){
3601
- let epoly=poly[i][0];
3815
+ function isPoiWithinPoly(poi, poly) {
3816
+ let sinsc = 0;
3817
+ for (let i = 0; i < poly.length; i++) {
3818
+ let epoly = poly[i][0];
3602
3819
  if (poly.length == 1) {
3603
- epoly = poly[i][0]
3820
+ epoly = poly[i][0];
3604
3821
  }
3605
- for(let j=0;j<epoly.length-1;j++){
3606
- let s_poi=epoly[j];
3607
- let e_poi=epoly[j+1];
3608
- if (isRayIntersectsSegment(poi,s_poi,e_poi)){
3609
- sinsc+=1;
3822
+ for (let j = 0; j < epoly.length - 1; j++) {
3823
+ let s_poi = epoly[j];
3824
+ let e_poi = epoly[j + 1];
3825
+ if (isRayIntersectsSegment(poi, s_poi, e_poi)) {
3826
+ sinsc += 1;
3610
3827
  }
3611
3828
  }
3612
3829
  }
3613
3830
 
3614
- if(sinsc%2==1){
3831
+ if (sinsc % 2 == 1) {
3615
3832
  return true;
3616
- }else{
3833
+ } else {
3617
3834
  return false;
3618
3835
  }
3619
3836
  }
3620
3837
 
3621
-
3622
3838
  function drawMapDataPoints(series, opts, config, context) {
3623
- var mapOption=assign({},{
3624
- border:true,
3625
- borderWidth:1,
3626
- borderColor:'#666666',
3627
- fillOpacity:0.6,
3628
- activeBorderColor:'#f04864',
3629
- activeFillColor:'#facc14',
3630
- activeFillOpacity:1
3631
- },opts.extra.map);
3839
+ var mapOption = assign(
3840
+ {},
3841
+ {
3842
+ border: true,
3843
+ borderWidth: 1,
3844
+ borderColor: '#666666',
3845
+ fillOpacity: 0.6,
3846
+ activeBorderColor: '#f04864',
3847
+ activeFillColor: '#facc14',
3848
+ activeFillOpacity: 1
3849
+ },
3850
+ opts.extra.map
3851
+ );
3632
3852
  var coords, point;
3633
3853
  var data = series;
3634
- var bounds= getBoundingBox(data);
3854
+ var bounds = getBoundingBox(data);
3635
3855
  var xScale = opts.width / Math.abs(bounds.xMax - bounds.xMin);
3636
3856
  var yScale = opts.height / Math.abs(bounds.yMax - bounds.yMin);
3637
3857
  var scale = xScale < yScale ? xScale : yScale;
3638
- var xoffset=opts.width/2-Math.abs(bounds.xMax - bounds.xMin)/2*scale;
3639
- var yoffset=opts.height/2-Math.abs(bounds.yMax - bounds.yMin)/2*scale;
3858
+ var xoffset = opts.width / 2 - (Math.abs(bounds.xMax - bounds.xMin) / 2) * scale;
3859
+ var yoffset = opts.height / 2 - (Math.abs(bounds.yMax - bounds.yMin) / 2) * scale;
3640
3860
  context.beginPath();
3641
3861
  context.clearRect(0, 0, opts.width, opts.height);
3642
- context.setFillStyle(opts.background||'#FFFFFF');
3643
- context.rect(0,0,opts.width,opts.height);
3862
+ context.setFillStyle(opts.background || '#FFFFFF');
3863
+ context.rect(0, 0, opts.width, opts.height);
3644
3864
  context.fill();
3645
3865
  for (var i = 0; i < data.length; i++) {
3646
3866
  context.beginPath();
@@ -3648,19 +3868,19 @@ function drawMapDataPoints(series, opts, config, context) {
3648
3868
  context.setStrokeStyle(mapOption.borderColor);
3649
3869
  context.setFillStyle(hexToRgb(series[i].color, mapOption.fillOpacity));
3650
3870
  if (opts.tooltip) {
3651
- if (opts.tooltip.index == i ) {
3871
+ if (opts.tooltip.index == i) {
3652
3872
  context.setStrokeStyle(mapOption.activeBorderColor);
3653
3873
  context.setFillStyle(hexToRgb(mapOption.activeFillColor, mapOption.activeFillOpacity));
3654
3874
  }
3655
3875
  }
3656
- var coorda = data[i].geometry.coordinates
3876
+ var coorda = data[i].geometry.coordinates;
3657
3877
  for (var k = 0; k < coorda.length; k++) {
3658
3878
  coords = coorda[k];
3659
3879
  if (coords.length == 1) {
3660
- coords = coords[0]
3880
+ coords = coords[0];
3661
3881
  }
3662
3882
  for (var j = 0; j < coords.length; j++) {
3663
- point = coordinateToPoint(coords[j][1], coords[j][0],bounds,scale,xoffset,yoffset)
3883
+ point = coordinateToPoint(coords[j][1], coords[j][0], bounds, scale, xoffset, yoffset);
3664
3884
  if (j === 0) {
3665
3885
  context.beginPath();
3666
3886
  context.moveTo(point.x, point.y);
@@ -3669,207 +3889,269 @@ function drawMapDataPoints(series, opts, config, context) {
3669
3889
  }
3670
3890
  }
3671
3891
  context.fill();
3672
- if(mapOption.border == true){
3892
+ if (mapOption.border == true) {
3673
3893
  context.stroke();
3674
3894
  }
3675
3895
  }
3676
- if(opts.dataLabel == true){
3896
+ if (opts.dataLabel == true) {
3677
3897
  var centerPoint = data[i].properties.centroid;
3678
- if(centerPoint){
3679
- point = coordinateToPoint(centerPoint[1], centerPoint[0],bounds,scale,xoffset,yoffset);
3680
- let fontSize=data[i].textSize||config.fontSize;
3681
- let text=data[i].properties.name;
3898
+ if (centerPoint) {
3899
+ point = coordinateToPoint(centerPoint[1], centerPoint[0], bounds, scale, xoffset, yoffset);
3900
+ let fontSize = data[i].textSize || config.fontSize;
3901
+ let text = data[i].properties.name;
3682
3902
  context.beginPath();
3683
- context.setFontSize(fontSize)
3684
- context.setFillStyle(data[i].textColor||'#666666')
3685
- context.fillText(text, point.x-measureText(text,fontSize)/2, point.y+fontSize/2);
3903
+ context.setFontSize(fontSize);
3904
+ context.setFillStyle(data[i].textColor || '#666666');
3905
+ context.fillText(text, point.x - measureText(text, fontSize) / 2, point.y + fontSize / 2);
3686
3906
  context.closePath();
3687
3907
  context.stroke();
3688
3908
  }
3689
3909
  }
3690
3910
  }
3691
- opts.chartData.mapData={
3692
- bounds:bounds,
3693
- scale:scale,
3694
- xoffset:xoffset,
3695
- yoffset:yoffset
3696
- }
3697
- drawToolTipBridge(opts, config, context,1);
3911
+ opts.chartData.mapData = {
3912
+ bounds: bounds,
3913
+ scale: scale,
3914
+ xoffset: xoffset,
3915
+ yoffset: yoffset
3916
+ };
3917
+ drawToolTipBridge(opts, config, context, 1);
3698
3918
  context.draw();
3699
3919
  }
3700
3920
 
3701
- function getWordCloudPoint(opts,type){
3702
- let points = opts.series.sort(function(a,b){return parseInt(b.textSize)-parseInt(a.textSize);});
3921
+ function getWordCloudPoint(opts, type) {
3922
+ let points = opts.series.sort(function (a, b) {
3923
+ return parseInt(b.textSize) - parseInt(a.textSize);
3924
+ });
3703
3925
  switch (type) {
3704
3926
  case 'normal':
3705
3927
  for (let i = 0; i < points.length; i++) {
3706
3928
  let text = points[i].name;
3707
3929
  let tHeight = points[i].textSize;
3708
- let tWidth = measureText(text,tHeight);
3709
- let x,y;
3930
+ let tWidth = measureText(text, tHeight);
3931
+ let x, y;
3710
3932
  let area;
3711
- let breaknum=0;
3712
- while(true) {
3713
- breaknum++;
3714
- x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2;
3715
- y = normalInt(-opts.height/2, opts.height/2,5) + tHeight/2;
3716
- area=[x-5+opts.width/2,y-5-tHeight+opts.height/2,x+tWidth+5+opts.width/2,y+5+opts.height/2];
3717
- let isCollision = collisionNew(area,points,opts.width,opts.height);
3718
- if (!isCollision) break;
3719
- if (breaknum==1000){
3720
- area=[-100,-100,-100,-100];
3721
- break;
3722
- }
3723
- };
3724
- points[i].area=area;
3933
+ let breaknum = 0;
3934
+ while (true) {
3935
+ breaknum++;
3936
+ x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
3937
+ y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
3938
+ area = [
3939
+ x - 5 + opts.width / 2,
3940
+ y - 5 - tHeight + opts.height / 2,
3941
+ x + tWidth + 5 + opts.width / 2,
3942
+ y + 5 + opts.height / 2
3943
+ ];
3944
+ let isCollision = collisionNew(area, points, opts.width, opts.height);
3945
+ if (!isCollision) break;
3946
+ if (breaknum == 1000) {
3947
+ area = [-100, -100, -100, -100];
3948
+ break;
3949
+ }
3950
+ }
3951
+ points[i].area = area;
3725
3952
  }
3726
- break;
3953
+ break;
3727
3954
  case 'vertical':
3728
- function Spin(){
3955
+ function Spin() {
3729
3956
  //获取均匀随机值,是否旋转,旋转的概率为(1-0.5)
3730
- if (Math.random()>0.7) {
3731
- return true;
3732
- }else {return false};
3733
- };
3957
+ if (Math.random() > 0.7) {
3958
+ return true;
3959
+ } else {
3960
+ return false;
3961
+ }
3962
+ }
3734
3963
  for (let i = 0; i < points.length; i++) {
3735
3964
  let text = points[i].name;
3736
3965
  let tHeight = points[i].textSize;
3737
- let tWidth = measureText(text,tHeight);
3966
+ let tWidth = measureText(text, tHeight);
3738
3967
  let isSpin = Spin();
3739
- let x,y,area,areav;
3740
- let breaknum=0;
3741
- while(true) {
3968
+ let x, y, area, areav;
3969
+ let breaknum = 0;
3970
+ while (true) {
3742
3971
  breaknum++;
3743
3972
  let isCollision;
3744
3973
  if (isSpin) {
3745
- x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2;
3746
- y = normalInt(-opts.height/2, opts.height/2,5)+tHeight/2;
3747
- area=[y-5-tWidth+opts.width/2,(-x-5+opts.height/2),y+5+opts.width/2,(-x+tHeight+5+opts.height/2)];
3748
- areav=[opts.width-(opts.width/2-opts.height/2)-(-x+tHeight+5+opts.height/2)-5,(opts.height/2-opts.width/2)+(y-5-tWidth+opts.width/2)-5,opts.width-(opts.width/2-opts.height/2)-(-x+tHeight+5+opts.height/2)+tHeight,(opts.height/2-opts.width/2)+(y-5-tWidth+opts.width/2)+tWidth+5];
3749
- isCollision = collisionNew(areav,points,opts.height,opts.width);
3750
- }else{
3751
- x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2;
3752
- y = normalInt(-opts.height/2, opts.height/2,5)+tHeight/2;
3753
- area=[x-5+opts.width/2,y-5-tHeight+opts.height/2,x+tWidth+5+opts.width/2,y+5+opts.height/2];
3754
- isCollision = collisionNew(area,points,opts.width,opts.height);
3974
+ x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
3975
+ y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
3976
+ area = [
3977
+ y - 5 - tWidth + opts.width / 2,
3978
+ -x - 5 + opts.height / 2,
3979
+ y + 5 + opts.width / 2,
3980
+ -x + tHeight + 5 + opts.height / 2
3981
+ ];
3982
+ areav = [
3983
+ opts.width - (opts.width / 2 - opts.height / 2) - (-x + tHeight + 5 + opts.height / 2) - 5,
3984
+ opts.height / 2 - opts.width / 2 + (y - 5 - tWidth + opts.width / 2) - 5,
3985
+ opts.width - (opts.width / 2 - opts.height / 2) - (-x + tHeight + 5 + opts.height / 2) + tHeight,
3986
+ opts.height / 2 - opts.width / 2 + (y - 5 - tWidth + opts.width / 2) + tWidth + 5
3987
+ ];
3988
+ isCollision = collisionNew(areav, points, opts.height, opts.width);
3989
+ } else {
3990
+ x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
3991
+ y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
3992
+ area = [
3993
+ x - 5 + opts.width / 2,
3994
+ y - 5 - tHeight + opts.height / 2,
3995
+ x + tWidth + 5 + opts.width / 2,
3996
+ y + 5 + opts.height / 2
3997
+ ];
3998
+ isCollision = collisionNew(area, points, opts.width, opts.height);
3755
3999
  }
3756
4000
  if (!isCollision) break;
3757
- if (breaknum==1000){
3758
- area=[-1000,-1000,-1000,-1000];
4001
+ if (breaknum == 1000) {
4002
+ area = [-1000, -1000, -1000, -1000];
3759
4003
  break;
3760
4004
  }
3761
- };
4005
+ }
3762
4006
  if (isSpin) {
3763
- points[i].area=areav;
3764
- points[i].areav=area;
3765
- }else{
3766
- points[i].area=area;
4007
+ points[i].area = areav;
4008
+ points[i].areav = area;
4009
+ } else {
4010
+ points[i].area = area;
3767
4011
  }
3768
- points[i].rotate=isSpin;
3769
- };
3770
- break;
4012
+ points[i].rotate = isSpin;
4013
+ }
4014
+ break;
3771
4015
  }
3772
4016
  return points;
3773
4017
  }
3774
4018
 
3775
-
3776
4019
  function drawWordCloudDataPoints(series, opts, config, context) {
3777
4020
  let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
3778
- let wordOption = assign({},{
3779
- type: 'normal',
3780
- autoColors: true
3781
- },opts.extra.word);
4021
+ let wordOption = assign(
4022
+ {},
4023
+ {
4024
+ type: 'normal',
4025
+ autoColors: true
4026
+ },
4027
+ opts.extra.word
4028
+ );
3782
4029
 
3783
4030
  context.beginPath();
3784
- context.setFillStyle(opts.background||'#FFFFFF');
3785
- context.rect(0,0,opts.width,opts.height);
4031
+ context.setFillStyle(opts.background || '#FFFFFF');
4032
+ context.rect(0, 0, opts.width, opts.height);
3786
4033
  context.fill();
3787
4034
  context.save();
3788
4035
  let points = opts.chartData.wordCloudData;
3789
- context.translate(opts.width/2,opts.height/2);
4036
+ context.translate(opts.width / 2, opts.height / 2);
3790
4037
 
3791
- for(let i=0;i<points.length;i++){
3792
- context.save();
3793
- if(points[i].rotate){
3794
- context.rotate(90 * Math.PI / 180);
3795
- }
3796
- let text = points[i].name;
3797
- let tHeight = points[i].textSize;
3798
- let tWidth = measureText(text,tHeight);
3799
- context.beginPath();
3800
- context.setStrokeStyle(points[i].color);
3801
- context.setFillStyle(points[i].color);
3802
- context.setFontSize(tHeight);
3803
- if(points[i].rotate){
3804
- if(points[i].areav[0]>0){
3805
- if (opts.tooltip) {
3806
- if (opts.tooltip.index == i) {
3807
- context.strokeText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process);
3808
- }else{
3809
- 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);
3810
- }
3811
- }else{
3812
- 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);
4038
+ for (let i = 0; i < points.length; i++) {
4039
+ context.save();
4040
+ if (points[i].rotate) {
4041
+ context.rotate((90 * Math.PI) / 180);
4042
+ }
4043
+ let text = points[i].name;
4044
+ let tHeight = points[i].textSize;
4045
+ let tWidth = measureText(text, tHeight);
4046
+ context.beginPath();
4047
+ context.setStrokeStyle(points[i].color);
4048
+ context.setFillStyle(points[i].color);
4049
+ context.setFontSize(tHeight);
4050
+ if (points[i].rotate) {
4051
+ if (points[i].areav[0] > 0) {
4052
+ if (opts.tooltip) {
4053
+ if (opts.tooltip.index == i) {
4054
+ context.strokeText(
4055
+ text,
4056
+ (points[i].areav[0] + 5 - opts.width / 2) * process - (tWidth * (1 - process)) / 2,
4057
+ (points[i].areav[1] + 5 + tHeight - opts.height / 2) * process
4058
+ );
4059
+ } else {
4060
+ context.fillText(
4061
+ text,
4062
+ (points[i].areav[0] + 5 - opts.width / 2) * process - (tWidth * (1 - process)) / 2,
4063
+ (points[i].areav[1] + 5 + tHeight - opts.height / 2) * process
4064
+ );
3813
4065
  }
4066
+ } else {
4067
+ context.fillText(
4068
+ text,
4069
+ (points[i].areav[0] + 5 - opts.width / 2) * process - (tWidth * (1 - process)) / 2,
4070
+ (points[i].areav[1] + 5 + tHeight - opts.height / 2) * process
4071
+ );
3814
4072
  }
3815
- }else{
3816
- if(points[i].area[0]>0){
3817
- if (opts.tooltip) {
3818
- if (opts.tooltip.index == i) {
3819
- context.strokeText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process);
3820
- }else{
3821
- 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);
3822
- }
3823
- }else{
3824
- 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);
4073
+ }
4074
+ } else {
4075
+ if (points[i].area[0] > 0) {
4076
+ if (opts.tooltip) {
4077
+ if (opts.tooltip.index == i) {
4078
+ context.strokeText(
4079
+ text,
4080
+ (points[i].area[0] + 5 - opts.width / 2) * process - (tWidth * (1 - process)) / 2,
4081
+ (points[i].area[1] + 5 + tHeight - opts.height / 2) * process
4082
+ );
4083
+ } else {
4084
+ context.fillText(
4085
+ text,
4086
+ (points[i].area[0] + 5 - opts.width / 2) * process - (tWidth * (1 - process)) / 2,
4087
+ (points[i].area[1] + 5 + tHeight - opts.height / 2) * process
4088
+ );
3825
4089
  }
3826
-
4090
+ } else {
4091
+ context.fillText(
4092
+ text,
4093
+ (points[i].area[0] + 5 - opts.width / 2) * process - (tWidth * (1 - process)) / 2,
4094
+ (points[i].area[1] + 5 + tHeight - opts.height / 2) * process
4095
+ );
3827
4096
  }
3828
4097
  }
4098
+ }
3829
4099
 
3830
- context.stroke();
3831
- context.restore();
4100
+ context.stroke();
4101
+ context.restore();
3832
4102
  }
3833
4103
  context.restore();
3834
4104
  }
3835
4105
 
3836
4106
  function drawFunnelDataPoints(series, opts, config, context) {
3837
4107
  let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
3838
- let funnelOption = assign({},{
3839
- activeWidth:10,
3840
- activeOpacity:0.3,
3841
- border:false,
3842
- borderWidth:2,
3843
- borderColor:'#FFFFFF',
3844
- fillOpacity:1,
3845
- labelAlign:'right'
3846
- },opts.extra.funnel);
3847
- let eachSpacing = (opts.height - opts.area[0] - opts.area[2])/series.length;
4108
+ let funnelOption = assign(
4109
+ {},
4110
+ {
4111
+ activeWidth: 10,
4112
+ activeOpacity: 0.3,
4113
+ border: false,
4114
+ borderWidth: 2,
4115
+ borderColor: '#FFFFFF',
4116
+ fillOpacity: 1,
4117
+ labelAlign: 'right'
4118
+ },
4119
+ opts.extra.funnel
4120
+ );
4121
+ let eachSpacing = (opts.height - opts.area[0] - opts.area[2]) / series.length;
3848
4122
  let centerPosition = {
3849
4123
  x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
3850
- y: opts.height-opts.area[2]
4124
+ y: opts.height - opts.area[2]
3851
4125
  };
3852
4126
  let activeWidth = funnelOption.activeWidth;
3853
- let radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - activeWidth, (opts.height - opts.area[0] - opts.area[2]) / 2 - activeWidth);
4127
+ let radius = Math.min(
4128
+ (opts.width - opts.area[1] - opts.area[3]) / 2 - activeWidth,
4129
+ (opts.height - opts.area[0] - opts.area[2]) / 2 - activeWidth
4130
+ );
3854
4131
  series = getFunnelDataPoints(series, radius, process);
3855
4132
  context.save();
3856
- context.translate(centerPosition.x,centerPosition.y);
3857
- for(let i=0;i<series.length;i++){
3858
- if(i==0){
4133
+ context.translate(centerPosition.x, centerPosition.y);
4134
+ for (let i = 0; i < series.length; i++) {
4135
+ if (i == 0) {
3859
4136
  if (opts.tooltip) {
3860
4137
  if (opts.tooltip.index == i) {
3861
4138
  context.beginPath();
3862
4139
  context.setFillStyle(hexToRgb(series[i].color, funnelOption.activeOpacity));
3863
4140
  context.moveTo(-activeWidth, 0);
3864
- context.lineTo(-series[i].radius-activeWidth, -eachSpacing);
3865
- context.lineTo(series[i].radius+activeWidth, -eachSpacing);
4141
+ context.lineTo(-series[i].radius - activeWidth, -eachSpacing);
4142
+ context.lineTo(series[i].radius + activeWidth, -eachSpacing);
3866
4143
  context.lineTo(activeWidth, 0);
3867
4144
  context.lineTo(-activeWidth, 0);
3868
4145
  context.closePath();
3869
4146
  context.fill();
3870
4147
  }
3871
4148
  }
3872
- series[i].funnelArea=[centerPosition.x-series[i].radius,centerPosition.y-eachSpacing,centerPosition.x+series[i].radius,centerPosition.y];
4149
+ series[i].funnelArea = [
4150
+ centerPosition.x - series[i].radius,
4151
+ centerPosition.y - eachSpacing,
4152
+ centerPosition.x + series[i].radius,
4153
+ centerPosition.y
4154
+ ];
3873
4155
  context.beginPath();
3874
4156
  context.setLineWidth(funnelOption.borderWidth * opts.pixelRatio);
3875
4157
  context.setStrokeStyle(funnelOption.borderColor);
@@ -3880,19 +4162,19 @@ function drawFunnelDataPoints(series, opts, config, context) {
3880
4162
  context.lineTo(0, 0);
3881
4163
  context.closePath();
3882
4164
  context.fill();
3883
- if(funnelOption.border == true){
4165
+ if (funnelOption.border == true) {
3884
4166
  context.stroke();
3885
4167
  }
3886
- }else{
4168
+ } else {
3887
4169
  if (opts.tooltip) {
3888
4170
  if (opts.tooltip.index == i) {
3889
4171
  context.beginPath();
3890
4172
  context.setFillStyle(hexToRgb(series[i].color, funnelOption.activeOpacity));
3891
4173
  context.moveTo(0, 0);
3892
- context.lineTo(-series[i-1].radius-activeWidth, 0);
3893
- context.lineTo(-series[i].radius-activeWidth, -eachSpacing);
3894
- context.lineTo(series[i].radius+activeWidth, -eachSpacing);
3895
- context.lineTo(series[i-1].radius+activeWidth, 0);
4174
+ context.lineTo(-series[i - 1].radius - activeWidth, 0);
4175
+ context.lineTo(-series[i].radius - activeWidth, -eachSpacing);
4176
+ context.lineTo(series[i].radius + activeWidth, -eachSpacing);
4177
+ context.lineTo(series[i - 1].radius + activeWidth, 0);
3896
4178
  context.lineTo(0, 0);
3897
4179
  context.closePath();
3898
4180
  context.fill();
@@ -3900,24 +4182,29 @@ function drawFunnelDataPoints(series, opts, config, context) {
3900
4182
  context.fill();
3901
4183
  }
3902
4184
  }
3903
- series[i].funnelArea=[centerPosition.x-series[i].radius,centerPosition.y-eachSpacing*(i+1),centerPosition.x+series[i].radius,centerPosition.y-eachSpacing*i];
4185
+ series[i].funnelArea = [
4186
+ centerPosition.x - series[i].radius,
4187
+ centerPosition.y - eachSpacing * (i + 1),
4188
+ centerPosition.x + series[i].radius,
4189
+ centerPosition.y - eachSpacing * i
4190
+ ];
3904
4191
  context.beginPath();
3905
4192
  context.setLineWidth(funnelOption.borderWidth * opts.pixelRatio);
3906
4193
  context.setStrokeStyle(funnelOption.borderColor);
3907
4194
  context.setFillStyle(hexToRgb(series[i].color, funnelOption.fillOpacity));
3908
4195
  context.moveTo(0, 0);
3909
- context.lineTo(-series[i-1].radius, 0);
4196
+ context.lineTo(-series[i - 1].radius, 0);
3910
4197
  context.lineTo(-series[i].radius, -eachSpacing);
3911
4198
  context.lineTo(series[i].radius, -eachSpacing);
3912
- context.lineTo(series[i-1].radius, 0);
4199
+ context.lineTo(series[i - 1].radius, 0);
3913
4200
  context.lineTo(0, 0);
3914
4201
  context.closePath();
3915
4202
  context.fill();
3916
- if(funnelOption.border == true){
4203
+ if (funnelOption.border == true) {
3917
4204
  context.stroke();
3918
4205
  }
3919
4206
  }
3920
- context.translate(0,-eachSpacing)
4207
+ context.translate(0, -eachSpacing);
3921
4208
  }
3922
4209
  context.restore();
3923
4210
 
@@ -3932,26 +4219,26 @@ function drawFunnelDataPoints(series, opts, config, context) {
3932
4219
  };
3933
4220
  }
3934
4221
 
3935
- function drawFunnelText(series, opts, context, eachSpacing, labelAlign,activeWidth, centerPosition){
3936
- for(let i=0;i<series.length;i++){
4222
+ function drawFunnelText(series, opts, context, eachSpacing, labelAlign, activeWidth, centerPosition) {
4223
+ for (let i = 0; i < series.length; i++) {
3937
4224
  let item = series[i];
3938
- let startX,endX,startY,fontSize;
3939
- let text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_ * 100) +'%';
3940
- if(labelAlign == 'right'){
3941
- if(i==0){
3942
- startX=(item.funnelArea[2]+centerPosition.x)/2;
3943
- }else{
3944
- startX=(item.funnelArea[2]+series[i-1].funnelArea[2])/2;
4225
+ let startX, endX, startY, fontSize;
4226
+ let text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_ * 100) + '%';
4227
+ if (labelAlign == 'right') {
4228
+ if (i == 0) {
4229
+ startX = (item.funnelArea[2] + centerPosition.x) / 2;
4230
+ } else {
4231
+ startX = (item.funnelArea[2] + series[i - 1].funnelArea[2]) / 2;
3945
4232
  }
3946
- endX=startX+activeWidth*2;
3947
- startY=item.funnelArea[1]+eachSpacing/2;
4233
+ endX = startX + activeWidth * 2;
4234
+ startY = item.funnelArea[1] + eachSpacing / 2;
3948
4235
  fontSize = item.textSize || opts.fontSize;
3949
4236
  context.setLineWidth(1 * opts.pixelRatio);
3950
4237
  context.setStrokeStyle(item.color);
3951
4238
  context.setFillStyle(item.color);
3952
4239
  context.beginPath();
3953
- context.moveTo(startX,startY );
3954
- context.lineTo(endX,startY);
4240
+ context.moveTo(startX, startY);
4241
+ context.lineTo(endX, startY);
3955
4242
  context.stroke();
3956
4243
  context.closePath();
3957
4244
  context.beginPath();
@@ -3962,25 +4249,25 @@ function drawFunnelText(series, opts, context, eachSpacing, labelAlign,activeWid
3962
4249
  context.beginPath();
3963
4250
  context.setFontSize(fontSize);
3964
4251
  context.setFillStyle(item.textColor || '#666666');
3965
- context.fillText(text, endX+5, startY + fontSize/2 -2);
4252
+ context.fillText(text, endX + 5, startY + fontSize / 2 - 2);
3966
4253
  context.closePath();
3967
4254
  context.stroke();
3968
4255
  context.closePath();
3969
- }else{
3970
- if(i==0){
3971
- startX=(item.funnelArea[0]+centerPosition.x)/2;
3972
- }else{
3973
- startX=(item.funnelArea[0]+series[i-1].funnelArea[0])/2;
4256
+ } else {
4257
+ if (i == 0) {
4258
+ startX = (item.funnelArea[0] + centerPosition.x) / 2;
4259
+ } else {
4260
+ startX = (item.funnelArea[0] + series[i - 1].funnelArea[0]) / 2;
3974
4261
  }
3975
- endX=startX-activeWidth*2;
3976
- startY=item.funnelArea[1]+eachSpacing/2;
4262
+ endX = startX - activeWidth * 2;
4263
+ startY = item.funnelArea[1] + eachSpacing / 2;
3977
4264
  fontSize = item.textSize || opts.fontSize;
3978
4265
  context.setLineWidth(1 * opts.pixelRatio);
3979
4266
  context.setStrokeStyle(item.color);
3980
4267
  context.setFillStyle(item.color);
3981
4268
  context.beginPath();
3982
- context.moveTo(startX,startY );
3983
- context.lineTo(endX,startY);
4269
+ context.moveTo(startX, startY);
4270
+ context.lineTo(endX, startY);
3984
4271
  context.stroke();
3985
4272
  context.closePath();
3986
4273
  context.beginPath();
@@ -3991,16 +4278,14 @@ function drawFunnelText(series, opts, context, eachSpacing, labelAlign,activeWid
3991
4278
  context.beginPath();
3992
4279
  context.setFontSize(fontSize);
3993
4280
  context.setFillStyle(item.textColor || '#666666');
3994
- context.fillText(text, endX-5-measureText(text), startY + fontSize/2 -2);
4281
+ context.fillText(text, endX - 5 - measureText(text), startY + fontSize / 2 - 2);
3995
4282
  context.closePath();
3996
4283
  context.stroke();
3997
4284
  context.closePath();
3998
4285
  }
3999
-
4000
4286
  }
4001
4287
  }
4002
4288
 
4003
-
4004
4289
  function drawCanvas(opts, context) {
4005
4290
  context.draw();
4006
4291
  }
@@ -4032,8 +4317,8 @@ function Animation(opts) {
4032
4317
 
4033
4318
  function createAnimationFrame() {
4034
4319
  if (typeof setTimeout !== 'undefined') {
4035
- return function(step, delay) {
4036
- setTimeout(function() {
4320
+ return function (step, delay) {
4321
+ setTimeout(function () {
4037
4322
  var timeStamp = +new Date();
4038
4323
  step(timeStamp);
4039
4324
  }, delay);
@@ -4041,11 +4326,11 @@ function Animation(opts) {
4041
4326
  } else if (typeof requestAnimationFrame !== 'undefined') {
4042
4327
  return requestAnimationFrame;
4043
4328
  } else {
4044
- return function(step) {
4329
+ return function (step) {
4045
4330
  step(null);
4046
4331
  };
4047
4332
  }
4048
- };
4333
+ }
4049
4334
  var animationFrame = createAnimationFrame();
4050
4335
  var startTimeStamp = null;
4051
4336
  var _step = function step(timestamp) {
@@ -4075,7 +4360,7 @@ function Animation(opts) {
4075
4360
 
4076
4361
  // stop animation immediately
4077
4362
  // and tigger onAnimationFinish
4078
- Animation.prototype.stop = function() {
4363
+ Animation.prototype.stop = function () {
4079
4364
  this.isStop = true;
4080
4365
  };
4081
4366
 
@@ -4134,7 +4419,8 @@ function drawCharts(type, opts, config, context) {
4134
4419
  break;
4135
4420
  }
4136
4421
 
4137
- let _calYAxisData = {},yAxisWidth = 0;
4422
+ let _calYAxisData = {},
4423
+ yAxisWidth = 0;
4138
4424
  if (opts.type === 'line' || opts.type === 'column' || opts.type === 'area' || opts.type === 'mix' || opts.type === 'candle') {
4139
4425
  _calYAxisData = calYAxisData(series, opts, config);
4140
4426
  yAxisWidth = _calYAxisData.yAxisWidth;
@@ -4181,38 +4467,42 @@ function drawCharts(type, opts, config, context) {
4181
4467
 
4182
4468
  switch (type) {
4183
4469
  case 'word':
4184
- let wordOption = assign({},{
4185
- type: 'normal',
4186
- autoColors: true
4187
- },opts.extra.word);
4188
- if(opts.updateData==true || opts.updateData==undefined){
4189
- opts.chartData.wordCloudData=getWordCloudPoint(opts,wordOption.type);
4470
+ let wordOption = assign(
4471
+ {},
4472
+ {
4473
+ type: 'normal',
4474
+ autoColors: true
4475
+ },
4476
+ opts.extra.word
4477
+ );
4478
+ if (opts.updateData == true || opts.updateData == undefined) {
4479
+ opts.chartData.wordCloudData = getWordCloudPoint(opts, wordOption.type);
4190
4480
  }
4191
4481
  this.animationInstance = new Animation({
4192
4482
  timing: 'easeInOut',
4193
4483
  duration: duration,
4194
- onProcess: function(process) {
4484
+ onProcess: function (process) {
4195
4485
  context.clearRect(0, 0, opts.width, opts.height);
4196
4486
  if (opts.rotate) {
4197
4487
  contextRotate(context, opts);
4198
4488
  }
4199
- drawWordCloudDataPoints(series, opts, config, context,process);
4489
+ drawWordCloudDataPoints(series, opts, config, context, process);
4200
4490
  drawCanvas(opts, context);
4201
4491
  },
4202
4492
  onAnimationFinish: function onAnimationFinish() {
4203
4493
  _this.event.trigger('renderComplete');
4204
4494
  }
4205
4495
  });
4206
- break;
4496
+ break;
4207
4497
  case 'map':
4208
4498
  context.clearRect(0, 0, opts.width, opts.height);
4209
4499
  drawMapDataPoints(series, opts, config, context);
4210
- break;
4500
+ break;
4211
4501
  case 'funnel':
4212
4502
  this.animationInstance = new Animation({
4213
4503
  timing: 'easeInOut',
4214
4504
  duration: duration,
4215
- onProcess: function(process) {
4505
+ onProcess: function (process) {
4216
4506
  context.clearRect(0, 0, opts.width, opts.height);
4217
4507
  if (opts.rotate) {
4218
4508
  contextRotate(context, opts);
@@ -4226,7 +4516,7 @@ function drawCharts(type, opts, config, context) {
4226
4516
  _this.event.trigger('renderComplete');
4227
4517
  }
4228
4518
  });
4229
- break;
4519
+ break;
4230
4520
  case 'line':
4231
4521
  this.animationInstance = new Animation({
4232
4522
  timing: 'easeIn',
@@ -4254,7 +4544,6 @@ function drawCharts(type, opts, config, context) {
4254
4544
  drawLegend(opts.series, opts, config, context, opts.chartData);
4255
4545
  drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints);
4256
4546
  drawCanvas(opts, context);
4257
-
4258
4547
  },
4259
4548
  onAnimationFinish: function onAnimationFinish() {
4260
4549
  _this.event.trigger('renderComplete');
@@ -4498,12 +4787,12 @@ function Event() {
4498
4787
  this.events = {};
4499
4788
  }
4500
4789
 
4501
- Event.prototype.addEventListener = function(type, listener) {
4790
+ Event.prototype.addEventListener = function (type, listener) {
4502
4791
  this.events[type] = this.events[type] || [];
4503
4792
  this.events[type].push(listener);
4504
4793
  };
4505
4794
 
4506
- Event.prototype.trigger = function() {
4795
+ Event.prototype.trigger = function () {
4507
4796
  for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
4508
4797
  args[_key] = arguments[_key];
4509
4798
  }
@@ -4511,7 +4800,7 @@ Event.prototype.trigger = function() {
4511
4800
  var type = args[0];
4512
4801
  var params = args.slice(1);
4513
4802
  if (!!this.events[type]) {
4514
- this.events[type].forEach(function(listener) {
4803
+ this.events[type].forEach(function (listener) {
4515
4804
  try {
4516
4805
  listener.apply(null, params);
4517
4806
  } catch (e) {
@@ -4527,34 +4816,46 @@ var Charts = function Charts(opts) {
4527
4816
  opts.title = assign({}, opts.title);
4528
4817
  opts.subtitle = assign({}, opts.subtitle);
4529
4818
  opts.duration = opts.duration ? opts.duration : 1000;
4530
- opts.yAxis = assign({}, {
4531
- gridType: 'solid',
4532
- dashLength: 4 * opts.pixelRatio
4533
- }, opts.yAxis);
4534
- opts.xAxis = assign({}, {
4535
- rotateLabel: false,
4536
- type: 'calibration',
4537
- gridType: 'solid',
4538
- dashLength: 4 * opts.pixelRatio,
4539
- scrollAlign: 'left',
4540
- boundaryGap:'center'
4541
- }, opts.xAxis);
4542
- opts.legend = assign({}, {
4543
- show: true,
4544
- position: 'bottom',
4545
- float: 'center',
4546
- backgroundColor: 'rgba(0,0,0,0)',
4547
- borderColor: 'rgba(0,0,0,0)',
4548
- borderWidth: 0,
4549
- padding: 5,
4550
- margin: 5,
4551
- itemGap: 10,
4552
- fontSize: opts.fontSize,
4553
- lineHeight: opts.fontSize,
4554
- fontColor: '#333333',
4555
- format: {},
4556
- hiddenColor: '#CECECE'
4557
- }, opts.legend);
4819
+ opts.yAxis = assign(
4820
+ {},
4821
+ {
4822
+ gridType: 'solid',
4823
+ dashLength: 4 * opts.pixelRatio
4824
+ },
4825
+ opts.yAxis
4826
+ );
4827
+ opts.xAxis = assign(
4828
+ {},
4829
+ {
4830
+ rotateLabel: false,
4831
+ type: 'calibration',
4832
+ gridType: 'solid',
4833
+ dashLength: 4 * opts.pixelRatio,
4834
+ scrollAlign: 'left',
4835
+ boundaryGap: 'center'
4836
+ },
4837
+ opts.xAxis
4838
+ );
4839
+ opts.legend = assign(
4840
+ {},
4841
+ {
4842
+ show: true,
4843
+ position: 'bottom',
4844
+ float: 'center',
4845
+ backgroundColor: 'rgba(0,0,0,0)',
4846
+ borderColor: 'rgba(0,0,0,0)',
4847
+ borderWidth: 0,
4848
+ padding: 5,
4849
+ margin: 5,
4850
+ itemGap: 10,
4851
+ fontSize: opts.fontSize,
4852
+ lineHeight: opts.fontSize,
4853
+ fontColor: '#333333',
4854
+ format: {},
4855
+ hiddenColor: '#CECECE'
4856
+ },
4857
+ opts.legend
4858
+ );
4558
4859
  opts.legend.borderWidth = opts.legend.borderWidth * opts.pixelRatio;
4559
4860
  opts.legend.itemGap = opts.legend.itemGap * opts.pixelRatio;
4560
4861
  opts.legend.padding = opts.legend.padding * opts.pixelRatio;
@@ -4567,10 +4868,16 @@ var Charts = function Charts(opts) {
4567
4868
  config$$1.colors = opts.colors ? opts.colors : config$$1.colors;
4568
4869
  config$$1.yAxisTitleWidth = opts.yAxis.disabled !== true && opts.yAxis.title ? config$$1.yAxisTitleWidth : 0;
4569
4870
  if (opts.type == 'pie' || opts.type == 'ring') {
4570
- config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.pie.labelWidth * opts.pixelRatio || config$$1.pieChartLinePadding * opts.pixelRatio;
4871
+ config$$1.pieChartLinePadding =
4872
+ opts.dataLabel === false
4873
+ ? 0
4874
+ : opts.extra.pie.labelWidth * opts.pixelRatio || config$$1.pieChartLinePadding * opts.pixelRatio;
4571
4875
  }
4572
4876
  if (opts.type == 'rose') {
4573
- config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.rose.labelWidth * opts.pixelRatio || config$$1.pieChartLinePadding * opts.pixelRatio;
4877
+ config$$1.pieChartLinePadding =
4878
+ opts.dataLabel === false
4879
+ ? 0
4880
+ : opts.extra.rose.labelWidth * opts.pixelRatio || config$$1.pieChartLinePadding * opts.pixelRatio;
4574
4881
  }
4575
4882
  config$$1.pieChartTextPadding = opts.dataLabel === false ? 0 : config$$1.pieChartTextPadding * opts.pixelRatio;
4576
4883
  config$$1.yAxisSplit = opts.yAxis.splitNumber ? opts.yAxis.splitNumber : config.yAxisSplit;
@@ -4630,7 +4937,7 @@ var Charts = function Charts(opts) {
4630
4937
  drawCharts.call(this, opts.type, opts, config$$1, this.context);
4631
4938
  };
4632
4939
 
4633
- Charts.prototype.updateData = function() {
4940
+ Charts.prototype.updateData = function () {
4634
4941
  let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4635
4942
  this.opts = assign({}, this.opts, data);
4636
4943
  this.opts.updateData = true;
@@ -4673,15 +4980,16 @@ Charts.prototype.updateData = function() {
4673
4980
  drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
4674
4981
  };
4675
4982
 
4676
- Charts.prototype.zoom = function() {
4983
+ Charts.prototype.zoom = function () {
4677
4984
  var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.opts.xAxis.itemCount;
4678
4985
  if (this.opts.enableScroll !== true) {
4679
- console.log('请启用滚动条后使用!')
4986
+ console.log('请启用滚动条后使用!');
4680
4987
  return;
4681
4988
  }
4682
4989
  //当前屏幕中间点
4683
- let centerPoint = Math.round(Math.abs(this.scrollOption.currentOffset) / this.opts.chartData.eachSpacing) + Math.round(
4684
- this.opts.xAxis.itemCount / 2);
4990
+ let centerPoint =
4991
+ Math.round(Math.abs(this.scrollOption.currentOffset) / this.opts.chartData.eachSpacing) +
4992
+ Math.round(this.opts.xAxis.itemCount / 2);
4685
4993
  this.opts.animation = false;
4686
4994
  this.opts.xAxis.itemCount = val.itemCount;
4687
4995
  //重新计算x轴偏移距离
@@ -4714,15 +5022,15 @@ Charts.prototype.zoom = function() {
4714
5022
  drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
4715
5023
  };
4716
5024
 
4717
- Charts.prototype.stopAnimation = function() {
5025
+ Charts.prototype.stopAnimation = function () {
4718
5026
  this.animationInstance && this.animationInstance.stop();
4719
5027
  };
4720
5028
 
4721
- Charts.prototype.addEventListener = function(type, listener) {
5029
+ Charts.prototype.addEventListener = function (type, listener) {
4722
5030
  this.event.addEventListener(type, listener);
4723
5031
  };
4724
5032
 
4725
- Charts.prototype.getCurrentDataIndex = function(e) {
5033
+ Charts.prototype.getCurrentDataIndex = function (e) {
4726
5034
  var touches = null;
4727
5035
  if (e.changedTouches) {
4728
5036
  touches = e.changedTouches[0];
@@ -4732,41 +5040,63 @@ Charts.prototype.getCurrentDataIndex = function(e) {
4732
5040
  if (touches) {
4733
5041
  let _touches$ = getTouches(touches, this.opts, e);
4734
5042
  if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose') {
4735
- return findPieChartCurrentIndex({
4736
- x: _touches$.x,
4737
- y: _touches$.y
4738
- }, this.opts.chartData.pieData);
5043
+ return findPieChartCurrentIndex(
5044
+ {
5045
+ x: _touches$.x,
5046
+ y: _touches$.y
5047
+ },
5048
+ this.opts.chartData.pieData
5049
+ );
4739
5050
  } else if (this.opts.type === 'radar') {
4740
- return findRadarChartCurrentIndex({
4741
- x: _touches$.x,
4742
- y: _touches$.y
4743
- }, this.opts.chartData.radarData, this.opts.categories.length);
5051
+ return findRadarChartCurrentIndex(
5052
+ {
5053
+ x: _touches$.x,
5054
+ y: _touches$.y
5055
+ },
5056
+ this.opts.chartData.radarData,
5057
+ this.opts.categories.length
5058
+ );
4744
5059
  } else if (this.opts.type === 'funnel') {
4745
- return findFunnelChartCurrentIndex({
4746
- x: _touches$.x,
4747
- y: _touches$.y
4748
- }, this.opts.chartData.funnelData);
5060
+ return findFunnelChartCurrentIndex(
5061
+ {
5062
+ x: _touches$.x,
5063
+ y: _touches$.y
5064
+ },
5065
+ this.opts.chartData.funnelData
5066
+ );
4749
5067
  } else if (this.opts.type === 'map') {
4750
- return findMapChartCurrentIndex({
4751
- x: _touches$.x,
4752
- y: _touches$.y
4753
- }, this.opts);
4754
- }else if (this.opts.type === 'word') {
4755
- return findWordChartCurrentIndex({
4756
- x: _touches$.x,
4757
- y: _touches$.y
4758
- }, this.opts.chartData.wordCloudData);
5068
+ return findMapChartCurrentIndex(
5069
+ {
5070
+ x: _touches$.x,
5071
+ y: _touches$.y
5072
+ },
5073
+ this.opts
5074
+ );
5075
+ } else if (this.opts.type === 'word') {
5076
+ return findWordChartCurrentIndex(
5077
+ {
5078
+ x: _touches$.x,
5079
+ y: _touches$.y
5080
+ },
5081
+ this.opts.chartData.wordCloudData
5082
+ );
4759
5083
  } else {
4760
- return findCurrentIndex({
4761
- x: _touches$.x,
4762
- y: _touches$.y
4763
- }, this.opts.chartData.xAxisPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset));
5084
+ return findCurrentIndex(
5085
+ {
5086
+ x: _touches$.x,
5087
+ y: _touches$.y
5088
+ },
5089
+ this.opts.chartData.xAxisPoints,
5090
+ this.opts,
5091
+ this.config,
5092
+ Math.abs(this.scrollOption.currentOffset)
5093
+ );
4764
5094
  }
4765
5095
  }
4766
5096
  return -1;
4767
5097
  };
4768
5098
 
4769
- Charts.prototype.getLegendDataIndex = function(e) {
5099
+ Charts.prototype.getLegendDataIndex = function (e) {
4770
5100
  var touches = null;
4771
5101
  if (e.changedTouches) {
4772
5102
  touches = e.changedTouches[0];
@@ -4775,15 +5105,18 @@ Charts.prototype.getLegendDataIndex = function(e) {
4775
5105
  }
4776
5106
  if (touches) {
4777
5107
  let _touches$ = getTouches(touches, this.opts, e);
4778
- return findLegendIndex({
4779
- x: _touches$.x,
4780
- y: _touches$.y
4781
- }, this.opts.chartData.legendData);
5108
+ return findLegendIndex(
5109
+ {
5110
+ x: _touches$.x,
5111
+ y: _touches$.y
5112
+ },
5113
+ this.opts.chartData.legendData
5114
+ );
4782
5115
  }
4783
5116
  return -1;
4784
5117
  };
4785
5118
 
4786
- Charts.prototype.touchLegend = function(e) {
5119
+ Charts.prototype.touchLegend = function (e) {
4787
5120
  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4788
5121
  var touches = null;
4789
5122
  if (e.changedTouches) {
@@ -4800,10 +5133,9 @@ Charts.prototype.touchLegend = function(e) {
4800
5133
  drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
4801
5134
  }
4802
5135
  }
4803
-
4804
5136
  };
4805
5137
 
4806
- Charts.prototype.showToolTip = function(e) {
5138
+ Charts.prototype.showToolTip = function (e) {
4807
5139
  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4808
5140
  var touches = null;
4809
5141
  if (e.changedTouches) {
@@ -4812,7 +5144,7 @@ Charts.prototype.showToolTip = function(e) {
4812
5144
  touches = e.mp.changedTouches[0];
4813
5145
  }
4814
5146
  if (!touches) {
4815
- console.log("touchError");
5147
+ console.log('touchError');
4816
5148
  }
4817
5149
  var _touches$ = getTouches(touches, this.opts, e);
4818
5150
  var currentOffset = this.scrollOption.currentOffset;
@@ -4825,7 +5157,7 @@ Charts.prototype.showToolTip = function(e) {
4825
5157
  if (index > -1) {
4826
5158
  var seriesData = getSeriesDataItem(this.opts.series, index);
4827
5159
  if (seriesData.length !== 0) {
4828
- var _getToolTipData = getToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories,option),
5160
+ var _getToolTipData = getToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories, option),
4829
5161
  textList = _getToolTipData.textList,
4830
5162
  offset = _getToolTipData.offset;
4831
5163
  offset.y = _touches$.y;
@@ -4849,7 +5181,13 @@ Charts.prototype.showToolTip = function(e) {
4849
5181
  });
4850
5182
  var seriesData = getSeriesDataItem(this.opts.series, index);
4851
5183
  if (seriesData.length !== 0) {
4852
- var _getMixToolTipData = getMixToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories,option),
5184
+ var _getMixToolTipData = getMixToolTipData(
5185
+ seriesData,
5186
+ this.opts.chartData.calPoints,
5187
+ index,
5188
+ this.opts.categories,
5189
+ option
5190
+ ),
4853
5191
  textList = _getMixToolTipData.textList,
4854
5192
  offset = _getMixToolTipData.offset;
4855
5193
  offset.y = _touches$.y;
@@ -4873,8 +5211,15 @@ Charts.prototype.showToolTip = function(e) {
4873
5211
  });
4874
5212
  var seriesData = getSeriesDataItem(this.opts.series, index);
4875
5213
  if (seriesData.length !== 0) {
4876
- var _getToolTipData = getCandleToolTipData(this.opts.series[0].data, seriesData, this.opts.chartData.calPoints,
4877
- index, this.opts.categories, this.opts.extra.candle, option),
5214
+ var _getToolTipData = getCandleToolTipData(
5215
+ this.opts.series[0].data,
5216
+ seriesData,
5217
+ this.opts.chartData.calPoints,
5218
+ index,
5219
+ this.opts.categories,
5220
+ this.opts.extra.candle,
5221
+ option
5222
+ ),
4878
5223
  textList = _getToolTipData.textList,
4879
5224
  offset = _getToolTipData.offset;
4880
5225
  offset.y = _touches$.y;
@@ -4888,7 +5233,7 @@ Charts.prototype.showToolTip = function(e) {
4888
5233
  }
4889
5234
  drawCharts.call(this, opts.type, opts, this.config, this.context);
4890
5235
  }
4891
- if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose'||this.opts.type === 'funnel' ) {
5236
+ if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose' || this.opts.type === 'funnel') {
4892
5237
  var index = this.getCurrentDataIndex(e);
4893
5238
  if (index > -1) {
4894
5239
  var currentOffset = this.scrollOption.currentOffset;
@@ -4897,10 +5242,12 @@ Charts.prototype.showToolTip = function(e) {
4897
5242
  animation: false
4898
5243
  });
4899
5244
  var seriesData = this.opts._series_[index];
4900
- var textList = [{
4901
- text: option.format ? option.format(seriesData) : seriesData.name + ': ' + seriesData.data,
4902
- color: seriesData.color
4903
- }];
5245
+ var textList = [
5246
+ {
5247
+ text: option.format ? option.format(seriesData) : seriesData.name + ': ' + seriesData.data,
5248
+ color: seriesData.color
5249
+ }
5250
+ ];
4904
5251
  var offset = {
4905
5252
  x: _touches$.x,
4906
5253
  y: _touches$.y
@@ -4914,7 +5261,7 @@ Charts.prototype.showToolTip = function(e) {
4914
5261
  }
4915
5262
  drawCharts.call(this, opts.type, opts, this.config, this.context);
4916
5263
  }
4917
- if (this.opts.type === 'map'||this.opts.type === 'word') {
5264
+ if (this.opts.type === 'map' || this.opts.type === 'word') {
4918
5265
  var index = this.getCurrentDataIndex(e);
4919
5266
  if (index > -1) {
4920
5267
  var currentOffset = this.scrollOption.currentOffset;
@@ -4923,10 +5270,12 @@ Charts.prototype.showToolTip = function(e) {
4923
5270
  animation: false
4924
5271
  });
4925
5272
  var seriesData = this.opts._series_[index];
4926
- var textList = [{
4927
- text: option.format ? option.format(seriesData) : seriesData.properties.name ,
4928
- color: seriesData.color
4929
- }];
5273
+ var textList = [
5274
+ {
5275
+ text: option.format ? option.format(seriesData) : seriesData.properties.name,
5276
+ color: seriesData.color
5277
+ }
5278
+ ];
4930
5279
  var offset = {
4931
5280
  x: _touches$.x,
4932
5281
  y: _touches$.y
@@ -4951,7 +5300,7 @@ Charts.prototype.showToolTip = function(e) {
4951
5300
  });
4952
5301
  var seriesData = getSeriesDataItem(this.opts.series, index);
4953
5302
  if (seriesData.length !== 0) {
4954
- var textList = seriesData.map(function(item) {
5303
+ var textList = seriesData.map(function (item) {
4955
5304
  return {
4956
5305
  text: option.format ? option.format(item) : item.name + ': ' + item.data,
4957
5306
  color: item.color
@@ -4973,7 +5322,7 @@ Charts.prototype.showToolTip = function(e) {
4973
5322
  }
4974
5323
  };
4975
5324
 
4976
- Charts.prototype.translate = function(distance) {
5325
+ Charts.prototype.translate = function (distance) {
4977
5326
  this.scrollOption = {
4978
5327
  currentOffset: distance,
4979
5328
  startTouchX: distance,
@@ -4987,7 +5336,7 @@ Charts.prototype.translate = function(distance) {
4987
5336
  drawCharts.call(this, this.opts.type, opts, this.config, this.context);
4988
5337
  };
4989
5338
 
4990
- Charts.prototype.scrollStart = function(e) {
5339
+ Charts.prototype.scrollStart = function (e) {
4991
5340
  var touches = null;
4992
5341
  if (e.changedTouches) {
4993
5342
  touches = e.changedTouches[0];
@@ -5000,7 +5349,7 @@ Charts.prototype.scrollStart = function(e) {
5000
5349
  }
5001
5350
  };
5002
5351
 
5003
- Charts.prototype.scroll = function(e) {
5352
+ Charts.prototype.scroll = function (e) {
5004
5353
  if (this.scrollOption.lastMoveTime === 0) {
5005
5354
  this.scrollOption.lastMoveTime = Date.now();
5006
5355
  }
@@ -5031,7 +5380,7 @@ Charts.prototype.scroll = function(e) {
5031
5380
  }
5032
5381
  };
5033
5382
 
5034
- Charts.prototype.scrollEnd = function(e) {
5383
+ Charts.prototype.scrollEnd = function (e) {
5035
5384
  if (this.opts.enableScroll === true) {
5036
5385
  var _scrollOption = this.scrollOption,
5037
5386
  currentOffset = _scrollOption.currentOffset,
@@ -5040,7 +5389,7 @@ Charts.prototype.scrollEnd = function(e) {
5040
5389
  this.scrollOption.distance = 0;
5041
5390
  }
5042
5391
  };
5043
- if (typeof module === "object" && typeof module.exports === "object") {
5044
- module.exports = Charts;
5392
+ if (typeof module === 'object' && typeof module.exports === 'object') {
5045
5393
  //export default Charts;//建议使用nodejs的module导出方式,如报错请使用export方式导出
5046
5394
  }
5395
+ export default Charts;