echarts 3.5.1 → 3.6.0
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.
- package/LICENSE +21 -18
- package/README.md +10 -0
- package/dist/echarts.common.js +11010 -9830
- package/dist/echarts.common.min.js +13 -13
- package/dist/echarts.js +13291 -10852
- package/dist/echarts.min.js +22 -21
- package/dist/echarts.simple.js +9904 -8990
- package/dist/echarts.simple.min.js +9 -10
- package/index.js +1 -0
- package/lib/ExtensionAPI.js +2 -4
- package/lib/chart/bar/BarView.js +141 -49
- package/lib/chart/bar/BaseBarSeries.js +2 -6
- package/lib/chart/bar.js +1 -0
- package/lib/chart/boxplot/BoxplotSeries.js +1 -1
- package/lib/chart/boxplot/boxplotLayout.js +23 -7
- package/lib/chart/candlestick/CandlestickSeries.js +3 -22
- package/lib/chart/candlestick/candlestickLayout.js +23 -7
- package/lib/chart/custom.js +442 -0
- package/lib/chart/funnel/funnelLayout.js +10 -3
- package/lib/chart/gauge/GaugeView.js +1 -1
- package/lib/chart/graph/GraphView.js +15 -9
- package/lib/chart/graph/categoryVisual.js +3 -2
- package/lib/chart/heatmap/HeatmapLayer.js +1 -1
- package/lib/chart/heatmap/HeatmapView.js +75 -73
- package/lib/chart/helper/Symbol.js +8 -31
- package/lib/chart/helper/createListFromArray.js +15 -10
- package/lib/chart/helper/labelHelper.js +48 -0
- package/lib/chart/helper/whiskerBoxCommon.js +25 -44
- package/lib/chart/map/mapDataStatistic.js +9 -8
- package/lib/chart/parallel/ParallelSeries.js +2 -0
- package/lib/chart/parallel/ParallelView.js +13 -12
- package/lib/chart/parallel/parallelVisual.js +9 -1
- package/lib/chart/pie/pieLayout.js +25 -17
- package/lib/chart/radar/RadarSeries.js +1 -1
- package/lib/chart/sankey/sankeyLayout.js +1 -1
- package/lib/chart/scatter/ScatterSeries.js +2 -3
- package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
- package/lib/chart/treemap/TreemapSeries.js +3 -3
- package/lib/chart/treemap/TreemapView.js +1 -1
- package/lib/chart/treemap/treemapLayout.js +6 -1
- package/lib/component/axis/AxisBuilder.js +53 -34
- package/lib/component/axis/ParallelAxisView.js +45 -37
- package/lib/component/axisPointer/AxisPointerModel.js +1 -1
- package/lib/component/axisPointer/BaseAxisPointer.js +20 -15
- package/lib/component/axisPointer/CartesianAxisPointer.js +9 -6
- package/lib/component/axisPointer/PolarAxisPointer.js +10 -8
- package/lib/component/axisPointer/SingleAxisPointer.js +11 -7
- package/lib/component/axisPointer/axisTrigger.js +87 -72
- package/lib/component/axisPointer/viewHelper.js +6 -3
- package/lib/component/axisPointer.js +2 -2
- package/lib/component/brush/BrushModel.js +6 -4
- package/lib/component/brush/BrushView.js +1 -1
- package/lib/component/brush/visualEncoding.js +6 -4
- package/lib/component/calendar/CalendarView.js +5 -5
- package/lib/component/dataZoom/AxisProxy.js +76 -13
- package/lib/component/dataZoom/DataZoomModel.js +21 -5
- package/lib/component/dataZoom/InsideZoomModel.js +4 -1
- package/lib/component/dataZoom/InsideZoomView.js +17 -27
- package/lib/component/dataZoom/SliderZoomView.js +63 -26
- package/lib/component/dataZoom/roams.js +9 -4
- package/lib/component/graphic.js +13 -12
- package/lib/component/helper/BrushController.js +75 -114
- package/lib/component/helper/BrushTargetManager.js +16 -8
- package/lib/component/helper/MapDraw.js +25 -11
- package/lib/component/helper/RoamController.js +111 -139
- package/lib/component/helper/brushHelper.js +25 -213
- package/lib/component/helper/cursorHelper.js +21 -0
- package/lib/component/helper/roamHelper.js +54 -0
- package/lib/component/helper/selectableMixin.js +7 -7
- package/lib/component/helper/sliderMove.js +66 -37
- package/lib/component/legend/LegendView.js +6 -6
- package/lib/component/legend/legendAction.js +1 -1
- package/lib/component/marker/MarkAreaView.js +3 -6
- package/lib/component/marker/MarkLineView.js +3 -5
- package/lib/component/marker/MarkPointView.js +3 -5
- package/lib/component/marker/MarkerView.js +10 -12
- package/lib/component/marker/markerHelper.js +1 -1
- package/lib/component/parallel.js +94 -29
- package/lib/component/polar.js +5 -0
- package/lib/component/timeline/SliderTimelineView.js +1 -1
- package/lib/component/toolbox/feature/Brush.js +7 -0
- package/lib/component/toolbox/feature/DataZoom.js +17 -4
- package/lib/component/tooltip/TooltipView.js +92 -20
- package/lib/component/visualMap/ContinuousView.js +6 -4
- package/lib/coord/Axis.js +34 -2
- package/lib/coord/axisDefault.js +4 -1
- package/lib/coord/axisHelper.js +32 -26
- package/lib/coord/axisModelCommonMixin.js +1 -1
- package/lib/coord/calendar/Calendar.js +14 -17
- package/lib/coord/calendar/prepareCustom.js +31 -0
- package/lib/coord/cartesian/Axis2D.js +0 -12
- package/lib/coord/cartesian/Cartesian2D.js +1 -0
- package/lib/coord/cartesian/Grid.js +5 -2
- package/lib/coord/cartesian/prepareCustom.js +36 -0
- package/lib/coord/geo/Geo.js +9 -14
- package/lib/coord/geo/GeoModel.js +5 -5
- package/lib/coord/geo/geoCreator.js +3 -3
- package/lib/coord/geo/parseGeoJson.js +11 -4
- package/lib/coord/geo/prepareCustom.js +36 -0
- package/lib/coord/parallel/Parallel.js +225 -101
- package/lib/coord/parallel/ParallelModel.js +7 -1
- package/lib/coord/polar/Polar.js +2 -1
- package/lib/coord/polar/prepareCustom.js +53 -0
- package/lib/coord/single/Single.js +9 -8
- package/lib/coord/single/SingleAxis.js +0 -27
- package/lib/coord/single/prepareCustom.js +33 -0
- package/lib/data/DataDiffer.js +2 -1
- package/lib/data/Graph.js +11 -7
- package/lib/data/List.js +59 -20
- package/lib/data/helper/completeDimensions.js +184 -23
- package/lib/echarts.js +68 -36
- package/lib/helper.js +1 -8
- package/lib/layout/barGrid.js +91 -19
- package/lib/layout/barPolar.js +286 -0
- package/lib/layout/points.js +22 -16
- package/lib/model/Global.js +34 -31
- package/lib/model/Series.js +41 -29
- package/lib/model/globalDefault.js +4 -1
- package/lib/model/mixin/colorPalette.js +2 -1
- package/lib/model/mixin/textStyle.js +7 -13
- package/lib/scale/Interval.js +46 -76
- package/lib/scale/Log.js +5 -7
- package/lib/scale/Scale.js +10 -1
- package/lib/scale/Time.js +34 -12
- package/lib/scale/helper.js +93 -0
- package/lib/util/format.js +20 -9
- package/lib/util/graphic.js +70 -8
- package/lib/util/layout.js +7 -3
- package/lib/util/model.js +63 -7
- package/lib/util/number.js +59 -19
- package/lib/util/throttle.js +14 -3
- package/map/js/world.js +1 -1
- package/map/json/world.json +1 -1
- package/package.json +3 -3
- package/src/ExtensionAPI.js +2 -4
- package/src/chart/bar/BarView.js +141 -49
- package/src/chart/bar/BaseBarSeries.js +2 -6
- package/src/chart/bar.js +1 -0
- package/src/chart/boxplot/BoxplotSeries.js +1 -1
- package/src/chart/boxplot/boxplotLayout.js +23 -7
- package/src/chart/candlestick/CandlestickSeries.js +3 -22
- package/src/chart/candlestick/candlestickLayout.js +23 -7
- package/src/chart/custom.js +442 -0
- package/src/chart/funnel/funnelLayout.js +10 -4
- package/src/chart/gauge/GaugeView.js +1 -1
- package/src/chart/graph/GraphView.js +15 -9
- package/src/chart/graph/categoryVisual.js +3 -2
- package/src/chart/heatmap/HeatmapLayer.js +1 -1
- package/src/chart/heatmap/HeatmapView.js +75 -73
- package/src/chart/helper/Symbol.js +8 -31
- package/src/chart/helper/createListFromArray.js +15 -10
- package/src/chart/helper/labelHelper.js +49 -0
- package/src/chart/helper/whiskerBoxCommon.js +25 -44
- package/src/chart/map/mapDataStatistic.js +9 -8
- package/src/chart/parallel/ParallelSeries.js +2 -0
- package/src/chart/parallel/ParallelView.js +13 -12
- package/src/chart/parallel/parallelVisual.js +9 -1
- package/src/chart/pie/pieLayout.js +25 -17
- package/src/chart/radar/RadarSeries.js +1 -1
- package/src/chart/sankey/sankeyLayout.js +1 -1
- package/src/chart/scatter/ScatterSeries.js +2 -3
- package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/src/chart/themeRiver/themeRiverVisual.js +1 -1
- package/src/chart/treemap/TreemapSeries.js +3 -3
- package/src/chart/treemap/TreemapView.js +1 -1
- package/src/chart/treemap/treemapLayout.js +6 -1
- package/src/component/axis/AxisBuilder.js +53 -34
- package/src/component/axis/ParallelAxisView.js +45 -37
- package/src/component/axisPointer/AxisPointerModel.js +1 -1
- package/src/component/axisPointer/BaseAxisPointer.js +20 -15
- package/src/component/axisPointer/CartesianAxisPointer.js +9 -6
- package/src/component/axisPointer/PolarAxisPointer.js +10 -8
- package/src/component/axisPointer/SingleAxisPointer.js +11 -7
- package/src/component/axisPointer/axisTrigger.js +87 -72
- package/src/component/axisPointer/viewHelper.js +6 -3
- package/src/component/axisPointer.js +2 -2
- package/src/component/brush/BrushModel.js +6 -4
- package/src/component/brush/BrushView.js +1 -1
- package/src/component/brush/visualEncoding.js +6 -4
- package/src/component/calendar/CalendarView.js +5 -5
- package/src/component/dataZoom/AxisProxy.js +76 -13
- package/src/component/dataZoom/DataZoomModel.js +21 -5
- package/src/component/dataZoom/InsideZoomModel.js +4 -1
- package/src/component/dataZoom/InsideZoomView.js +17 -27
- package/src/component/dataZoom/SliderZoomView.js +63 -26
- package/src/component/dataZoom/roams.js +9 -4
- package/src/component/graphic.js +13 -12
- package/src/component/helper/BrushController.js +75 -114
- package/src/component/helper/BrushTargetManager.js +16 -8
- package/src/component/helper/MapDraw.js +25 -11
- package/src/component/helper/RoamController.js +111 -139
- package/src/component/helper/brushHelper.js +41 -0
- package/src/component/helper/cursorHelper.js +22 -0
- package/src/component/helper/roamHelper.js +55 -0
- package/src/component/helper/selectableMixin.js +7 -7
- package/src/component/helper/sliderMove.js +66 -37
- package/src/component/legend/LegendView.js +6 -6
- package/src/component/legend/legendAction.js +1 -1
- package/src/component/marker/MarkAreaView.js +3 -6
- package/src/component/marker/MarkLineView.js +3 -5
- package/src/component/marker/MarkPointView.js +3 -5
- package/src/component/marker/MarkerView.js +10 -12
- package/src/component/marker/markerHelper.js +1 -1
- package/src/component/parallel.js +94 -29
- package/src/component/polar.js +5 -0
- package/src/component/timeline/SliderTimelineView.js +1 -1
- package/src/component/toolbox/feature/Brush.js +7 -0
- package/src/component/toolbox/feature/DataZoom.js +17 -4
- package/src/component/tooltip/TooltipView.js +92 -20
- package/src/component/visualMap/ContinuousView.js +6 -4
- package/src/coord/Axis.js +34 -2
- package/src/coord/axisDefault.js +4 -1
- package/src/coord/axisHelper.js +32 -26
- package/src/coord/axisModelCommonMixin.js +1 -1
- package/src/coord/calendar/Calendar.js +14 -17
- package/src/coord/calendar/prepareCustom.js +32 -0
- package/src/coord/cartesian/Axis2D.js +0 -12
- package/src/coord/cartesian/Cartesian2D.js +1 -0
- package/src/coord/cartesian/Grid.js +5 -2
- package/src/coord/cartesian/prepareCustom.js +37 -0
- package/src/coord/geo/Geo.js +9 -14
- package/src/coord/geo/GeoModel.js +5 -5
- package/src/coord/geo/geoCreator.js +3 -3
- package/src/coord/geo/parseGeoJson.js +11 -4
- package/src/coord/geo/prepareCustom.js +37 -0
- package/src/coord/parallel/Parallel.js +225 -101
- package/src/coord/parallel/ParallelModel.js +7 -1
- package/src/coord/polar/Polar.js +2 -1
- package/src/coord/polar/prepareCustom.js +54 -0
- package/src/coord/single/Single.js +9 -8
- package/src/coord/single/SingleAxis.js +0 -27
- package/src/coord/single/prepareCustom.js +34 -0
- package/src/data/DataDiffer.js +2 -1
- package/src/data/Graph.js +11 -7
- package/src/data/List.js +59 -20
- package/src/data/helper/completeDimensions.js +184 -23
- package/src/echarts.js +68 -36
- package/src/helper.js +1 -8
- package/src/layout/barGrid.js +91 -19
- package/src/layout/barPolar.js +287 -0
- package/src/layout/points.js +22 -16
- package/src/model/Global.js +34 -31
- package/src/model/Series.js +41 -29
- package/src/model/globalDefault.js +4 -1
- package/src/model/mixin/colorPalette.js +2 -1
- package/src/model/mixin/textStyle.js +7 -13
- package/src/scale/Interval.js +46 -76
- package/src/scale/Log.js +5 -7
- package/src/scale/Scale.js +10 -1
- package/src/scale/Time.js +34 -12
- package/src/scale/helper.js +94 -0
- package/src/util/format.js +20 -9
- package/src/util/graphic.js +70 -8
- package/src/util/layout.js +7 -3
- package/src/util/model.js +63 -7
- package/src/util/number.js +59 -19
- package/src/util/throttle.js +14 -3
- package/src/coord/cartesian/axisLabelInterval.js +0 -26
- package/theme/default.js +0 -23
- package/theme/halloween.js +0 -528
package/lib/util/graphic.js
CHANGED
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
var zrUtil = require('zrender/lib/core/util');
|
|
5
5
|
|
|
6
6
|
var pathTool = require('zrender/lib/tool/path');
|
|
7
|
-
var round = Math.round;
|
|
8
7
|
var Path = require('zrender/lib/graphic/Path');
|
|
9
8
|
var colorTool = require('zrender/lib/tool/color');
|
|
10
9
|
var matrix = require('zrender/lib/core/matrix');
|
|
11
10
|
var vector = require('zrender/lib/core/vector');
|
|
11
|
+
var Transformable = require('zrender/lib/mixin/Transformable');
|
|
12
|
+
var BoundingRect = require('zrender/lib/core/BoundingRect');
|
|
13
|
+
|
|
14
|
+
var round = Math.round;
|
|
15
|
+
var mathMax = Math.max;
|
|
16
|
+
var mathMin = Math.min;
|
|
12
17
|
|
|
13
18
|
var graphic = {};
|
|
14
19
|
|
|
@@ -42,7 +47,7 @@
|
|
|
42
47
|
|
|
43
48
|
graphic.RadialGradient = require('zrender/lib/graphic/RadialGradient');
|
|
44
49
|
|
|
45
|
-
graphic.BoundingRect =
|
|
50
|
+
graphic.BoundingRect = BoundingRect;
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* Extend shape with parameters
|
|
@@ -404,6 +409,17 @@
|
|
|
404
409
|
});
|
|
405
410
|
};
|
|
406
411
|
|
|
412
|
+
graphic.getFont = function (opt, ecModel) {
|
|
413
|
+
var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
|
|
414
|
+
return [
|
|
415
|
+
// FIXME in node-canvas fontWeight is before fontStyle
|
|
416
|
+
opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
|
|
417
|
+
opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '',
|
|
418
|
+
(opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px',
|
|
419
|
+
opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'
|
|
420
|
+
].join(' ');
|
|
421
|
+
};
|
|
422
|
+
|
|
407
423
|
function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
|
|
408
424
|
if (typeof dataIndex === 'function') {
|
|
409
425
|
cb = dataIndex;
|
|
@@ -433,9 +449,10 @@
|
|
|
433
449
|
|
|
434
450
|
duration > 0
|
|
435
451
|
? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
|
|
436
|
-
: (el.attr(props), cb && cb());
|
|
452
|
+
: (el.stopAnimation(), el.attr(props), cb && cb());
|
|
437
453
|
}
|
|
438
454
|
else {
|
|
455
|
+
el.stopAnimation();
|
|
439
456
|
el.attr(props);
|
|
440
457
|
cb && cb();
|
|
441
458
|
}
|
|
@@ -493,16 +510,22 @@
|
|
|
493
510
|
|
|
494
511
|
/**
|
|
495
512
|
* Apply transform to an vertex.
|
|
496
|
-
* @param {Array.<number>}
|
|
497
|
-
* @param {Array.<number
|
|
513
|
+
* @param {Array.<number>} target [x, y]
|
|
514
|
+
* @param {Array.<number>|TypedArray.<number>|Object} transform Can be:
|
|
515
|
+
* + Transform matrix: like [1, 0, 0, 1, 0, 0]
|
|
516
|
+
* + {position, rotation, scale}, the same as `zrender/Transformable`.
|
|
498
517
|
* @param {boolean=} invert Whether use invert matrix.
|
|
499
518
|
* @return {Array.<number>} [x, y]
|
|
500
519
|
*/
|
|
501
|
-
graphic.applyTransform = function (
|
|
520
|
+
graphic.applyTransform = function (target, transform, invert) {
|
|
521
|
+
if (transform && !zrUtil.isArrayLike(transform)) {
|
|
522
|
+
transform = Transformable.getLocalTransform(transform);
|
|
523
|
+
}
|
|
524
|
+
|
|
502
525
|
if (invert) {
|
|
503
526
|
transform = matrix.invert([], transform);
|
|
504
527
|
}
|
|
505
|
-
return vector.applyTransform([],
|
|
528
|
+
return vector.applyTransform([], target, transform);
|
|
506
529
|
};
|
|
507
530
|
|
|
508
531
|
/**
|
|
@@ -532,7 +555,8 @@
|
|
|
532
555
|
};
|
|
533
556
|
|
|
534
557
|
/**
|
|
535
|
-
* Apply group transition animation from g1 to g2
|
|
558
|
+
* Apply group transition animation from g1 to g2.
|
|
559
|
+
* If no animatableModel, no animation.
|
|
536
560
|
*/
|
|
537
561
|
graphic.groupTransition = function (g1, g2, animatableModel, cb) {
|
|
538
562
|
if (!g1 || !g2) {
|
|
@@ -577,5 +601,43 @@
|
|
|
577
601
|
});
|
|
578
602
|
};
|
|
579
603
|
|
|
604
|
+
/**
|
|
605
|
+
* @param {Array.<Array.<number>>} points Like: [[23, 44], [53, 66], ...]
|
|
606
|
+
* @param {Object} rect {x, y, width, height}
|
|
607
|
+
* @return {Array.<Array.<number>>} A new clipped points.
|
|
608
|
+
*/
|
|
609
|
+
graphic.clipPointsByRect = function (points, rect) {
|
|
610
|
+
return zrUtil.map(points, function (point) {
|
|
611
|
+
var x = point[0];
|
|
612
|
+
x = mathMax(x, rect.x);
|
|
613
|
+
x = mathMin(x, rect.x + rect.width);
|
|
614
|
+
var y = point[1];
|
|
615
|
+
y = mathMax(y, rect.y);
|
|
616
|
+
y = mathMin(y, rect.y + rect.height);
|
|
617
|
+
return [x, y];
|
|
618
|
+
});
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* @param {Object} targetRect {x, y, width, height}
|
|
623
|
+
* @param {Object} rect {x, y, width, height}
|
|
624
|
+
* @return {Object} A new clipped rect. If rect size are negative, return undefined.
|
|
625
|
+
*/
|
|
626
|
+
graphic.clipRectByRect = function (targetRect, rect) {
|
|
627
|
+
var x = mathMax(targetRect.x, rect.x);
|
|
628
|
+
var x2 = mathMin(targetRect.x + targetRect.width, rect.x + rect.width);
|
|
629
|
+
var y = mathMax(targetRect.y, rect.y);
|
|
630
|
+
var y2 = mathMin(targetRect.y + targetRect.height, rect.y + rect.height);
|
|
631
|
+
|
|
632
|
+
if (x2 >= x && y2 >= y) {
|
|
633
|
+
return {
|
|
634
|
+
x: x,
|
|
635
|
+
y: y,
|
|
636
|
+
width: x2 - x,
|
|
637
|
+
height: y2 - y
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
|
|
580
642
|
module.exports = graphic;
|
|
581
643
|
|
package/lib/util/layout.js
CHANGED
|
@@ -405,9 +405,13 @@
|
|
|
405
405
|
});
|
|
406
406
|
|
|
407
407
|
if (ignoreSize[hvIdx]) {
|
|
408
|
-
// Only one of left/
|
|
409
|
-
hasValue(newOption, names[
|
|
410
|
-
|
|
408
|
+
// Only one of left/right is premitted to exist.
|
|
409
|
+
if (hasValue(newOption, names[1])) {
|
|
410
|
+
merged[names[2]] = null;
|
|
411
|
+
}
|
|
412
|
+
else if (hasValue(newOption, names[2])) {
|
|
413
|
+
merged[names[1]] = null;
|
|
414
|
+
}
|
|
411
415
|
return merged;
|
|
412
416
|
}
|
|
413
417
|
|
package/lib/util/model.js
CHANGED
|
@@ -145,6 +145,7 @@
|
|
|
145
145
|
var rawDataIndex = data.getRawIndex(dataIndex);
|
|
146
146
|
var name = data.getName(dataIndex, true);
|
|
147
147
|
var itemOpt = data.getRawDataItem(dataIndex);
|
|
148
|
+
var color = data.getItemVisual(dataIndex, 'color');
|
|
148
149
|
|
|
149
150
|
return {
|
|
150
151
|
componentType: this.mainType,
|
|
@@ -158,7 +159,8 @@
|
|
|
158
159
|
data: itemOpt,
|
|
159
160
|
dataType: dataType,
|
|
160
161
|
value: rawValue,
|
|
161
|
-
color:
|
|
162
|
+
color: color,
|
|
163
|
+
marker: formatUtil.getTooltipMarker(color),
|
|
162
164
|
|
|
163
165
|
// Param name list for mapping `a`, `b`, `c`, `d`, `e`
|
|
164
166
|
$vars: ['seriesName', 'name', 'value']
|
|
@@ -333,22 +335,22 @@
|
|
|
333
335
|
// to specify multi components (like series) by one name.
|
|
334
336
|
|
|
335
337
|
// Ensure that each id is distinct.
|
|
336
|
-
var idMap =
|
|
338
|
+
var idMap = zrUtil.createHashMap();
|
|
337
339
|
|
|
338
340
|
each(mapResult, function (item, index) {
|
|
339
341
|
var existCpt = item.exist;
|
|
340
|
-
existCpt && (
|
|
342
|
+
existCpt && idMap.set(existCpt.id, item);
|
|
341
343
|
});
|
|
342
344
|
|
|
343
345
|
each(mapResult, function (item, index) {
|
|
344
346
|
var opt = item.option;
|
|
345
347
|
|
|
346
348
|
zrUtil.assert(
|
|
347
|
-
!opt || opt.id == null || !idMap
|
|
349
|
+
!opt || opt.id == null || !idMap.get(opt.id) || idMap.get(opt.id) === item,
|
|
348
350
|
'id duplicates: ' + (opt && opt.id)
|
|
349
351
|
);
|
|
350
352
|
|
|
351
|
-
opt && opt.id != null && (
|
|
353
|
+
opt && opt.id != null && idMap.set(opt.id, item);
|
|
352
354
|
!item.keyInfo && (item.keyInfo = {});
|
|
353
355
|
});
|
|
354
356
|
|
|
@@ -388,10 +390,10 @@
|
|
|
388
390
|
do {
|
|
389
391
|
keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
|
|
390
392
|
}
|
|
391
|
-
while (idMap
|
|
393
|
+
while (idMap.get(keyInfo.id));
|
|
392
394
|
}
|
|
393
395
|
|
|
394
|
-
idMap
|
|
396
|
+
idMap.set(keyInfo.id, item);
|
|
395
397
|
});
|
|
396
398
|
};
|
|
397
399
|
|
|
@@ -597,6 +599,60 @@
|
|
|
597
599
|
return result;
|
|
598
600
|
};
|
|
599
601
|
|
|
602
|
+
/**
|
|
603
|
+
* @see {module:echarts/data/helper/completeDimensions}
|
|
604
|
+
* @param {module:echarts/data/List} data
|
|
605
|
+
* @param {string|number} dataDim
|
|
606
|
+
* @return {string}
|
|
607
|
+
*/
|
|
608
|
+
modelUtil.dataDimToCoordDim = function (data, dataDim) {
|
|
609
|
+
var dimensions = data.dimensions;
|
|
610
|
+
dataDim = data.getDimension(dataDim);
|
|
611
|
+
for (var i = 0; i < dimensions.length; i++) {
|
|
612
|
+
var dimItem = data.getDimensionInfo(dimensions[i]);
|
|
613
|
+
if (dimItem.name === dataDim) {
|
|
614
|
+
return dimItem.coordDim;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @see {module:echarts/data/helper/completeDimensions}
|
|
621
|
+
* @param {module:echarts/data/List} data
|
|
622
|
+
* @param {string} coordDim
|
|
623
|
+
* @return {Array.<string>} data dimensions on the coordDim.
|
|
624
|
+
*/
|
|
625
|
+
modelUtil.coordDimToDataDim = function (data, coordDim) {
|
|
626
|
+
var dataDim = [];
|
|
627
|
+
each(data.dimensions, function (dimName) {
|
|
628
|
+
var dimItem = data.getDimensionInfo(dimName);
|
|
629
|
+
if (dimItem.coordDim === coordDim) {
|
|
630
|
+
dataDim[dimItem.coordDimIndex] = dimItem.name;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
return dataDim;
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @see {module:echarts/data/helper/completeDimensions}
|
|
638
|
+
* @param {module:echarts/data/List} data
|
|
639
|
+
* @param {string} otherDim Can be `otherDims`
|
|
640
|
+
* like 'label' or 'tooltip'.
|
|
641
|
+
* @return {Array.<string>} data dimensions on the otherDim.
|
|
642
|
+
*/
|
|
643
|
+
modelUtil.otherDimToDataDim = function (data, otherDim) {
|
|
644
|
+
var dataDim = [];
|
|
645
|
+
each(data.dimensions, function (dimName) {
|
|
646
|
+
var dimItem = data.getDimensionInfo(dimName);
|
|
647
|
+
var otherDims = dimItem.otherDims;
|
|
648
|
+
var dimIndex = otherDims[otherDim];
|
|
649
|
+
if (dimIndex != null && dimIndex !== false) {
|
|
650
|
+
dataDim[dimIndex] = dimItem.name;
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
return dataDim;
|
|
654
|
+
};
|
|
655
|
+
|
|
600
656
|
function has(obj, prop) {
|
|
601
657
|
return obj && obj.hasOwnProperty(prop);
|
|
602
658
|
}
|
package/lib/util/number.js
CHANGED
|
@@ -102,7 +102,9 @@
|
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* Fix rounding error of float numbers
|
|
105
|
+
* (1) Fix rounding error of float numbers.
|
|
106
|
+
* (2) Support return string to avoid scientific notation like '3.5e-7'.
|
|
107
|
+
*
|
|
106
108
|
* @param {number} x
|
|
107
109
|
* @param {number} [precision]
|
|
108
110
|
* @param {boolean} [returnStr]
|
|
@@ -147,17 +149,28 @@
|
|
|
147
149
|
return count;
|
|
148
150
|
};
|
|
149
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @param {string|number} val
|
|
154
|
+
* @return {number}
|
|
155
|
+
*/
|
|
150
156
|
number.getPrecisionSafe = function (val) {
|
|
151
157
|
var str = val.toString();
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
|
|
159
|
+
// Consider scientific notation: '3.4e-12' '3.4e+12'
|
|
160
|
+
var eIndex = str.indexOf('e');
|
|
161
|
+
if (eIndex > 0) {
|
|
162
|
+
var precision = +str.slice(eIndex + 1);
|
|
163
|
+
return precision < 0 ? -precision : 0;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
var dotIndex = str.indexOf('.');
|
|
167
|
+
return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
|
|
155
168
|
}
|
|
156
|
-
return str.length - 1 - dotIndex;
|
|
157
169
|
};
|
|
158
170
|
|
|
159
171
|
/**
|
|
160
172
|
* Minimal dicernible data precisioin according to a single pixel.
|
|
173
|
+
*
|
|
161
174
|
* @param {Array.<number>} dataExtent
|
|
162
175
|
* @param {Array.<number>} pixelExtent
|
|
163
176
|
* @return {number} precision
|
|
@@ -193,8 +206,14 @@
|
|
|
193
206
|
return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
|
|
194
207
|
};
|
|
195
208
|
|
|
196
|
-
var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(
|
|
197
|
-
|
|
209
|
+
var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @return {number} in minutes
|
|
213
|
+
*/
|
|
214
|
+
number.getTimezoneOffset = function () {
|
|
215
|
+
return (new Date()).getTimezoneOffset();
|
|
216
|
+
};
|
|
198
217
|
|
|
199
218
|
/**
|
|
200
219
|
* @param {string|Date|number} value These values can be accepted:
|
|
@@ -203,9 +222,9 @@
|
|
|
203
222
|
* + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
|
|
204
223
|
* + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
|
|
205
224
|
* + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
|
|
206
|
-
* all of which will be treated as
|
|
207
|
-
*
|
|
208
|
-
* + Or other string format, including:
|
|
225
|
+
* all of which will be treated as local time if time zone is not specified
|
|
226
|
+
* (see <https://momentjs.com/>).
|
|
227
|
+
* + Or other string format, including (all of which will be treated as loacal time):
|
|
209
228
|
* '2012', '2012-3-1', '2012/3/1', '2012/03/01',
|
|
210
229
|
* '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
|
|
211
230
|
* + a timestamp, which represent a time in UTC.
|
|
@@ -228,6 +247,13 @@
|
|
|
228
247
|
return new Date(NaN);
|
|
229
248
|
}
|
|
230
249
|
|
|
250
|
+
var timezoneOffset = number.getTimezoneOffset();
|
|
251
|
+
var timeOffset = !match[8]
|
|
252
|
+
? 0
|
|
253
|
+
: match[8].toUpperCase() === 'Z'
|
|
254
|
+
? timezoneOffset
|
|
255
|
+
: +match[8].slice(0, 3) * 60 + timezoneOffset;
|
|
256
|
+
|
|
231
257
|
// match[n] can only be string or undefined.
|
|
232
258
|
// But take care of '12' + 1 => '121'.
|
|
233
259
|
return new Date(
|
|
@@ -235,7 +261,7 @@
|
|
|
235
261
|
+(match[2] || 1) - 1,
|
|
236
262
|
+match[3] || 1,
|
|
237
263
|
+match[4] || 0,
|
|
238
|
-
+(match[5] || 0) -
|
|
264
|
+
+(match[5] || 0) - timeOffset,
|
|
239
265
|
+match[6] || 0,
|
|
240
266
|
+match[7] || 0
|
|
241
267
|
);
|
|
@@ -249,24 +275,33 @@
|
|
|
249
275
|
|
|
250
276
|
/**
|
|
251
277
|
* Quantity of a number. e.g. 0.1, 1, 10, 100
|
|
278
|
+
*
|
|
252
279
|
* @param {number} val
|
|
253
280
|
* @return {number}
|
|
254
281
|
*/
|
|
255
282
|
number.quantity = function (val) {
|
|
256
|
-
return Math.pow(10,
|
|
283
|
+
return Math.pow(10, quantityExponent(val));
|
|
257
284
|
};
|
|
258
285
|
|
|
259
|
-
|
|
286
|
+
function quantityExponent(val) {
|
|
287
|
+
return Math.floor(Math.log(val) / Math.LN10);
|
|
288
|
+
}
|
|
289
|
+
|
|
260
290
|
/**
|
|
261
|
-
* find a “nice” number approximately equal to x. Round the number if round = true,
|
|
262
|
-
* The primary observation is that the “nicest”
|
|
263
|
-
*
|
|
291
|
+
* find a “nice” number approximately equal to x. Round the number if round = true,
|
|
292
|
+
* take ceiling if round = false. The primary observation is that the “nicest”
|
|
293
|
+
* numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
|
|
294
|
+
*
|
|
295
|
+
* See "Nice Numbers for Graph Labels" of Graphic Gems.
|
|
296
|
+
*
|
|
297
|
+
* @param {number} val Non-negative value.
|
|
264
298
|
* @param {boolean} round
|
|
265
299
|
* @return {number}
|
|
266
300
|
*/
|
|
267
301
|
number.nice = function (val, round) {
|
|
268
|
-
var
|
|
269
|
-
var
|
|
302
|
+
var exponent = quantityExponent(val);
|
|
303
|
+
var exp10 = Math.pow(10, exponent);
|
|
304
|
+
var f = val / exp10; // 1 <= f < 10
|
|
270
305
|
var nf;
|
|
271
306
|
if (round) {
|
|
272
307
|
if (f < 1.5) { nf = 1; }
|
|
@@ -282,7 +317,11 @@
|
|
|
282
317
|
else if (f < 5) { nf = 5; }
|
|
283
318
|
else { nf = 10; }
|
|
284
319
|
}
|
|
285
|
-
|
|
320
|
+
val = nf * exp10;
|
|
321
|
+
|
|
322
|
+
// Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
|
|
323
|
+
// 20 is the uppper bound of toFixed.
|
|
324
|
+
return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
|
|
286
325
|
};
|
|
287
326
|
|
|
288
327
|
/**
|
|
@@ -353,6 +392,7 @@
|
|
|
353
392
|
* parseFloat NaNs numeric-cast false positives (null|true|false|"")
|
|
354
393
|
* ...but misinterprets leading-number strings, particularly hex literals ("0x...")
|
|
355
394
|
* subtraction forces infinities to NaN
|
|
395
|
+
*
|
|
356
396
|
* @param {*} v
|
|
357
397
|
* @return {boolean}
|
|
358
398
|
*/
|
package/lib/util/throttle.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
var diff;
|
|
25
25
|
var scope;
|
|
26
26
|
var args;
|
|
27
|
+
var debounceNextCall;
|
|
27
28
|
|
|
28
29
|
delay = delay || 0;
|
|
29
30
|
|
|
@@ -37,12 +38,15 @@
|
|
|
37
38
|
currCall = (new Date()).getTime();
|
|
38
39
|
scope = this;
|
|
39
40
|
args = arguments;
|
|
40
|
-
|
|
41
|
+
var thisDelay = debounceNextCall || delay;
|
|
42
|
+
var thisDebounce = debounceNextCall || debounce;
|
|
43
|
+
debounceNextCall = null;
|
|
44
|
+
diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay;
|
|
41
45
|
|
|
42
46
|
clearTimeout(timer);
|
|
43
47
|
|
|
44
|
-
if (
|
|
45
|
-
timer = setTimeout(exec,
|
|
48
|
+
if (thisDebounce) {
|
|
49
|
+
timer = setTimeout(exec, thisDelay);
|
|
46
50
|
}
|
|
47
51
|
else {
|
|
48
52
|
if (diff >= 0) {
|
|
@@ -67,6 +71,13 @@
|
|
|
67
71
|
}
|
|
68
72
|
};
|
|
69
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Enable debounce once.
|
|
76
|
+
*/
|
|
77
|
+
cb.debounceNextCall = function (debounceDelay) {
|
|
78
|
+
debounceNextCall = debounceDelay;
|
|
79
|
+
};
|
|
80
|
+
|
|
70
81
|
return cb;
|
|
71
82
|
};
|
|
72
83
|
|