echarts 4.2.0-rc.2 → 4.2.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 (82) hide show
  1. package/KEYS +60 -0
  2. package/LICENSE +7 -8
  3. package/dist/echarts-en.common.js +1250 -717
  4. package/dist/echarts-en.common.min.js +1 -1
  5. package/dist/echarts-en.js +2284 -1763
  6. package/dist/echarts-en.js.map +1 -1
  7. package/dist/echarts-en.min.js +1 -1
  8. package/dist/echarts-en.simple.js +1001 -560
  9. package/dist/echarts-en.simple.min.js +1 -1
  10. package/dist/echarts.common.js +1250 -717
  11. package/dist/echarts.common.min.js +1 -1
  12. package/dist/echarts.js +2284 -1763
  13. package/dist/echarts.js.map +1 -1
  14. package/dist/echarts.min.js +1 -1
  15. package/dist/echarts.simple.js +1001 -560
  16. package/dist/echarts.simple.min.js +1 -1
  17. package/dist/extension/dataTool.js +32 -33
  18. package/dist/extension/dataTool.js.map +1 -1
  19. package/lib/chart/graph/GraphView.js +17 -9
  20. package/lib/chart/graph/forceHelper.js +15 -20
  21. package/lib/chart/helper/Line.js +5 -1
  22. package/lib/chart/map/MapSeries.js +32 -26
  23. package/lib/chart/map/MapView.js +93 -40
  24. package/lib/chart/pie/labelLayout.js +23 -16
  25. package/lib/chart/sankey/sankeyLayout.js +18 -17
  26. package/lib/chart/sunburst/SunburstPiece.js +10 -5
  27. package/lib/chart/themeRiver/ThemeRiverSeries.js +26 -29
  28. package/lib/chart/tree/layoutHelper.js +57 -10
  29. package/lib/chart/treemap/treemapLayout.js +13 -7
  30. package/lib/component/axis/AxisBuilder.js +11 -2
  31. package/lib/component/helper/MapDraw.js +4 -0
  32. package/lib/component/helper/RoamController.js +3 -3
  33. package/lib/component/legend/LegendView.js +19 -1
  34. package/lib/component/legend/ScrollableLegendView.js +105 -70
  35. package/lib/coord/axisHelper.js +24 -1
  36. package/lib/coord/axisTickLabelBuilder.js +7 -12
  37. package/lib/coord/geo/Geo.js +1 -1
  38. package/lib/data/List.js +111 -36
  39. package/lib/echarts.js +13 -4
  40. package/lib/model/Model.js +1 -1
  41. package/lib/model/mixin/textStyle.js +1 -1
  42. package/lib/scale/Time.js +14 -4
  43. package/lib/util/format.js +30 -1
  44. package/lib/util/graphic.js +114 -27
  45. package/lib/util/model.js +27 -1
  46. package/lib/util/number.js +12 -33
  47. package/lib/visual/visualSolution.js +1 -1
  48. package/package.json +3 -4
  49. package/src/chart/graph/GraphView.js +15 -10
  50. package/src/chart/graph/forceHelper.js +17 -24
  51. package/src/chart/helper/Line.js +5 -1
  52. package/src/chart/map/MapSeries.js +28 -31
  53. package/src/chart/map/MapView.js +96 -38
  54. package/src/chart/pie/labelLayout.js +19 -14
  55. package/src/chart/sankey/sankeyLayout.js +17 -19
  56. package/src/chart/sunburst/SunburstPiece.js +11 -3
  57. package/src/chart/themeRiver/ThemeRiverSeries.js +18 -33
  58. package/src/chart/tree/layoutHelper.js +56 -10
  59. package/src/chart/treemap/treemapLayout.js +13 -7
  60. package/src/component/axis/AxisBuilder.js +7 -1
  61. package/src/component/helper/MapDraw.js +5 -1
  62. package/src/component/helper/RoamController.js +3 -4
  63. package/src/component/legend/LegendView.js +20 -1
  64. package/src/component/legend/ScrollableLegendView.js +119 -85
  65. package/src/coord/axisHelper.js +19 -0
  66. package/src/coord/axisTickLabelBuilder.js +10 -13
  67. package/src/coord/geo/Geo.js +1 -1
  68. package/src/data/List.js +107 -28
  69. package/src/echarts.js +11 -5
  70. package/src/model/Model.js +1 -1
  71. package/src/model/mixin/textStyle.js +1 -0
  72. package/src/scale/Time.js +14 -4
  73. package/src/util/format.js +39 -1
  74. package/src/util/graphic.js +110 -28
  75. package/src/util/model.js +25 -0
  76. package/src/util/number.js +12 -33
  77. package/src/visual/visualSolution.js +1 -1
  78. package/extension/dataTool/quantile.js +0 -82
  79. package/lib/component/tooltip/TooltipContentManager.js +0 -126
  80. package/lib/util/nest.js +0 -148
  81. package/src/component/tooltip/TooltipContentManager.js +0 -120
  82. package/src/util/nest.js +0 -127
