echarts 4.5.0 → 4.9.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/.DS_Store +0 -0
- package/.gitattributes +3 -0
- package/.github/pull_request_template.md +66 -0
- package/.github/workflows/nodejs.yml +15 -3
- package/.huskyrc +5 -0
- package/CONTRIBUTING.md +16 -160
- package/NOTICE +1 -1
- package/README.md +3 -3
- package/asset/.DS_Store +0 -0
- package/build/.DS_Store +0 -0
- package/dist/echarts-en.common.js +3072 -1261
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +4339 -1685
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +2496 -1011
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +3046 -1261
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +4313 -1685
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +2470 -1011
- package/dist/echarts.simple.min.js +1 -1
- package/dist/extension/bmap.js +33 -11
- package/dist/extension/bmap.js.map +1 -1
- package/dist/extension/bmap.min.js +1 -1
- package/dist/extension/dataTool.js.map +1 -1
- package/extension/.DS_Store +0 -0
- package/extension/bmap/BMapCoordSys.js +14 -4
- package/extension/bmap/BMapModel.js +4 -0
- package/extension/bmap/BMapView.js +18 -10
- package/extension-src/bmap/BMapCoordSys.js +14 -4
- package/extension-src/bmap/BMapModel.js +6 -1
- package/extension-src/bmap/BMapView.js +16 -9
- package/lib/chart/bar/BarSeries.js +14 -1
- package/lib/chart/bar/BarView.js +196 -18
- package/lib/chart/bar/BaseBarSeries.js +3 -1
- package/lib/chart/bar/PictorialBarSeries.js +1 -1
- package/lib/chart/candlestick/candlestickVisual.js +1 -1
- package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
- package/lib/chart/funnel/FunnelSeries.js +14 -5
- package/lib/chart/funnel/funnelLayout.js +162 -46
- package/lib/chart/gauge/GaugeSeries.js +0 -2
- package/lib/chart/graph/GraphSeries.js +23 -7
- package/lib/chart/graph/GraphView.js +30 -12
- package/lib/chart/graph/circularLayoutHelper.js +8 -2
- package/lib/chart/graph/forceLayout.js +6 -1
- package/lib/chart/graph/simpleLayout.js +1 -1
- package/lib/chart/graph/simpleLayoutHelper.js +10 -4
- package/lib/chart/heatmap/HeatmapView.js +4 -4
- package/lib/chart/helper/EffectLine.js +23 -1
- package/lib/chart/helper/EffectSymbol.js +2 -1
- package/lib/chart/helper/Line.js +129 -42
- package/lib/chart/helper/LineDraw.js +5 -1
- package/lib/chart/helper/Symbol.js +2 -3
- package/lib/chart/helper/createClipPathFromCoordSys.js +4 -1
- package/lib/chart/helper/createListFromArray.js +14 -8
- package/lib/chart/helper/createRenderPlanner.js +6 -3
- package/lib/chart/helper/multipleGraphEdgeHelper.js +258 -0
- package/lib/chart/helper/whiskerBoxCommon.js +22 -16
- package/lib/chart/line/LineSeries.js +3 -1
- package/lib/chart/line/LineView.js +41 -2
- package/lib/chart/lines/LinesSeries.js +0 -2
- package/lib/chart/map/MapSeries.js +14 -5
- package/lib/chart/pie/PieSeries.js +27 -6
- package/lib/chart/pie/PieView.js +22 -15
- package/lib/chart/pie/labelLayout.js +102 -19
- package/lib/chart/pie/pieLayout.js +19 -7
- package/lib/chart/radar/RadarSeries.js +27 -6
- package/lib/chart/radar/RadarView.js +3 -1
- package/lib/chart/sankey/SankeySeries.js +13 -1
- package/lib/chart/sankey/SankeyView.js +70 -32
- package/lib/chart/sankey/sankeyLayout.js +22 -3
- package/lib/chart/scatter/ScatterSeries.js +3 -1
- package/lib/chart/sunburst/SunburstPiece.js +5 -1
- package/lib/chart/sunburst/SunburstSeries.js +29 -12
- package/lib/chart/sunburst/SunburstView.js +5 -1
- package/lib/chart/themeRiver/ThemeRiverSeries.js +24 -33
- package/lib/chart/tree/TreeSeries.js +20 -3
- package/lib/chart/tree/TreeView.js +149 -23
- package/lib/chart/treemap/TreemapSeries.js +25 -4
- package/lib/chart/treemap/TreemapView.js +80 -38
- package/lib/chart/treemap/treemapLayout.js +1 -1
- package/lib/chart/treemap/treemapVisual.js +9 -15
- package/lib/component/axis/AngleAxisView.js +64 -7
- package/lib/component/axis/AxisBuilder.js +62 -24
- package/lib/component/axis/CartesianAxisView.js +52 -85
- package/lib/component/axis/RadiusAxisView.js +36 -4
- package/lib/component/axis/SingleAxisView.js +21 -6
- package/lib/component/axis/axisSplitHelper.js +132 -0
- package/lib/component/axisPointer/axisTrigger.js +1 -1
- package/lib/component/brush/BrushView.js +11 -1
- package/lib/component/brush/visualEncoding.js +13 -2
- package/lib/component/dataZoom/SliderZoomView.js +4 -10
- package/lib/component/helper/BrushController.js +33 -43
- package/lib/component/helper/MapDraw.js +30 -4
- package/lib/component/legend/LegendModel.js +3 -3
- package/lib/component/legend/LegendView.js +17 -13
- package/lib/component/legend/ScrollableLegendView.js +18 -18
- package/lib/component/marker/MarkAreaView.js +53 -15
- package/lib/component/marker/MarkLineModel.js +2 -1
- package/lib/component/marker/MarkLineView.js +3 -0
- package/lib/component/marker/MarkPointView.js +8 -1
- package/lib/component/marker/MarkerModel.js +3 -2
- package/lib/component/marker/markerHelper.js +7 -4
- package/lib/component/timeline/SliderTimelineView.js +7 -1
- package/lib/component/title.js +6 -2
- package/lib/component/toolbox/ToolboxView.js +5 -1
- package/lib/component/toolbox/feature/DataView.js +23 -8
- package/lib/component/toolbox/feature/DataZoom.js +6 -6
- package/lib/component/toolbox/feature/MagicType.js +20 -14
- package/lib/component/toolbox/feature/SaveAsImage.js +4 -2
- package/lib/component/tooltip/TooltipContent.js +101 -30
- package/lib/component/tooltip/TooltipRichContent.js +56 -8
- package/lib/component/tooltip/TooltipView.js +11 -12
- package/lib/component/visualMap/PiecewiseModel.js +3 -6
- package/lib/component/visualMap/VisualMapModel.js +1 -1
- package/lib/coord/Axis.js +30 -2
- package/lib/coord/View.js +9 -0
- package/lib/coord/axisDefault.js +22 -3
- package/lib/coord/axisHelper.js +24 -18
- package/lib/coord/calendar/Calendar.js +8 -4
- package/lib/coord/geo/GeoModel.js +2 -1
- package/lib/coord/geo/geoJSONLoader.js +3 -2
- package/lib/coord/geo/geoSourceManager.js +3 -2
- package/lib/coord/geo/parseGeoJson.js +3 -2
- package/lib/coord/radar/Radar.js +5 -5
- package/lib/data/DataDimensionInfo.js +157 -0
- package/lib/data/Graph.js +1 -6
- package/lib/data/List.js +26 -20
- package/lib/data/Tree.js +5 -42
- package/lib/data/helper/completeDimensions.js +43 -32
- package/lib/data/helper/createDimensions.js +2 -0
- package/lib/data/helper/sourceHelper.js +214 -114
- package/lib/echarts.js +57 -34
- package/lib/langEN.js +26 -0
- package/lib/layout/barGrid.js +19 -13
- package/lib/layout/barPolar.js +1 -6
- package/lib/loading/default.js +43 -27
- package/lib/model/Series.js +4 -4
- package/lib/model/referHelper.js +40 -12
- package/lib/processor/dataSample.js +1 -1
- package/lib/scale/Interval.js +87 -2
- package/lib/scale/Log.js +9 -2
- package/lib/scale/helper.js +1 -43
- package/lib/stream/Scheduler.js +10 -2
- package/lib/theme/dark.js +3 -0
- package/lib/util/format.js +19 -2
- package/lib/util/graphic.js +14 -12
- package/lib/visual/LegendVisualProvider.js +75 -0
- package/lib/visual/VisualMapping.js +1 -1
- package/lib/visual/dataColor.js +2 -12
- package/lib/visual/seriesColor.js +15 -7
- package/lib/visual/symbol.js +12 -2
- package/map/.DS_Store +0 -0
- package/map/js/.DS_Store +0 -0
- package/map/js/china.js +1 -1
- package/map/js/province/.DS_Store +0 -0
- package/map/js/province/chongqing.js +1 -1
- package/map/js/province/gansu.js +2 -2
- package/map/js/province/tianjin.js +1 -28
- package/map/json/.DS_Store +0 -0
- package/map/json/china.json +1 -1
- package/map/json/province/chongqing.json +1 -1
- package/map/json/province/tianjin.json +1 -1
- package/package.json +12 -6
- package/src/.DS_Store +0 -0
- package/src/chart/.DS_Store +0 -0
- package/src/chart/bar/BarSeries.js +15 -1
- package/src/chart/bar/BarView.js +198 -17
- package/src/chart/bar/BaseBarSeries.js +1 -1
- package/src/chart/bar/PictorialBarSeries.js +2 -2
- package/src/chart/candlestick/candlestickVisual.js +1 -1
- package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
- package/src/chart/funnel/FunnelSeries.js +11 -4
- package/src/chart/funnel/funnelLayout.js +179 -53
- package/src/chart/gauge/GaugeSeries.js +0 -1
- package/src/chart/graph/GraphSeries.js +19 -7
- package/src/chart/graph/GraphView.js +28 -10
- package/src/chart/graph/circularLayoutHelper.js +8 -2
- package/src/chart/graph/forceLayout.js +7 -1
- package/src/chart/graph/simpleLayout.js +1 -1
- package/src/chart/graph/simpleLayoutHelper.js +12 -5
- package/src/chart/heatmap/HeatmapView.js +4 -4
- package/src/chart/helper/EffectLine.js +23 -1
- package/src/chart/helper/EffectSymbol.js +2 -1
- package/src/chart/helper/Line.js +122 -37
- package/src/chart/helper/LineDraw.js +5 -1
- package/src/chart/helper/Symbol.js +4 -4
- package/src/chart/helper/createClipPathFromCoordSys.js +4 -0
- package/src/chart/helper/createGraphFromNodeEdge.js +2 -1
- package/src/chart/helper/createListFromArray.js +13 -8
- package/src/chart/helper/createRenderPlanner.js +5 -2
- package/src/chart/helper/multipleGraphEdgeHelper.js +229 -0
- package/src/chart/helper/whiskerBoxCommon.js +21 -16
- package/src/chart/line/LineSeries.js +1 -1
- package/src/chart/line/LineView.js +45 -1
- package/src/chart/lines/LinesSeries.js +1 -3
- package/src/chart/map/MapSeries.js +11 -5
- package/src/chart/pie/PieSeries.js +26 -5
- package/src/chart/pie/PieView.js +20 -15
- package/src/chart/pie/labelLayout.js +114 -22
- package/src/chart/pie/pieLayout.js +20 -7
- package/src/chart/radar/RadarSeries.js +31 -6
- package/src/chart/radar/RadarView.js +4 -2
- package/src/chart/sankey/SankeySeries.js +12 -1
- package/src/chart/sankey/SankeyView.js +75 -30
- package/src/chart/sankey/sankeyLayout.js +25 -5
- package/src/chart/scatter/ScatterSeries.js +1 -1
- package/src/chart/sunburst/SunburstPiece.js +7 -1
- package/src/chart/sunburst/SunburstSeries.js +28 -15
- package/src/chart/sunburst/SunburstView.js +2 -1
- package/src/chart/themeRiver/ThemeRiverSeries.js +25 -30
- package/src/chart/tree/TreeSeries.js +19 -6
- package/src/chart/tree/TreeView.js +156 -23
- package/src/chart/treemap/TreemapSeries.js +23 -5
- package/src/chart/treemap/TreemapView.js +77 -41
- package/src/chart/treemap/treemapLayout.js +2 -2
- package/src/chart/treemap/treemapVisual.js +8 -25
- package/src/component/axis/AngleAxisView.js +75 -7
- package/src/component/axis/AxisBuilder.js +77 -32
- package/src/component/axis/CartesianAxisView.js +47 -83
- package/src/component/axis/RadiusAxisView.js +37 -4
- package/src/component/axis/SingleAxisView.js +21 -4
- package/src/component/axis/axisSplitHelper.js +114 -0
- package/src/component/axisPointer/axisTrigger.js +1 -1
- package/src/component/brush/BrushView.js +8 -1
- package/src/component/brush/visualEncoding.js +6 -3
- package/src/component/dataZoom/SliderZoomView.js +4 -9
- package/src/component/helper/BrushController.js +40 -47
- package/src/component/helper/MapDraw.js +27 -4
- package/src/component/legend/LegendModel.js +3 -3
- package/src/component/legend/LegendView.js +18 -12
- package/src/component/legend/ScrollableLegendView.js +18 -16
- package/src/component/marker/MarkAreaView.js +53 -15
- package/src/component/marker/MarkLineModel.js +2 -1
- package/src/component/marker/MarkLineView.js +3 -1
- package/src/component/marker/MarkPointView.js +7 -1
- package/src/component/marker/MarkerModel.js +3 -2
- package/src/component/marker/markerHelper.js +8 -5
- package/src/component/timeline/SliderTimelineView.js +9 -6
- package/src/component/title.js +4 -3
- package/src/component/toolbox/.DS_Store +0 -0
- package/src/component/toolbox/ToolboxView.js +5 -0
- package/src/component/toolbox/feature/DataView.js +20 -8
- package/src/component/toolbox/feature/DataZoom.js +6 -6
- package/src/component/toolbox/feature/MagicType.js +19 -13
- package/src/component/toolbox/feature/SaveAsImage.js +4 -2
- package/src/component/tooltip/TooltipContent.js +94 -28
- package/src/component/tooltip/TooltipRichContent.js +52 -9
- package/src/component/tooltip/TooltipView.js +14 -12
- package/src/component/visualMap/PiecewiseModel.js +5 -9
- package/src/component/visualMap/VisualMapModel.js +1 -1
- package/src/coord/Axis.js +29 -2
- package/src/coord/View.js +10 -1
- package/src/coord/axisDefault.js +26 -2
- package/src/coord/axisHelper.js +30 -21
- package/src/coord/calendar/Calendar.js +12 -5
- package/src/coord/geo/GeoModel.js +3 -6
- package/src/coord/geo/geoJSONLoader.js +3 -2
- package/src/coord/geo/geoSourceManager.js +3 -2
- package/src/coord/geo/parseGeoJson.js +3 -2
- package/src/coord/radar/Radar.js +6 -8
- package/src/data/DataDimensionInfo.js +135 -0
- package/src/data/Graph.js +0 -5
- package/src/data/List.js +30 -17
- package/src/data/Tree.js +6 -39
- package/src/data/helper/completeDimensions.js +49 -30
- package/src/data/helper/createDimensions.js +2 -0
- package/src/data/helper/sourceHelper.js +216 -124
- package/src/echarts.js +60 -36
- package/src/langEN.js +26 -0
- package/src/layout/barGrid.js +22 -10
- package/src/layout/barPolar.js +4 -6
- package/src/loading/default.js +46 -34
- package/src/model/.DS_Store +0 -0
- package/src/model/Series.js +4 -4
- package/src/model/referHelper.js +34 -11
- package/src/preprocessor/.DS_Store +0 -0
- package/src/processor/dataSample.js +1 -1
- package/src/scale/Interval.js +84 -4
- package/src/scale/Log.js +9 -2
- package/src/scale/helper.js +1 -39
- package/src/stream/Scheduler.js +9 -1
- package/src/theme/dark.js +3 -0
- package/src/util/.DS_Store +0 -0
- package/src/util/format.js +17 -1
- package/src/util/graphic.js +13 -11
- package/src/visual/LegendVisualProvider.js +55 -0
- package/src/visual/VisualMapping.js +1 -1
- package/src/visual/dataColor.js +0 -13
- package/src/visual/seriesColor.js +13 -7
- package/src/visual/symbol.js +11 -2
- package/theme/.DS_Store +0 -0
- package/theme/azul.js +163 -0
- package/theme/bee-inspired.js +178 -0
- package/theme/blue.js +178 -0
- package/theme/caravan.js +178 -0
- package/theme/carp.js +163 -0
- package/theme/cool.js +180 -0
- package/theme/dark-blue.js +168 -0
- package/theme/dark-bold.js +168 -0
- package/theme/dark-digerati.js +168 -0
- package/theme/dark-fresh-cut.js +168 -0
- package/theme/dark-mushroom.js +168 -0
- package/theme/dark.js +69 -62
- package/theme/eduardo.js +178 -0
- package/theme/forest.js +163 -0
- package/theme/fresh-cut.js +163 -0
- package/theme/fruit.js +178 -0
- package/theme/gray.js +220 -0
- package/theme/green.js +222 -0
- package/theme/helianthus.js +263 -0
- package/theme/infographic.js +72 -57
- package/theme/inspired.js +163 -0
- package/theme/jazz.js +163 -0
- package/theme/london.js +163 -0
- package/theme/macarons.js +80 -57
- package/theme/macarons2.js +251 -0
- package/theme/mint.js +155 -0
- package/theme/red-velvet.js +163 -0
- package/theme/red.js +225 -0
- package/theme/roma.js +55 -22
- package/theme/royal.js +163 -0
- package/theme/sakura.js +140 -0
- package/theme/shine.js +52 -45
- package/theme/tech-blue.js +180 -0
- package/theme/vintage.js +37 -23
|
@@ -48,7 +48,9 @@ var _default = SeriesModel.extend({
|
|
|
48
48
|
type: 'series.line',
|
|
49
49
|
dependencies: ['grid', 'polar'],
|
|
50
50
|
getInitialData: function (option, ecModel) {
|
|
51
|
-
return createListFromArray(this.getSource(), this
|
|
51
|
+
return createListFromArray(this.getSource(), this, {
|
|
52
|
+
useEncodeDefaulter: true
|
|
53
|
+
});
|
|
52
54
|
},
|
|
53
55
|
defaultOption: {
|
|
54
56
|
zlevel: 0,
|
|
@@ -24,6 +24,10 @@ var __DEV__ = _config.__DEV__;
|
|
|
24
24
|
|
|
25
25
|
var zrUtil = require("zrender/lib/core/util");
|
|
26
26
|
|
|
27
|
+
var _bbox = require("zrender/lib/core/bbox");
|
|
28
|
+
|
|
29
|
+
var fromPoints = _bbox.fromPoints;
|
|
30
|
+
|
|
27
31
|
var SymbolDraw = require("../helper/SymbolDraw");
|
|
28
32
|
|
|
29
33
|
var SymbolClz = require("../helper/Symbol");
|
|
@@ -87,6 +91,17 @@ function isPointsSame(points1, points2) {
|
|
|
87
91
|
return true;
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
function getBoundingDiff(points1, points2) {
|
|
95
|
+
var min1 = [];
|
|
96
|
+
var max1 = [];
|
|
97
|
+
var min2 = [];
|
|
98
|
+
var max2 = [];
|
|
99
|
+
fromPoints(points1, min1, max1);
|
|
100
|
+
fromPoints(points2, min2, max2); // Get a max value from each corner of two boundings.
|
|
101
|
+
|
|
102
|
+
return Math.max(Math.abs(min1[0] - min2[0]), Math.abs(min1[1] - min2[1]), Math.abs(max1[0] - max2[0]), Math.abs(max1[1] - max2[1]));
|
|
103
|
+
}
|
|
104
|
+
|
|
90
105
|
function getSmooth(smooth) {
|
|
91
106
|
return typeof smooth === 'number' ? smooth : smooth ? 0.5 : 0;
|
|
92
107
|
}
|
|
@@ -368,7 +383,7 @@ var _default = ChartView.extend({
|
|
|
368
383
|
var step = !isCoordSysPolar && seriesModel.get('step');
|
|
369
384
|
var clipShapeForSymbol;
|
|
370
385
|
|
|
371
|
-
if (coordSys && coordSys.getArea) {
|
|
386
|
+
if (coordSys && coordSys.getArea && seriesModel.get('clip', true)) {
|
|
372
387
|
clipShapeForSymbol = coordSys.getArea(); // Avoid float number rounding error for symbol on the edge of axis extent.
|
|
373
388
|
// See #7913 and `test/dataZoom-clip.html`.
|
|
374
389
|
|
|
@@ -381,8 +396,9 @@ var _default = ChartView.extend({
|
|
|
381
396
|
clipShapeForSymbol.r0 -= 0.5;
|
|
382
397
|
clipShapeForSymbol.r1 += 0.5;
|
|
383
398
|
}
|
|
384
|
-
}
|
|
399
|
+
}
|
|
385
400
|
|
|
401
|
+
this._clipShapeForSymbol = clipShapeForSymbol; // Initialization animation or coordinate system changed
|
|
386
402
|
|
|
387
403
|
if (!(polyline && prevCoordSys.type === coordSys.type && step === this._step)) {
|
|
388
404
|
showSymbol && symbolDraw.updateData(data, {
|
|
@@ -509,6 +525,11 @@ var _default = ChartView.extend({
|
|
|
509
525
|
if (!pt) {
|
|
510
526
|
// Null data
|
|
511
527
|
return;
|
|
528
|
+
} // fix #11360: should't draw symbol outside clipShapeForSymbol
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
if (this._clipShapeForSymbol && !this._clipShapeForSymbol.contain(pt[0], pt[1])) {
|
|
532
|
+
return;
|
|
512
533
|
}
|
|
513
534
|
|
|
514
535
|
symbol = new SymbolClz(data, dataIndex);
|
|
@@ -624,6 +645,24 @@ var _default = ChartView.extend({
|
|
|
624
645
|
stackedOnCurrent = turnPointsIntoStep(diff.stackedOnCurrent, coordSys, step);
|
|
625
646
|
next = turnPointsIntoStep(diff.next, coordSys, step);
|
|
626
647
|
stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
|
|
648
|
+
} // Don't apply animation if diff is large.
|
|
649
|
+
// For better result and avoid memory explosion problems like
|
|
650
|
+
// https://github.com/apache/incubator-echarts/issues/12229
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
if (getBoundingDiff(current, next) > 3000 || polygon && getBoundingDiff(stackedOnCurrent, stackedOnNext) > 3000) {
|
|
654
|
+
polyline.setShape({
|
|
655
|
+
points: next
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
if (polygon) {
|
|
659
|
+
polygon.setShape({
|
|
660
|
+
points: next,
|
|
661
|
+
stackedOnPoints: stackedOnNext
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return;
|
|
627
666
|
} // `diff.current` is subset of `current` (which should be ensured by
|
|
628
667
|
// turnPointsIntoStep), so points in `__points` can be updated when
|
|
629
668
|
// points in `current` are update during animation.
|
|
@@ -106,8 +106,6 @@ var LinesSeries = SeriesModel.extend({
|
|
|
106
106
|
LinesSeries.superApply(this, 'init', arguments);
|
|
107
107
|
},
|
|
108
108
|
mergeOption: function (option) {
|
|
109
|
-
// The input data may be null/undefined.
|
|
110
|
-
option.data = option.data || [];
|
|
111
109
|
compatEc2(option);
|
|
112
110
|
|
|
113
111
|
if (option.data) {
|
|
@@ -37,6 +37,10 @@ var retrieveRawAttr = _dataProvider.retrieveRawAttr;
|
|
|
37
37
|
|
|
38
38
|
var geoSourceManager = require("../../coord/geo/geoSourceManager");
|
|
39
39
|
|
|
40
|
+
var _sourceHelper = require("../../data/helper/sourceHelper");
|
|
41
|
+
|
|
42
|
+
var makeSeriesEncodeForNameBased = _sourceHelper.makeSeriesEncodeForNameBased;
|
|
43
|
+
|
|
40
44
|
/*
|
|
41
45
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
42
46
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -72,7 +76,10 @@ var MapSeries = SeriesModel.extend({
|
|
|
72
76
|
*/
|
|
73
77
|
seriesGroup: [],
|
|
74
78
|
getInitialData: function (option) {
|
|
75
|
-
var data = createListSimply(this,
|
|
79
|
+
var data = createListSimply(this, {
|
|
80
|
+
coordDimensions: ['value'],
|
|
81
|
+
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
|
|
82
|
+
});
|
|
76
83
|
var valueDim = data.mapDimension('value');
|
|
77
84
|
var dataNameMap = zrUtil.createHashMap();
|
|
78
85
|
var selectTargetList = [];
|
|
@@ -88,7 +95,7 @@ var MapSeries = SeriesModel.extend({
|
|
|
88
95
|
});
|
|
89
96
|
}
|
|
90
97
|
|
|
91
|
-
var geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap);
|
|
98
|
+
var geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap, this.option.nameProperty);
|
|
92
99
|
zrUtil.each(geoSource.regions, function (region) {
|
|
93
100
|
var name = region.name;
|
|
94
101
|
|
|
@@ -146,7 +153,7 @@ var MapSeries = SeriesModel.extend({
|
|
|
146
153
|
*
|
|
147
154
|
* @param {number} dataIndex
|
|
148
155
|
*/
|
|
149
|
-
formatTooltip: function (dataIndex) {
|
|
156
|
+
formatTooltip: function (dataIndex, multipleSeries, dataType, renderMode) {
|
|
150
157
|
// FIXME orignalData and data is a bit confusing
|
|
151
158
|
var data = this.getData();
|
|
152
159
|
var formattedValue = addCommas(this.getRawValue(dataIndex));
|
|
@@ -163,7 +170,8 @@ var MapSeries = SeriesModel.extend({
|
|
|
163
170
|
}
|
|
164
171
|
}
|
|
165
172
|
|
|
166
|
-
|
|
173
|
+
var newLine = renderMode === 'html' ? '<br/>' : '\n';
|
|
174
|
+
return seriesNames.join(', ') + newLine + encodeHTML(name + ' : ' + formattedValue);
|
|
167
175
|
},
|
|
168
176
|
|
|
169
177
|
/**
|
|
@@ -249,7 +257,8 @@ var MapSeries = SeriesModel.extend({
|
|
|
249
257
|
itemStyle: {
|
|
250
258
|
areaColor: 'rgba(255,215,0,0.8)'
|
|
251
259
|
}
|
|
252
|
-
}
|
|
260
|
+
},
|
|
261
|
+
nameProperty: 'name'
|
|
253
262
|
}
|
|
254
263
|
});
|
|
255
264
|
zrUtil.mixin(MapSeries, dataSelectableMixin);
|
|
@@ -36,6 +36,12 @@ var _dataProvider = require("../../data/helper/dataProvider");
|
|
|
36
36
|
|
|
37
37
|
var retrieveRawAttr = _dataProvider.retrieveRawAttr;
|
|
38
38
|
|
|
39
|
+
var _sourceHelper = require("../../data/helper/sourceHelper");
|
|
40
|
+
|
|
41
|
+
var makeSeriesEncodeForNameBased = _sourceHelper.makeSeriesEncodeForNameBased;
|
|
42
|
+
|
|
43
|
+
var LegendVisualProvider = require("../../visual/LegendVisualProvider");
|
|
44
|
+
|
|
39
45
|
/*
|
|
40
46
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
41
47
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -61,10 +67,7 @@ var PieSeries = echarts.extendSeriesModel({
|
|
|
61
67
|
PieSeries.superApply(this, 'init', arguments); // Enable legend selection for each data item
|
|
62
68
|
// Use a function instead of direct access because data reference may changed
|
|
63
69
|
|
|
64
|
-
this.
|
|
65
|
-
return this.getRawData();
|
|
66
|
-
};
|
|
67
|
-
|
|
70
|
+
this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
|
|
68
71
|
this.updateSelectedMap(this._createSelectableList());
|
|
69
72
|
|
|
70
73
|
this._defaultLabelLine(option);
|
|
@@ -75,7 +78,10 @@ var PieSeries = echarts.extendSeriesModel({
|
|
|
75
78
|
this.updateSelectedMap(this._createSelectableList());
|
|
76
79
|
},
|
|
77
80
|
getInitialData: function (option, ecModel) {
|
|
78
|
-
return createListSimply(this,
|
|
81
|
+
return createListSimply(this, {
|
|
82
|
+
coordDimensions: ['value'],
|
|
83
|
+
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
|
|
84
|
+
});
|
|
79
85
|
},
|
|
80
86
|
_createSelectableList: function () {
|
|
81
87
|
var data = this.getRawData();
|
|
@@ -144,12 +150,27 @@ var PieSeries = echarts.extendSeriesModel({
|
|
|
144
150
|
// If still show when all data zero.
|
|
145
151
|
stillShowZeroSum: true,
|
|
146
152
|
// cursor: null,
|
|
153
|
+
left: 0,
|
|
154
|
+
top: 0,
|
|
155
|
+
right: 0,
|
|
156
|
+
bottom: 0,
|
|
157
|
+
width: null,
|
|
158
|
+
height: null,
|
|
147
159
|
label: {
|
|
148
160
|
// If rotate around circle
|
|
149
161
|
rotate: false,
|
|
150
162
|
show: true,
|
|
151
163
|
// 'outer', 'inside', 'center'
|
|
152
|
-
position: 'outer'
|
|
164
|
+
position: 'outer',
|
|
165
|
+
// 'none', 'labelLine', 'edge'. Works only when position is 'outer'
|
|
166
|
+
alignTo: 'none',
|
|
167
|
+
// Closest distance between label and chart edge.
|
|
168
|
+
// Works only position is 'outer' and alignTo is 'edge'.
|
|
169
|
+
margin: '25%',
|
|
170
|
+
// Works only position is 'outer' and alignTo is not 'edge'.
|
|
171
|
+
bleedMargin: 10,
|
|
172
|
+
// Distance between text and label line.
|
|
173
|
+
distanceToLabelLine: 5 // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
|
|
153
174
|
// 默认使用全局文本样式,详见TEXTSTYLE
|
|
154
175
|
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
|
|
155
176
|
|
package/lib/chart/pie/PieView.js
CHANGED
|
@@ -159,33 +159,40 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
|
|
|
159
159
|
var cursorStyle = itemModel.getShallow('cursor');
|
|
160
160
|
cursorStyle && sector.attr('cursor', cursorStyle); // Toggle selected
|
|
161
161
|
|
|
162
|
-
toggleItemSelected(this, data.getItemLayout(idx), seriesModel.isSelected(
|
|
162
|
+
toggleItemSelected(this, data.getItemLayout(idx), seriesModel.isSelected(data.getName(idx)), seriesModel.get('selectedOffset'), seriesModel.get('animation')); // Label and text animation should be applied only for transition type animation when update
|
|
163
163
|
|
|
164
164
|
var withAnimation = !firstCreate && animationTypeUpdate === 'transition';
|
|
165
165
|
|
|
166
166
|
this._updateLabel(data, idx, withAnimation);
|
|
167
167
|
|
|
168
|
-
this.highDownOnUpdate =
|
|
168
|
+
this.highDownOnUpdate = !seriesModel.get('silent') ? function (fromState, toState) {
|
|
169
|
+
var hasAnimation = seriesModel.isAnimationEnabled() && itemModel.get('hoverAnimation');
|
|
170
|
+
|
|
169
171
|
if (toState === 'emphasis') {
|
|
170
172
|
labelLine.ignore = labelLine.hoverIgnore;
|
|
171
173
|
labelText.ignore = labelText.hoverIgnore; // Sector may has animation of updating data. Force to move to the last frame
|
|
172
174
|
// Or it may stopped on the wrong shape
|
|
173
175
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
if (hasAnimation) {
|
|
177
|
+
sector.stopAnimation(true);
|
|
178
|
+
sector.animateTo({
|
|
179
|
+
shape: {
|
|
180
|
+
r: layout.r + seriesModel.get('hoverOffset')
|
|
181
|
+
}
|
|
182
|
+
}, 300, 'elasticOut');
|
|
183
|
+
}
|
|
180
184
|
} else {
|
|
181
185
|
labelLine.ignore = labelLine.normalIgnore;
|
|
182
186
|
labelText.ignore = labelText.normalIgnore;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
|
|
188
|
+
if (hasAnimation) {
|
|
189
|
+
sector.stopAnimation(true);
|
|
190
|
+
sector.animateTo({
|
|
191
|
+
shape: {
|
|
192
|
+
r: layout.r
|
|
193
|
+
}
|
|
194
|
+
}, 300, 'elasticOut');
|
|
195
|
+
}
|
|
189
196
|
}
|
|
190
197
|
} : null;
|
|
191
198
|
graphic.setHoverStyle(this);
|
|
@@ -242,7 +249,7 @@ piePieceProto._updateLabel = function (data, idx, withAnimation) {
|
|
|
242
249
|
graphic.setLabelStyle(labelText.style, labelText.hoverStyle = {}, labelModel, labelHoverModel, {
|
|
243
250
|
labelFetcher: data.hostModel,
|
|
244
251
|
labelDataIndex: idx,
|
|
245
|
-
defaultText:
|
|
252
|
+
defaultText: labelLayout.text,
|
|
246
253
|
autoColor: visualColor,
|
|
247
254
|
useInsideStyle: !!labelLayout.inside
|
|
248
255
|
}, {
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
var textContain = require("zrender/lib/contain/text");
|
|
22
22
|
|
|
23
|
+
var _number = require("../../util/number");
|
|
24
|
+
|
|
25
|
+
var parsePercent = _number.parsePercent;
|
|
26
|
+
|
|
23
27
|
/*
|
|
24
28
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
25
29
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -41,13 +45,17 @@ var textContain = require("zrender/lib/contain/text");
|
|
|
41
45
|
// FIXME emphasis label position is not same with normal label position
|
|
42
46
|
var RADIAN = Math.PI / 180;
|
|
43
47
|
|
|
44
|
-
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
48
|
+
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
|
|
45
49
|
list.sort(function (a, b) {
|
|
46
50
|
return a.y - b.y;
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
function shiftDown(start, end, delta, dir) {
|
|
50
54
|
for (var j = start; j < end; j++) {
|
|
55
|
+
if (list[j].y + delta > viewTop + viewHeight) {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
list[j].y += delta;
|
|
52
60
|
|
|
53
61
|
if (j > start && j + 1 < end && list[j + 1].y > list[j].y + list[j].height) {
|
|
@@ -61,6 +69,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
61
69
|
|
|
62
70
|
function shiftUp(end, delta) {
|
|
63
71
|
for (var j = end; j >= 0; j--) {
|
|
72
|
+
if (list[j].y - delta < viewTop) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
list[j].y -= delta;
|
|
65
77
|
|
|
66
78
|
if (j > 0 && list[j].y > list[j - 1].y + list[j - 1].height) {
|
|
@@ -78,6 +90,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
78
90
|
: 0; // up
|
|
79
91
|
|
|
80
92
|
for (var i = 0, l = list.length; i < l; i++) {
|
|
93
|
+
if (list[i].labelAlignTo !== 'none') {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
var deltaY = Math.abs(list[i].y - cy);
|
|
82
98
|
var length = list[i].len;
|
|
83
99
|
var length2 = list[i].len2;
|
|
@@ -105,6 +121,12 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
105
121
|
var downList = [];
|
|
106
122
|
|
|
107
123
|
for (var i = 0; i < len; i++) {
|
|
124
|
+
if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
|
|
125
|
+
var dx = list[i].x - farthestX;
|
|
126
|
+
list[i].linePoints[1][0] += dx;
|
|
127
|
+
list[i].x = farthestX;
|
|
128
|
+
}
|
|
129
|
+
|
|
108
130
|
delta = list[i].y - lastY;
|
|
109
131
|
|
|
110
132
|
if (delta < 0) {
|
|
@@ -130,9 +152,11 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
130
152
|
changeX(downList, true, cx, cy, r, dir);
|
|
131
153
|
}
|
|
132
154
|
|
|
133
|
-
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
155
|
+
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
134
156
|
var leftList = [];
|
|
135
157
|
var rightList = [];
|
|
158
|
+
var leftmostX = Number.MAX_VALUE;
|
|
159
|
+
var rightmostX = -Number.MAX_VALUE;
|
|
136
160
|
|
|
137
161
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
138
162
|
if (isPositionCenter(labelLayoutList[i])) {
|
|
@@ -140,33 +164,72 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
140
164
|
}
|
|
141
165
|
|
|
142
166
|
if (labelLayoutList[i].x < cx) {
|
|
167
|
+
leftmostX = Math.min(leftmostX, labelLayoutList[i].x);
|
|
143
168
|
leftList.push(labelLayoutList[i]);
|
|
144
169
|
} else {
|
|
170
|
+
rightmostX = Math.max(rightmostX, labelLayoutList[i].x);
|
|
145
171
|
rightList.push(labelLayoutList[i]);
|
|
146
172
|
}
|
|
147
173
|
}
|
|
148
174
|
|
|
149
|
-
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
|
|
150
|
-
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
|
|
175
|
+
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
|
|
176
|
+
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
|
|
151
177
|
|
|
152
178
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
153
|
-
|
|
179
|
+
var layout = labelLayoutList[i];
|
|
180
|
+
|
|
181
|
+
if (isPositionCenter(layout)) {
|
|
154
182
|
continue;
|
|
155
183
|
}
|
|
156
184
|
|
|
157
|
-
var linePoints =
|
|
185
|
+
var linePoints = layout.linePoints;
|
|
158
186
|
|
|
159
187
|
if (linePoints) {
|
|
188
|
+
var isAlignToEdge = layout.labelAlignTo === 'edge';
|
|
189
|
+
var realTextWidth = layout.textRect.width;
|
|
190
|
+
var targetTextWidth;
|
|
191
|
+
|
|
192
|
+
if (isAlignToEdge) {
|
|
193
|
+
if (layout.x < cx) {
|
|
194
|
+
targetTextWidth = linePoints[2][0] - layout.labelDistance - viewLeft - layout.labelMargin;
|
|
195
|
+
} else {
|
|
196
|
+
targetTextWidth = viewLeft + viewWidth - layout.labelMargin - linePoints[2][0] - layout.labelDistance;
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
if (layout.x < cx) {
|
|
200
|
+
targetTextWidth = layout.x - viewLeft - layout.bleedMargin;
|
|
201
|
+
} else {
|
|
202
|
+
targetTextWidth = viewLeft + viewWidth - layout.x - layout.bleedMargin;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (targetTextWidth < layout.textRect.width) {
|
|
207
|
+
layout.text = textContain.truncateText(layout.text, targetTextWidth, layout.font);
|
|
208
|
+
|
|
209
|
+
if (layout.labelAlignTo === 'edge') {
|
|
210
|
+
realTextWidth = textContain.getWidth(layout.text, layout.font);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
160
214
|
var dist = linePoints[1][0] - linePoints[2][0];
|
|
161
215
|
|
|
162
|
-
if (
|
|
163
|
-
|
|
216
|
+
if (isAlignToEdge) {
|
|
217
|
+
if (layout.x < cx) {
|
|
218
|
+
linePoints[2][0] = viewLeft + layout.labelMargin + realTextWidth + layout.labelDistance;
|
|
219
|
+
} else {
|
|
220
|
+
linePoints[2][0] = viewLeft + viewWidth - layout.labelMargin - realTextWidth - layout.labelDistance;
|
|
221
|
+
}
|
|
164
222
|
} else {
|
|
165
|
-
|
|
223
|
+
if (layout.x < cx) {
|
|
224
|
+
linePoints[2][0] = layout.x + layout.labelDistance;
|
|
225
|
+
} else {
|
|
226
|
+
linePoints[2][0] = layout.x - layout.labelDistance;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
linePoints[1][0] = linePoints[2][0] + dist;
|
|
166
230
|
}
|
|
167
231
|
|
|
168
|
-
linePoints[1][1] = linePoints[2][1] =
|
|
169
|
-
linePoints[1][0] = linePoints[2][0] + dist;
|
|
232
|
+
linePoints[1][1] = linePoints[2][1] = layout.y;
|
|
170
233
|
}
|
|
171
234
|
}
|
|
172
235
|
}
|
|
@@ -176,7 +239,7 @@ function isPositionCenter(layout) {
|
|
|
176
239
|
return layout.position === 'center';
|
|
177
240
|
}
|
|
178
241
|
|
|
179
|
-
function _default(seriesModel, r, viewWidth, viewHeight,
|
|
242
|
+
function _default(seriesModel, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
180
243
|
var data = seriesModel.getData();
|
|
181
244
|
var labelLayoutList = [];
|
|
182
245
|
var cx;
|
|
@@ -189,9 +252,16 @@ function _default(seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
189
252
|
var labelModel = itemModel.getModel('label'); // Use position in normal or emphasis
|
|
190
253
|
|
|
191
254
|
var labelPosition = labelModel.get('position') || itemModel.get('emphasis.label.position');
|
|
255
|
+
var labelDistance = labelModel.get('distanceToLabelLine');
|
|
256
|
+
var labelAlignTo = labelModel.get('alignTo');
|
|
257
|
+
var labelMargin = parsePercent(labelModel.get('margin'), viewWidth);
|
|
258
|
+
var bleedMargin = labelModel.get('bleedMargin');
|
|
259
|
+
var font = labelModel.getFont();
|
|
192
260
|
var labelLineModel = itemModel.getModel('labelLine');
|
|
193
261
|
var labelLineLen = labelLineModel.get('length');
|
|
262
|
+
labelLineLen = parsePercent(labelLineLen, viewWidth);
|
|
194
263
|
var labelLineLen2 = labelLineModel.get('length2');
|
|
264
|
+
labelLineLen2 = parsePercent(labelLineLen2, viewWidth);
|
|
195
265
|
|
|
196
266
|
if (layout.angle < minShowLabelRadian) {
|
|
197
267
|
return;
|
|
@@ -206,6 +276,8 @@ function _default(seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
206
276
|
var textAlign;
|
|
207
277
|
cx = layout.cx;
|
|
208
278
|
cy = layout.cy;
|
|
279
|
+
var text = seriesModel.getFormattedLabel(idx, 'normal') || data.getName(idx);
|
|
280
|
+
var textRect = textContain.getBoundingRect(text, font, textAlign, 'top');
|
|
209
281
|
var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
|
|
210
282
|
|
|
211
283
|
if (labelPosition === 'center') {
|
|
@@ -224,15 +296,21 @@ function _default(seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
224
296
|
var y2 = y1 + dy * (labelLineLen + r - layout.r);
|
|
225
297
|
var x3 = x2 + (dx < 0 ? -1 : 1) * labelLineLen2;
|
|
226
298
|
var y3 = y2;
|
|
227
|
-
|
|
299
|
+
|
|
300
|
+
if (labelAlignTo === 'edge') {
|
|
301
|
+
// Adjust textX because text align of edge is opposite
|
|
302
|
+
textX = dx < 0 ? viewLeft + labelMargin : viewLeft + viewWidth - labelMargin;
|
|
303
|
+
} else {
|
|
304
|
+
textX = x3 + (dx < 0 ? -labelDistance : labelDistance);
|
|
305
|
+
}
|
|
306
|
+
|
|
228
307
|
textY = y3;
|
|
229
308
|
linePoints = [[x1, y1], [x2, y2], [x3, y3]];
|
|
230
309
|
}
|
|
231
310
|
|
|
232
|
-
textAlign = isLabelInside ? 'center' : dx > 0 ? 'left' : 'right';
|
|
311
|
+
textAlign = isLabelInside ? 'center' : labelAlignTo === 'edge' ? dx > 0 ? 'right' : 'left' : dx > 0 ? 'left' : 'right';
|
|
233
312
|
}
|
|
234
313
|
|
|
235
|
-
var font = labelModel.getFont();
|
|
236
314
|
var labelRotate;
|
|
237
315
|
var rotate = labelModel.get('rotate');
|
|
238
316
|
|
|
@@ -242,8 +320,6 @@ function _default(seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
242
320
|
labelRotate = rotate ? dx < 0 ? -midAngle + Math.PI : -midAngle : 0;
|
|
243
321
|
}
|
|
244
322
|
|
|
245
|
-
var text = seriesModel.getFormattedLabel(idx, 'normal') || data.getName(idx);
|
|
246
|
-
var textRect = textContain.getBoundingRect(text, font, textAlign, 'top');
|
|
247
323
|
hasLabelRotate = !!labelRotate;
|
|
248
324
|
layout.label = {
|
|
249
325
|
x: textX,
|
|
@@ -256,7 +332,14 @@ function _default(seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
256
332
|
textAlign: textAlign,
|
|
257
333
|
verticalAlign: 'middle',
|
|
258
334
|
rotation: labelRotate,
|
|
259
|
-
inside: isLabelInside
|
|
335
|
+
inside: isLabelInside,
|
|
336
|
+
labelDistance: labelDistance,
|
|
337
|
+
labelAlignTo: labelAlignTo,
|
|
338
|
+
labelMargin: labelMargin,
|
|
339
|
+
bleedMargin: bleedMargin,
|
|
340
|
+
textRect: textRect,
|
|
341
|
+
text: text,
|
|
342
|
+
font: font
|
|
260
343
|
}; // Not layout the inside label
|
|
261
344
|
|
|
262
345
|
if (!isLabelInside) {
|
|
@@ -265,7 +348,7 @@ function _default(seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
265
348
|
});
|
|
266
349
|
|
|
267
350
|
if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
|
|
268
|
-
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
|
|
351
|
+
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
|
|
269
352
|
}
|
|
270
353
|
}
|
|
271
354
|
|
|
@@ -23,6 +23,8 @@ var _number = require("../../util/number");
|
|
|
23
23
|
var parsePercent = _number.parsePercent;
|
|
24
24
|
var linearMap = _number.linearMap;
|
|
25
25
|
|
|
26
|
+
var layout = require("../../util/layout");
|
|
27
|
+
|
|
26
28
|
var labelLayout = require("./labelLayout");
|
|
27
29
|
|
|
28
30
|
var zrUtil = require("zrender/lib/core/util");
|
|
@@ -48,10 +50,18 @@ var zrUtil = require("zrender/lib/core/util");
|
|
|
48
50
|
var PI2 = Math.PI * 2;
|
|
49
51
|
var RADIAN = Math.PI / 180;
|
|
50
52
|
|
|
53
|
+
function getViewRect(seriesModel, api) {
|
|
54
|
+
return layout.getLayoutRect(seriesModel.getBoxLayoutParams(), {
|
|
55
|
+
width: api.getWidth(),
|
|
56
|
+
height: api.getHeight()
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
function _default(seriesType, ecModel, api, payload) {
|
|
52
61
|
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
|
53
62
|
var data = seriesModel.getData();
|
|
54
63
|
var valueDim = data.mapDimension('value');
|
|
64
|
+
var viewRect = getViewRect(seriesModel, api);
|
|
55
65
|
var center = seriesModel.get('center');
|
|
56
66
|
var radius = seriesModel.get('radius');
|
|
57
67
|
|
|
@@ -63,11 +73,11 @@ function _default(seriesType, ecModel, api, payload) {
|
|
|
63
73
|
center = [center, center];
|
|
64
74
|
}
|
|
65
75
|
|
|
66
|
-
var width = api.getWidth();
|
|
67
|
-
var height = api.getHeight();
|
|
76
|
+
var width = parsePercent(viewRect.width, api.getWidth());
|
|
77
|
+
var height = parsePercent(viewRect.height, api.getHeight());
|
|
68
78
|
var size = Math.min(width, height);
|
|
69
|
-
var cx = parsePercent(center[0], width);
|
|
70
|
-
var cy = parsePercent(center[1], height);
|
|
79
|
+
var cx = parsePercent(center[0], width) + viewRect.x;
|
|
80
|
+
var cy = parsePercent(center[1], height) + viewRect.y;
|
|
71
81
|
var r0 = parsePercent(radius[0], size / 2);
|
|
72
82
|
var r = parsePercent(radius[1], size / 2);
|
|
73
83
|
var startAngle = -seriesModel.get('startAngle') * RADIAN;
|
|
@@ -102,7 +112,8 @@ function _default(seriesType, ecModel, api, payload) {
|
|
|
102
112
|
cx: cx,
|
|
103
113
|
cy: cy,
|
|
104
114
|
r0: r0,
|
|
105
|
-
r: roseType ? NaN : r
|
|
115
|
+
r: roseType ? NaN : r,
|
|
116
|
+
viewRect: viewRect
|
|
106
117
|
});
|
|
107
118
|
return;
|
|
108
119
|
} // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
|
|
@@ -130,7 +141,8 @@ function _default(seriesType, ecModel, api, payload) {
|
|
|
130
141
|
cx: cx,
|
|
131
142
|
cy: cy,
|
|
132
143
|
r0: r0,
|
|
133
|
-
r: roseType ? linearMap(value, extent, [r0, r]) : r
|
|
144
|
+
r: roseType ? linearMap(value, extent, [r0, r]) : r,
|
|
145
|
+
viewRect: viewRect
|
|
134
146
|
});
|
|
135
147
|
currentAngle = endAngle;
|
|
136
148
|
}); // Some sector is constrained by minAngle
|
|
@@ -164,7 +176,7 @@ function _default(seriesType, ecModel, api, payload) {
|
|
|
164
176
|
}
|
|
165
177
|
}
|
|
166
178
|
|
|
167
|
-
labelLayout(seriesModel, r, width, height);
|
|
179
|
+
labelLayout(seriesModel, r, viewRect.width, viewRect.height, viewRect.x, viewRect.y);
|
|
168
180
|
});
|
|
169
181
|
}
|
|
170
182
|
|
|
@@ -28,6 +28,8 @@ var _format = require("../../util/format");
|
|
|
28
28
|
|
|
29
29
|
var encodeHTML = _format.encodeHTML;
|
|
30
30
|
|
|
31
|
+
var LegendVisualProvider = require("../../visual/LegendVisualProvider");
|
|
32
|
+
|
|
31
33
|
/*
|
|
32
34
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
33
35
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -54,9 +56,7 @@ var RadarSeries = SeriesModel.extend({
|
|
|
54
56
|
RadarSeries.superApply(this, 'init', arguments); // Enable legend selection for each data item
|
|
55
57
|
// Use a function instead of direct access because data reference may changed
|
|
56
58
|
|
|
57
|
-
this.
|
|
58
|
-
return this.getRawData();
|
|
59
|
-
};
|
|
59
|
+
this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
|
|
60
60
|
},
|
|
61
61
|
getInitialData: function (option, ecModel) {
|
|
62
62
|
return createListSimply(this, {
|
|
@@ -64,15 +64,36 @@ var RadarSeries = SeriesModel.extend({
|
|
|
64
64
|
generateCoordCount: Infinity
|
|
65
65
|
});
|
|
66
66
|
},
|
|
67
|
-
formatTooltip: function (dataIndex) {
|
|
67
|
+
formatTooltip: function (dataIndex, multipleSeries, dataType, renderMode) {
|
|
68
68
|
var data = this.getData();
|
|
69
69
|
var coordSys = this.coordinateSystem;
|
|
70
70
|
var indicatorAxes = coordSys.getIndicatorAxes();
|
|
71
71
|
var name = this.getData().getName(dataIndex);
|
|
72
|
-
|
|
72
|
+
var newLine = renderMode === 'html' ? '<br/>' : '\n';
|
|
73
|
+
return encodeHTML(name === '' ? this.name : name) + newLine + zrUtil.map(indicatorAxes, function (axis, idx) {
|
|
73
74
|
var val = data.get(data.mapDimension(axis.dim), dataIndex);
|
|
74
75
|
return encodeHTML(axis.name + ' : ' + val);
|
|
75
|
-
}).join(
|
|
76
|
+
}).join(newLine);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @implement
|
|
81
|
+
*/
|
|
82
|
+
getTooltipPosition: function (dataIndex) {
|
|
83
|
+
if (dataIndex != null) {
|
|
84
|
+
var data = this.getData();
|
|
85
|
+
var coordSys = this.coordinateSystem;
|
|
86
|
+
var values = data.getValues(zrUtil.map(coordSys.dimensions, function (dim) {
|
|
87
|
+
return data.mapDimension(dim);
|
|
88
|
+
}), dataIndex, true);
|
|
89
|
+
|
|
90
|
+
for (var i = 0, len = values.length; i < len; i++) {
|
|
91
|
+
if (!isNaN(values[i])) {
|
|
92
|
+
var indicatorAxes = coordSys.getIndicatorAxes();
|
|
93
|
+
return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
76
97
|
},
|
|
77
98
|
defaultOption: {
|
|
78
99
|
zlevel: 0,
|