package/lib/echarts.js CHANGED
@@ -101,9 +101,9 @@ var each = zrUtil.each;
101
101
  var isFunction = zrUtil.isFunction;
102
102
  var isObject = zrUtil.isObject;
103
103
  var parseClassType = ComponentModel.parseClassType;
104
- var version = '4.2.0';
104
+ var version = '4.2.1';
105
105
  var dependencies = {
106
- zrender: '4.0.5'
106
+ zrender: '4.0.6'
107
107
  };
108
108
  var TEST_FRAME_REMAIN_TIME = 1;
109
109
  var PRIORITY_PROCESSOR_FILTER = 1000;
@@ -1396,7 +1396,7 @@ var MOUSE_EVENT_NAMES = ['click', 'dblclick', 'mouseover', 'mouseout', 'mousemov
1396
1396
 
1397
1397
  echartsProto._initEvents = function () {
1398
1398
  each(MOUSE_EVENT_NAMES, function (eveName) {
1399
- this._zr.on(eveName, function (e) {
1399
+ var handler = function (e) {
1400
1400
  var ecModel = this.getModel();
1401
1401
  var el = e.target;
1402
1402
  var params;
@@ -1444,7 +1444,16 @@ echartsProto._initEvents = function () {
1444
1444
  };
1445
1445
  this.trigger(eveName, params);
1446
1446
  }
1447
- }, this);
1447
+ }; // Consider that some component (like tooltip, brush, ...)
1448
+ // register zr event handler, but user event handler might
1449
+ // do anything, such as call `setOption` or `dispatchAction`,
1450
+ // which probably update any of the content and probably
1451
+ // cause problem if it is called previous other inner handlers.
1452
+
1453
+
1454
+ handler.zrEventfulCallAtLast = true;
1455
+
1456
+ this._zr.on(eveName, handler, this);
1448
1457
  }, this);
1449
1458
  each(eventActionMap, function (actionType, eventType) {
1450
1459
  this._messageCenter.on(eventType, function (event) {
@@ -66,7 +66,7 @@ var inner = makeInner();
66
66
  /**
67
67
  * @alias module:echarts/model/Model
68
68
  * @constructor
69
- * @param {Object} option
69
+ * @param {Object} [option]
70
70
  * @param {module:echarts/model/Model} [parentModel]
71
71
  * @param {module:echarts/model/Global} [ecModel]
72
72
  */
@@ -65,7 +65,7 @@ var _default = {
65
65
  }, this.ecModel);
66
66
  },
67
67
  getTextRect: function (text) {
68
- return textContain.getBoundingRect(text, this.getFont(), this.getShallow('align'), this.getShallow('verticalAlign') || this.getShallow('baseline'), this.getShallow('padding'), this.getShallow('rich'), this.getShallow('truncateText'));
68
+ return textContain.getBoundingRect(text, this.getFont(), this.getShallow('align'), this.getShallow('verticalAlign') || this.getShallow('baseline'), this.getShallow('padding'), this.getShallow('lineHeight'), this.getShallow('rich'), this.getShallow('truncateText'));
69
69
  }
70
70
  };
71
71
  module.exports = _default;
package/lib/scale/Time.js CHANGED
@@ -48,9 +48,13 @@ var IntervalScale = require("./Interval");
48
48
  */
49
49
 
50
50
  /*
51
- * The `scaleLevels` references to d3.js. The use of the source
52
- * code of this file is also subject to the terms and consitions
53
- * of its license (BSD-3Clause, see <echarts/src/licenses/LICENSE-d3>).
51
+ * A third-party license is embeded for some of the code in this file:
52
+ * The "scaleLevels" was originally copied from "d3.js" with some
53
+ * modifications made for this project.
54
+ * (See more details in the comment on the definition of "scaleLevels" below.)
55
+ * The use of the source code of this file is also subject to the terms
56
+ * and consitions of the license of "d3.js" (BSD-3Clause, see
57
+ * </licenses/LICENSE-d3>).
54
58
  */
55
59
  // [About UTC and local time zone]:
56
60
  // In most cases, `number.parseDate` will treat input data string as local time
@@ -179,7 +183,13 @@ zrUtil.each(['contain', 'normalize'], function (methodName) {
179
183
  TimeScale.prototype[methodName] = function (val) {
180
184
  return intervalScaleProto[methodName].call(this, this.parse(val));
181
185
  };
182
- }); // Steps from d3, see the license statement at the top of this file.
186
+ });
187
+ /**
188
+ * This implementation was originally copied from "d3.js"
189
+ * <https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/time/scale.js>
190
+ * with some modifications made for this program.
191
+ * See the license statement at the head of this file.
192
+ */
183
193
 
184
194
  var scaleLevels = [// Format interval
185
195
  ['hh:mm:ss', ONE_SECOND], // 1s
@@ -233,7 +233,35 @@ function capitalFirst(str) {
233
233
  }
234
234
 
235
235
  var truncateText = textContain.truncateText;
236
- var getTextRect = textContain.getBoundingRect;
236
+ /**
237
+ * @public
238
+ * @param {Object} opt
239
+ * @param {string} opt.text
240
+ * @param {string} opt.font
241
+ * @param {string} [opt.textAlign='left']
242
+ * @param {string} [opt.textVerticalAlign='top']
243
+ * @param {Array.<number>} [opt.textPadding]
244
+ * @param {number} [opt.textLineHeight]
245
+ * @param {Object} [opt.rich]
246
+ * @param {Object} [opt.truncate]
247
+ * @return {Object} {x, y, width, height, lineHeight}
248
+ */
249
+
250
+ function getTextBoundingRect(opt) {
251
+ return textContain.getBoundingRect(opt.text, opt.font, opt.textAlign, opt.textVerticalAlign, opt.textPadding, opt.textLineHeight, opt.rich, opt.truncate);
252
+ }
253
+ /**
254
+ * @deprecated
255
+ * the `textLineHeight` was added later.
256
+ * For backward compatiblility, put it as the last parameter.
257
+ * But deprecated this interface. Please use `getTextBoundingRect` instead.
258
+ */
259
+
260
+
261
+ function getTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate, textLineHeight) {
262
+ return textContain.getBoundingRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, rich, truncate);
263
+ }
264
+
237
265
  exports.addCommas = addCommas;
238
266
  exports.toCamelCase = toCamelCase;
239
267
  exports.normalizeCssArray = normalizeCssArray;
@@ -244,4 +272,5 @@ exports.getTooltipMarker = getTooltipMarker;
244
272
  exports.formatTime = formatTime;
245
273
  exports.capitalFirst = capitalFirst;
246
274
  exports.truncateText = truncateText;
275
+ exports.getTextBoundingRect = getTextBoundingRect;
247
276
  exports.getTextRect = getTextRect;
@@ -122,6 +122,7 @@ var round = Math.round;
122
122
  var mathMax = Math.max;
123
123
  var mathMin = Math.min;
124
124
  var EMPTY_OBJ = {};
125
+ var Z2_EMPHASIS_LIFT = 1;
125
126
  /**
126
127
  * Extend shape with parameters
127
128
  */
@@ -347,11 +348,12 @@ function cacheElementStl(el) {
347
348
  var hoverStyle = el.__hoverStl;
348
349
 
349
350
  if (!hoverStyle) {
350
- el.__normalStl = null;
351
+ el.__cachedNormalStl = el.__cachedNormalZ2 = null;
351
352
  return;
352
353
  }
353
354
 
354
- var normalStyle = el.__normalStl = {};
355
+ var normalStyle = el.__cachedNormalStl = {};
356
+ el.__cachedNormalZ2 = el.z2;
355
357
  var elStyle = el.style;
356
358
 
357
359
  for (var name in hoverStyle) {
@@ -387,10 +389,7 @@ function doSingleEnterHover(el) {
387
389
  if (useHoverLayer) {
388
390
  elTarget = zr.addHover(el);
389
391
  targetStyle = elTarget.style;
390
- } // Consider case: only `position: 'top'` is set on emphasis, then text
391
- // color should be returned to `autoColor`, rather than remain '#fff'.
392
- // So we should rollback then apply again after style merging.
393
-
392
+ }
394
393
 
395
394
  rollbackDefaultTextStyle(targetStyle);
396
395
 
@@ -424,7 +423,7 @@ function doSingleEnterHover(el) {
424
423
 
425
424
  if (!useHoverLayer) {
426
425
  el.dirty(false);
427
- el.z2 += 1;
426
+ el.z2 += Z2_EMPHASIS_LIFT;
428
427
  }
429
428
  }
430
429
 
@@ -435,20 +434,19 @@ function setDefaultHoverFillStroke(targetStyle, hoverStyle, prop) {
435
434
  }
436
435
 
437
436
  function doSingleLeaveHover(el) {
438
- if (el.__highlighted) {
439
- doSingleRestoreHoverStyle(el);
440
- el.__highlighted = false;
437
+ var highlighted = el.__highlighted;
438
+
439
+ if (!highlighted) {
440
+ return;
441
441
  }
442
- }
443
442
 
444
- function doSingleRestoreHoverStyle(el) {
445
- var highlighted = el.__highlighted;
443
+ el.__highlighted = false;
446
444
 
447
445
  if (highlighted === 'layer') {
448
446
  el.__zr && el.__zr.removeHover(el);
449
447
  } else if (highlighted) {
450
448
  var style = el.style;
451
- var normalStl = el.__normalStl;
449
+ var normalStl = el.__cachedNormalStl;
452
450
 
453
451
  if (normalStl) {
454
452
  rollbackDefaultTextStyle(style); // Consider null/undefined value, should use
@@ -456,7 +454,15 @@ function doSingleRestoreHoverStyle(el) {
456
454
 
457
455
  el.setStyle(normalStl);
458
456
  applyDefaultTextStyle(style);
459
- el.z2 -= 1;
457
+ } // `__cachedNormalZ2` will not be reset if calling `setElementHoverStyle`
458
+ // when `el` is on emphasis state. So here by comparing with 1, we try
459
+ // hard to make the bug case rare.
460
+
461
+
462
+ var normalZ2 = el.__cachedNormalZ2;
463
+
464
+ if (normalZ2 != null && el.z2 - normalZ2 === Z2_EMPHASIS_LIFT) {
465
+ el.z2 = normalZ2;
460
466
  }
461
467
  }
462
468
  }
@@ -467,7 +473,10 @@ function traverseCall(el, method) {
467
473
  }) : method(el);
468
474
  }
469
475
  /**
470
- * Set hover style of element.
476
+ * Set hover style (namely "emphasis style") of element, based on the current
477
+ * style of the given `el`.
478
+ * This method should be called after all of the normal styles have been adopted
479
+ * to the `el`. See the reason on `setHoverStyle`.
471
480
  *
472
481
  * @param {module:zrender/Element} el Should not be `zrender/container/Group`.
473
482
  * @param {Object|boolean} [hoverStl] The specified hover style.
@@ -481,10 +490,26 @@ function traverseCall(el, method) {
481
490
 
482
491
 
483
492
  function setElementHoverStyle(el, hoverStl) {
493
+ // For performance consideration, it might be better to make the "hover style" only the
494
+ // difference properties from the "normal style", but not a entire copy of all styles.
484
495
  hoverStl = el.__hoverStl = hoverStl !== false && (hoverStl || {});
485
- el.__hoverStlDirty = true;
496
+ el.__hoverStlDirty = true; // FIXME
497
+ // It is not completely right to save "normal"/"emphasis" flag on elements.
498
+ // It probably should be saved on `data` of series. Consider the cases:
499
+ // (1) A highlighted elements are moved out of the view port and re-enter
500
+ // again by dataZoom.
501
+ // (2) call `setOption` and replace elements totally when they are highlighted.
486
502
 
487
503
  if (el.__highlighted) {
504
+ // Consider the case:
505
+ // The styles of a highlighted `el` is being updated. The new "emphasis style"
506
+ // should be adapted to the `el`. Notice here new "normal styles" should have
507
+ // been set outside and the cached "normal style" is out of date.
508
+ el.__cachedNormalStl = null; // Do not clear `__cachedNormalZ2` here, because setting `z2` is not a constraint
509
+ // of this method. In most cases, `z2` is not set and hover style should be able
510
+ // to rollback. Of course, that would bring bug, but only in a rare case, see
511
+ // `doSingleLeaveHover` for details.
512
+
488
513
  doSingleLeaveHover(el);
489
514
  doSingleEnterHover(el);
490
515
  }
@@ -534,12 +559,29 @@ function leaveEmphasis() {
534
559
  traverseCall(this, doSingleLeaveHover);
535
560
  }
536
561
  /**
537
- * Set hover style of element.
562
+ * Set hover style (namely "emphasis style") of element,
563
+ * based on the current style of the given `el`.
564
+ *
565
+ * (1)
566
+ * **CONSTRAINTS** for this method:
567
+ * <A> This method MUST be called after all of the normal styles having been adopted
568
+ * to the `el`.
569
+ * <B> The input `hoverStyle` (that is, "emphasis style") MUST be the subset of the
570
+ * "normal style" having been set to the el.
571
+ * <C> `color` MUST be one of the "normal styles" (because color might be lifted as
572
+ * a default hover style).
573
+ *
574
+ * The reason: this method treat the current style of the `el` as the "normal style"
575
+ * and cache them when enter/update the "emphasis style". Consider the case: the `el`
576
+ * is in "emphasis" state and `setOption`/`dispatchAction` trigger the style updating
577
+ * logic, where the el should shift from the original emphasis style to the new
578
+ * "emphasis style" and should be able to "downplay" back to the new "normal style".
538
579
  *
539
- * [Caveat]:
540
- * This method can be called repeatly and achieve the same result.
580
+ * Indeed, it is error-prone to make a interface has so many constraints, but I have
581
+ * not found a better solution yet to fit the backward compatibility, performance and
582
+ * the current programming style.
541
583
  *
542
- * [Usage]:
584
+ * (2)
543
585
  * Call the method for a "root" element once. Do not call it for each descendants.
544
586
  * If the descendants elemenets of a group has itself hover style different from the
545
587
  * root group, we can simply mount the style on `el.hoverStyle` for them, but should
@@ -590,6 +632,7 @@ function setAsHoverStyleTrigger(el, opt) {
590
632
  }
591
633
  }
592
634
  /**
635
+ * See more info in `setTextStyleCommon`.
593
636
  * @param {Object|module:zrender/graphic/Style} normalStyle
594
637
  * @param {Object} emphasisStyle
595
638
  * @param {module:echarts/model/Model} normalModel
@@ -650,6 +693,7 @@ function setLabelStyle(normalStyle, emphasisStyle, normalModel, emphasisModel, o
650
693
  }
651
694
  /**
652
695
  * Set basic textStyle properties.
696
+ * See more info in `setTextStyleCommon`.
653
697
  * @param {Object|module:zrender/graphic/Style} textStyle
654
698
  * @param {module:echarts/model/Model} model
655
699
  * @param {Object} [specifiedTextStyle] Can be overrided by settings in model.
@@ -666,6 +710,7 @@ function setTextStyle(textStyle, textStyleModel, specifiedTextStyle, opt, isEmph
666
710
  }
667
711
  /**
668
712
  * Set text option in the style.
713
+ * See more info in `setTextStyleCommon`.
669
714
  * @deprecated
670
715
  * @param {Object} textStyle
671
716
  * @param {module:echarts/model/Model} labelModel
@@ -690,7 +735,23 @@ function setText(textStyle, labelModel, defaultColor) {
690
735
  setTextStyleCommon(textStyle, labelModel, opt, isEmphasis); // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
691
736
  }
692
737
  /**
693
- * {
738
+ * The uniform entry of set text style, that is, retrieve style definitions
739
+ * from `model` and set to `textStyle` object.
740
+ *
741
+ * Never in merge mode, but in overwrite mode, that is, all of the text style
742
+ * properties will be set. (Consider the states of normal and emphasis and
743
+ * default value can be adopted, merge would make the logic too complicated
744
+ * to manage.)
745
+ *
746
+ * The `textStyle` object can either be a plain object or an instance of
747
+ * `zrender/src/graphic/Style`, and either be the style of normal or emphasis.
748
+ * After this mothod called, the `textStyle` object can then be used in
749
+ * `el.setStyle(textStyle)` or `el.hoverStyle = textStyle`.
750
+ *
751
+ * Default value will be adopted and `insideRollbackOpt` will be created.
752
+ * See `applyDefaultTextStyle` `rollbackDefaultTextStyle` for more details.
753
+ *
754
+ * opt: {
694
755
  * disableBox: boolean, Whether diable drawing box of block (outer most).
695
756
  * isRectText: boolean,
696
757
  * autoColor: string, specify a color when color is 'auto',
@@ -859,14 +920,28 @@ function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEm
859
920
 
860
921
  function getAutoColor(color, opt) {
861
922
  return color !== 'auto' ? color : opt && opt.autoColor ? opt.autoColor : null;
862
- } // When text position is `inside` and `textFill` not specified, we
863
- // provide a mechanism to auto make text border for better view. But
864
- // text position changing when hovering or being emphasis should be
865
- // considered, where the `insideRollback` enables to restore the style.
923
+ }
924
+ /**
925
+ * Give some default value to the input `textStyle` object, based on the current settings
926
+ * in this `textStyle` object.
927
+ *
928
+ * The Scenario:
929
+ * when text position is `inside` and `textFill` is not specified, we show
930
+ * text border by default for better view. But it should be considered that text position
931
+ * might be changed when hovering or being emphasis, where the `insideRollback` is used to
932
+ * restore the style.
933
+ *
934
+ * Usage (& NOTICE):
935
+ * When a style object (eithor plain object or instance of `zrender/src/graphic/Style`) is
936
+ * about to be modified on its text related properties, `rollbackDefaultTextStyle` should
937
+ * be called before the modification and `applyDefaultTextStyle` should be called after that.
938
+ * (For the case that all of the text related properties is reset, like `setTextStyleCommon`
939
+ * does, `rollbackDefaultTextStyle` is not needed to be called).
940
+ */
866
941
 
867
942
 
868
943
  function applyDefaultTextStyle(textStyle) {
869
- var opt = textStyle.insideRollbackOpt; // Only insideRollbackOpt create (setTextStyleCommon used),
944
+ var opt = textStyle.insideRollbackOpt; // Only `insideRollbackOpt` created (in `setTextStyleCommon`),
870
945
  // applyDefaultTextStyle works.
871
946
 
872
947
  if (!opt || textStyle.textFill != null) {
@@ -903,6 +978,17 @@ function applyDefaultTextStyle(textStyle) {
903
978
  textStyle.insideRollback = insideRollback;
904
979
  }
905
980
  }
981
+ /**
982
+ * Consider the case: in a scatter,
983
+ * label: {
984
+ * normal: {position: 'inside'},
985
+ * emphasis: {position: 'top'}
986
+ * }
987
+ * In the normal state, the `textFill` will be set as '#fff' for pretty view (see
988
+ * `applyDefaultTextStyle`), but when switching to emphasis state, the `textFill`
989
+ * should be retured to 'autoColor', but not keep '#fff'.
990
+ */
991
+
906
992
 
907
993
  function rollbackDefaultTextStyle(style) {
908
994
  var insideRollback = style.insideRollback;
@@ -1179,6 +1265,7 @@ function createIcon(iconStr, opt, rect) {
1179
1265
  }
1180
1266
  }
1181
1267
 
1268
+ exports.Z2_EMPHASIS_LIFT = Z2_EMPHASIS_LIFT;
1182
1269
  exports.extendShape = extendShape;
1183
1270
  exports.extendPath = extendPath;
1184
1271
  exports.makePath = makePath;
package/lib/util/model.js CHANGED
@@ -502,6 +502,31 @@ function getTooltipRenderMode(renderModeOption) {
502
502
  return renderModeOption || 'html';
503
503
  }
504
504
  }
505
+ /**
506
+ * Group a list by key.
507
+ *
508
+ * @param {Array} array
509
+ * @param {Function} getKey
510
+ * param {*} Array item
511
+ * return {string} key
512
+ * @return {Object} Result
513
+ * {Array}: keys,
514
+ * {module:zrender/core/util/HashMap} buckets: {key -> Array}
515
+ */
516
+
517
+
518
+ function groupData(array, getKey) {
519
+ var buckets = zrUtil.createHashMap();
520
+ var keys = [];
521
+ zrUtil.each(array, function (item) {
522
+ var key = getKey(item);
523
+ (buckets.get(key) || (keys.push(key), buckets.set(key, []))).push(item);
524
+ });
525
+ return {
526
+ keys: keys,
527
+ buckets: buckets
528
+ };
529
+ }
505
530
 
506
531
  exports.normalizeToArray = normalizeToArray;
507
532
  exports.defaultEmphasis = defaultEmphasis;
@@ -518,4 +543,5 @@ exports.makeInner = makeInner;
518
543
  exports.parseFinder = parseFinder;
519
544
  exports.setAttribute = setAttribute;
520
545
  exports.getAttribute = getAttribute;
521
- exports.getTooltipRenderMode = getTooltipRenderMode;
546
+ exports.getTooltipRenderMode = getTooltipRenderMode;
547
+ exports.groupData = groupData;
@@ -38,6 +38,15 @@ var zrUtil = require("zrender/lib/core/util");
38
38
  * specific language governing permissions and limitations
39
39
  * under the License.
40
40
  */
41
+
42
+ /*
43
+ * A third-party license is embeded for some of the code in this file:
44
+ * The method "quantile" was copied from "d3.js".
45
+ * (See more details in the comment of the method below.)
46
+ * The use of the source code of this file is also subject to the terms
47
+ * and consitions of the license of "d3.js" (BSD-3Clause, see
48
+ * </licenses/LICENSE-d3>).
49
+ */
41
50
  var RADIAN_EPSILON = 1e-4;
42
51
 
43
52
  function _trim(str) {
@@ -440,39 +449,9 @@ function nice(val, round) {
440
449
  return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
441
450
  }
442
451
  /**
443
- * BSD 3-Clause
444
- *
445
- * Copyright (c) 2010-2015, Michael Bostock
446
- * All rights reserved.
447
- *
448
- * Redistribution and use in source and binary forms, with or without
449
- * modification, are permitted provided that the following conditions are met:
450
- *
451
- * * Redistributions of source code must retain the above copyright notice, this
452
- * list of conditions and the following disclaimer.
453
- *
454
- * * Redistributions in binary form must reproduce the above copyright notice,
455
- * this list of conditions and the following disclaimer in the documentation
456
- * and/or other materials provided with the distribution.
457
- *
458
- * * The name Michael Bostock may not be used to endorse or promote products
459
- * derived from this software without specific prior written permission.
460
- *
461
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
462
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
463
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
464
- * DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
465
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
466
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
467
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
468
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
469
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
470
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
471
- */
472
-
473
- /**
474
- * @see <https://github.com/mbostock/d3/blob/master/src/arrays/quantile.js>
475
- * @see <http://en.wikipedia.org/wiki/Quantile>
452
+ * This code was copied from "d3.js"
453
+ * <https://github.com/d3/d3/blob/9cc9a875e636a1dcf36cc1e07bdf77e1ad6e2c74/src/arrays/quantile.js>.
454
+ * See the license statement at the head of this file.
476
455
  * @param {Array.<number>} ascArr
477
456
  */
478
457
 
@@ -211,7 +211,7 @@ function incrementalApplyVisual(stateList, visualMappings, getValueState, dim) {
211
211
  var rawDataItem = data.getRawDataItem(dataIndex); // Consider performance
212
212
 
213
213
  if (rawDataItem && rawDataItem.visualMap === false) {
214
- return;
214
+ continue;
215
215
  }
216
216
 
217
217
  var value = dim != null ? data.get(dim, dataIndex, true) : dataIndex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echarts",
3
- "version": "4.2.0-rc.2",
3
+ "version": "4.2.1",
4
4
  "description": "A powerful charting and visualization library for browser",
5
5
  "keywords": [
6
6
  "visualization",
@@ -15,7 +15,7 @@
15
15
  "prepublish": "node build/build.js --prepublish"
16
16
  },
17
17
  "dependencies": {
18
- "zrender": "4.0.5"
18
+ "zrender": "4.0.7"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@babel/core": "7.0.0-beta.31",
@@ -33,7 +33,6 @@
33
33
  "glob": "7.0.0",
34
34
  "rollup": "0.50.0",
35
35
  "rollup-plugin-node-resolve": "3.0.0",
36
- "rollup-plugin-uglify": "2.0.1",
37
- "zrender": "4.0.5"
36
+ "rollup-plugin-uglify": "2.0.1"
38
37
  }
39
38
  }
@@ -27,6 +27,8 @@ import {onIrrelevantElement} from '../../component/helper/cursorHelper';
27
27
  import * as graphic from '../../util/graphic';
28
28
  import adjustEdge from './adjustEdge';
29
29
 
30
+ var FOCUS_ADJACENCY = '__focusNodeAdjacency';
31
+ var UNFOCUS_ADJACENCY = '__unfocusNodeAdjacency';
30
32
 
31
33
  var nodeOpacityPath = ['itemStyle', 'opacity'];
32
34
  var lineOpacityPath = ['lineStyle', 'opacity'];
@@ -47,7 +49,11 @@ function fadeOutItem(item, opacityPath, opacityRatio) {
47
49
  el.downplay && el.downplay();
48
50
  el.traverse(function (child) {
49
51
  if (child.type !== 'group') {
50
- child.setStyle('opacity', opacity);
52
+ var opct = child.lineLabelOriginalOpacity;
53
+ if (opct == null || opacityRatio != null) {
54
+ opct = opacity;
55
+ }
56
+ child.setStyle('opacity', opct);
51
57
  }
52
58
  });
53
59
  }
@@ -151,24 +157,23 @@ export default echarts.extendChartView({
151
157
  }
152
158
  el.setDraggable(draggable && forceLayout);
153
159
 
154
- el.off('mouseover', el.__focusNodeAdjacency);
155
- el.off('mouseout', el.__unfocusNodeAdjacency);
160
+ el[FOCUS_ADJACENCY] && el.off('mouseover', el[FOCUS_ADJACENCY]);
161
+ el[UNFOCUS_ADJACENCY] && el.off('mouseout', el[UNFOCUS_ADJACENCY]);
156
162
 
157
163
  if (itemModel.get('focusNodeAdjacency')) {
158
- el.on('mouseover', el.__focusNodeAdjacency = function () {
164
+ el.on('mouseover', el[FOCUS_ADJACENCY] = function () {
159
165
  api.dispatchAction({
160
166
  type: 'focusNodeAdjacency',
161
167
  seriesId: seriesModel.id,
162
168
  dataIndex: el.dataIndex
163
169
  });
164
170
  });
165
- el.on('mouseout', el.__unfocusNodeAdjacency = function () {
171
+ el.on('mouseout', el[UNFOCUS_ADJACENCY] = function () {
166
172
  api.dispatchAction({
167
173
  type: 'unfocusNodeAdjacency',
168
174
  seriesId: seriesModel.id
169
175
  });
170
176
  });
171
-
172
177
  }
173
178
 
174
179
  }, this);
@@ -176,18 +181,18 @@ export default echarts.extendChartView({
176
181
  data.graph.eachEdge(function (edge) {
177
182
  var el = edge.getGraphicEl();
178
183
 
179
- el.off('mouseover', el.__focusNodeAdjacency);
180
- el.off('mouseout', el.__unfocusNodeAdjacency);
184
+ el[FOCUS_ADJACENCY] && el.off('mouseover', el[FOCUS_ADJACENCY]);
185
+ el[UNFOCUS_ADJACENCY] && el.off('mouseout', el[UNFOCUS_ADJACENCY]);
181
186
 
182
187
  if (edge.getModel().get('focusNodeAdjacency')) {
183
- el.on('mouseover', el.__focusNodeAdjacency = function () {
188
+ el.on('mouseover', el[FOCUS_ADJACENCY] = function () {
184
189
  api.dispatchAction({
185
190
  type: 'focusNodeAdjacency',
186
191
  seriesId: seriesModel.id,
187
192
  edgeDataIndex: edge.dataIndex
188
193
  });
189
194
  });
190
- el.on('mouseout', el.__unfocusNodeAdjacency = function () {
195
+ el.on('mouseout', el[UNFOCUS_ADJACENCY] = function () {
191
196
  api.dispatchAction({
192
197
  type: 'unfocusNodeAdjacency',
193
198
  seriesId: seriesModel.id
@@ -18,10 +18,13 @@
18
18
  */
19
19
 
20
20
  /*
21
- * The layout implementation references to d3.js. The use of
22
- * the source code of this file is also subject to the terms
23
- * and consitions of its license (BSD-3Clause, see
24
- * <echarts/src/licenses/LICENSE-d3>).
21
+ * A third-party license is embeded for some of the code in this file:
22
+ * Some formulas were originally copied from "d3.js" with some
23
+ * modifications made for this project.
24
+ * (See more details in the comment of the method "step" below.)
25
+ * The use of the source code of this file is also subject to the terms
26
+ * and consitions of the license of "d3.js" (BSD-3Clause, see
27
+ * </licenses/LICENSE-d3>).
25
28
  */
26
29
 
27
30
  import * as vec2 from 'zrender/src/core/vector';
@@ -53,26 +56,10 @@ export function forceLayout(nodes, edges, opts) {
53
56
  for (var i = 0; i < nodes.length; i++) {
54
57
  var n = nodes[i];
55
58
  if (!n.p) {
56
- // Use the position from first adjecent node with defined position
57
- // Or use a random position
58
- // From d3
59
- // if (n.edges) {
60
- // var j = -1;
61
- // while (++j < n.edges.length) {
62
- // var e = n.edges[j];
63
- // var other = adjacentNode(n, e);
64
- // if (other.p) {
65
- // n.p = vec2.clone(other.p);
66
- // break;
67
- // }
68
- // }
69
- // }
70
- // if (!n.p) {
71
- n.p = vec2.create(
72
- width * (Math.random() - 0.5) + center[0],
73
- height * (Math.random() - 0.5) + center[1]
74
- );
75
- // }
59
+ n.p = vec2.create(
60
+ width * (Math.random() - 0.5) + center[0],
61
+ height * (Math.random() - 0.5) + center[1]
62
+ );
76
63
  }
77
64
  n.pp = vec2.clone(n.p);
78
65
  n.edges = null;
@@ -97,6 +84,12 @@ export function forceLayout(nodes, edges, opts) {
97
84
  nodes[idx].fixed = false;
98
85
  },
99
86
 
87
+ /**
88
+ * Some formulas were originally copied from "d3.js"
89
+ * https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/layout/force.js
90
+ * with some modifications made for this project.
91
+ * See the license statement at the head of this file.
92
+ */
100
93
  step: function (cb) {
101
94
  var v12 = [];
102
95
  var nLen = nodes.length;