echarts 4.5.0 → 4.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/dist/echarts-en.common.js +1790 -774
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +2029 -849
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +1676 -691
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +1790 -774
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +2029 -849
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +1676 -691
- package/dist/echarts.simple.min.js +1 -1
- package/lib/chart/bar/BarView.js +11 -1
- package/lib/chart/bar/BaseBarSeries.js +3 -1
- package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
- package/lib/chart/funnel/FunnelSeries.js +15 -5
- package/lib/chart/gauge/GaugeSeries.js +0 -2
- package/lib/chart/graph/GraphSeries.js +9 -4
- package/lib/chart/graph/GraphView.js +28 -8
- package/lib/chart/heatmap/HeatmapView.js +4 -4
- package/lib/chart/helper/createListFromArray.js +14 -8
- package/lib/chart/helper/whiskerBoxCommon.js +22 -16
- package/lib/chart/line/LineSeries.js +3 -1
- package/lib/chart/line/LineView.js +8 -2
- package/lib/chart/map/MapSeries.js +8 -1
- package/lib/chart/pie/PieSeries.js +27 -6
- package/lib/chart/pie/PieView.js +1 -1
- package/lib/chart/pie/labelLayout.js +102 -19
- package/lib/chart/pie/pieLayout.js +19 -7
- package/lib/chart/radar/RadarSeries.js +3 -3
- package/lib/chart/sankey/SankeyView.js +28 -9
- package/lib/chart/scatter/ScatterSeries.js +3 -1
- package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
- package/lib/chart/tree/TreeSeries.js +15 -1
- package/lib/component/axis/AngleAxisView.js +64 -7
- package/lib/component/axis/AxisBuilder.js +63 -24
- package/lib/component/axis/CartesianAxisView.js +55 -11
- package/lib/component/axis/RadiusAxisView.js +36 -4
- package/lib/component/dataZoom/SliderZoomView.js +4 -10
- package/lib/component/helper/BrushController.js +33 -43
- package/lib/component/legend/LegendModel.js +3 -3
- package/lib/component/legend/LegendView.js +17 -13
- package/lib/component/toolbox/ToolboxView.js +5 -1
- package/lib/component/toolbox/feature/MagicType.js +19 -14
- package/lib/coord/Axis.js +30 -2
- package/lib/coord/axisDefault.js +21 -2
- package/lib/data/DataDimensionInfo.js +157 -0
- package/lib/data/List.js +25 -19
- package/lib/data/Tree.js +2 -1
- 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 +2 -2
- package/lib/layout/barGrid.js +2 -3
- package/lib/model/Series.js +3 -3
- package/lib/model/referHelper.js +40 -12
- package/lib/scale/Interval.js +87 -2
- package/lib/scale/Log.js +9 -2
- package/lib/scale/helper.js +1 -43
- package/lib/theme/dark.js +3 -0
- package/lib/util/graphic.js +1 -2
- package/lib/visual/LegendVisualProvider.js +75 -0
- package/lib/visual/dataColor.js +2 -12
- package/lib/visual/seriesColor.js +15 -7
- package/map/json/province/tianjin.json +1 -1
- package/package.json +3 -2
- package/src/chart/bar/BarView.js +12 -2
- package/src/chart/bar/BaseBarSeries.js +1 -1
- package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
- package/src/chart/funnel/FunnelSeries.js +11 -4
- package/src/chart/gauge/GaugeSeries.js +0 -1
- package/src/chart/graph/GraphSeries.js +8 -3
- package/src/chart/graph/GraphView.js +26 -8
- package/src/chart/heatmap/HeatmapView.js +4 -4
- package/src/chart/helper/createListFromArray.js +13 -8
- package/src/chart/helper/whiskerBoxCommon.js +21 -16
- package/src/chart/line/LineSeries.js +1 -1
- package/src/chart/line/LineView.js +6 -1
- package/src/chart/map/MapSeries.js +5 -1
- package/src/chart/pie/PieSeries.js +26 -5
- package/src/chart/pie/PieView.js +1 -1
- package/src/chart/pie/labelLayout.js +114 -22
- package/src/chart/pie/pieLayout.js +20 -7
- package/src/chart/radar/RadarSeries.js +5 -3
- package/src/chart/sankey/SankeyView.js +26 -9
- package/src/chart/scatter/ScatterSeries.js +1 -1
- package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
- package/src/chart/tree/TreeSeries.js +12 -1
- package/src/component/axis/AngleAxisView.js +75 -7
- package/src/component/axis/AxisBuilder.js +78 -33
- package/src/component/axis/CartesianAxisView.js +58 -11
- package/src/component/axis/RadiusAxisView.js +37 -4
- package/src/component/dataZoom/SliderZoomView.js +4 -9
- package/src/component/helper/BrushController.js +40 -47
- package/src/component/legend/LegendModel.js +3 -3
- package/src/component/legend/LegendView.js +18 -12
- package/src/component/toolbox/ToolboxView.js +5 -0
- package/src/component/toolbox/feature/MagicType.js +18 -13
- package/src/coord/Axis.js +29 -2
- package/src/coord/axisDefault.js +25 -1
- package/src/data/DataDimensionInfo.js +135 -0
- package/src/data/List.js +29 -16
- package/src/data/Tree.js +3 -1
- 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 +2 -2
- package/src/layout/barGrid.js +6 -3
- package/src/model/Series.js +3 -3
- package/src/model/referHelper.js +34 -11
- package/src/scale/Interval.js +84 -4
- package/src/scale/Log.js +9 -2
- package/src/scale/helper.js +1 -39
- package/src/theme/dark.js +3 -0
- package/src/util/graphic.js +1 -2
- package/src/visual/LegendVisualProvider.js +55 -0
- package/src/visual/dataColor.js +0 -13
- package/src/visual/seriesColor.js +13 -7
- 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
|
@@ -185,10 +185,10 @@ export default echarts.extendChartView({
|
|
|
185
185
|
|
|
186
186
|
rect = new graphic.Rect({
|
|
187
187
|
shape: {
|
|
188
|
-
x: point[0] - width / 2,
|
|
189
|
-
y: point[1] - height / 2,
|
|
190
|
-
width: width,
|
|
191
|
-
height: height
|
|
188
|
+
x: Math.floor(point[0] - width / 2),
|
|
189
|
+
y: Math.floor(point[1] - height / 2),
|
|
190
|
+
width: Math.ceil(width),
|
|
191
|
+
height: Math.ceil(height)
|
|
192
192
|
},
|
|
193
193
|
style: {
|
|
194
194
|
fill: data.getItemVisual(idx, 'color'),
|
|
@@ -24,15 +24,17 @@ import {SOURCE_FORMAT_ORIGINAL} from '../../data/helper/sourceType';
|
|
|
24
24
|
import {getDimensionTypeByAxis} from '../../data/helper/dimensionHelper';
|
|
25
25
|
import {getDataItemValue} from '../../util/model';
|
|
26
26
|
import CoordinateSystem from '../../CoordinateSystem';
|
|
27
|
-
import {
|
|
27
|
+
import {getCoordSysInfoBySeries} from '../../model/referHelper';
|
|
28
28
|
import Source from '../../data/Source';
|
|
29
29
|
import {enableDataStack} from '../../data/helper/dataStackHelper';
|
|
30
|
+
import {makeSeriesEncodeForAxisCoordSys} from '../../data/helper/sourceHelper';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* @param {module:echarts/data/Source|Array} source Or raw data.
|
|
33
34
|
* @param {module:echarts/model/Series} seriesModel
|
|
34
35
|
* @param {Object} [opt]
|
|
35
36
|
* @param {string} [opt.generateCoord]
|
|
37
|
+
* @param {boolean} [opt.useEncodeDefaulter]
|
|
36
38
|
*/
|
|
37
39
|
function createListFromArray(source, seriesModel, opt) {
|
|
38
40
|
opt = opt || {};
|
|
@@ -44,14 +46,14 @@ function createListFromArray(source, seriesModel, opt) {
|
|
|
44
46
|
var coordSysName = seriesModel.get('coordinateSystem');
|
|
45
47
|
var registeredCoordSys = CoordinateSystem.get(coordSysName);
|
|
46
48
|
|
|
47
|
-
var
|
|
49
|
+
var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
|
|
48
50
|
|
|
49
51
|
var coordSysDimDefs;
|
|
50
52
|
|
|
51
|
-
if (
|
|
52
|
-
coordSysDimDefs = zrUtil.map(
|
|
53
|
+
if (coordSysInfo) {
|
|
54
|
+
coordSysDimDefs = zrUtil.map(coordSysInfo.coordSysDims, function (dim) {
|
|
53
55
|
var dimInfo = {name: dim};
|
|
54
|
-
var axisModel =
|
|
56
|
+
var axisModel = coordSysInfo.axisMap.get(dim);
|
|
55
57
|
if (axisModel) {
|
|
56
58
|
var axisType = axisModel.get('type');
|
|
57
59
|
dimInfo.type = getDimensionTypeByAxis(axisType);
|
|
@@ -72,14 +74,17 @@ function createListFromArray(source, seriesModel, opt) {
|
|
|
72
74
|
|
|
73
75
|
var dimInfoList = createDimensions(source, {
|
|
74
76
|
coordDimensions: coordSysDimDefs,
|
|
75
|
-
generateCoord: opt.generateCoord
|
|
77
|
+
generateCoord: opt.generateCoord,
|
|
78
|
+
encodeDefaulter: opt.useEncodeDefaulter
|
|
79
|
+
? zrUtil.curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel)
|
|
80
|
+
: null
|
|
76
81
|
});
|
|
77
82
|
|
|
78
83
|
var firstCategoryDimIndex;
|
|
79
84
|
var hasNameEncode;
|
|
80
|
-
|
|
85
|
+
coordSysInfo && zrUtil.each(dimInfoList, function (dimInfo, dimIndex) {
|
|
81
86
|
var coordDim = dimInfo.coordDim;
|
|
82
|
-
var categoryAxisModel =
|
|
87
|
+
var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
|
|
83
88
|
if (categoryAxisModel) {
|
|
84
89
|
if (firstCategoryDimIndex == null) {
|
|
85
90
|
firstCategoryDimIndex = dimIndex;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import createListSimply from '../helper/createListSimply';
|
|
22
22
|
import * as zrUtil from 'zrender/src/core/util';
|
|
23
23
|
import {getDimensionTypeByAxis} from '../../data/helper/dimensionHelper';
|
|
24
|
+
import {makeSeriesEncodeForAxisCoordSys} from '../../data/helper/sourceHelper';
|
|
24
25
|
|
|
25
26
|
export var seriesModelMixin = {
|
|
26
27
|
|
|
@@ -47,7 +48,7 @@ export var seriesModelMixin = {
|
|
|
47
48
|
var addOrdinal;
|
|
48
49
|
|
|
49
50
|
// FIXME
|
|
50
|
-
//
|
|
51
|
+
// Consider time axis.
|
|
51
52
|
|
|
52
53
|
if (xAxisType === 'category') {
|
|
53
54
|
option.layout = 'horizontal';
|
|
@@ -95,25 +96,29 @@ export var seriesModelMixin = {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
var defaultValueDimensions = this.defaultValueDimensions;
|
|
99
|
+
var coordDimensions = [{
|
|
100
|
+
name: baseAxisDim,
|
|
101
|
+
type: getDimensionTypeByAxis(baseAxisType),
|
|
102
|
+
ordinalMeta: ordinalMeta,
|
|
103
|
+
otherDims: {
|
|
104
|
+
tooltip: false,
|
|
105
|
+
itemName: 0
|
|
106
|
+
},
|
|
107
|
+
dimsDef: ['base']
|
|
108
|
+
}, {
|
|
109
|
+
name: otherAxisDim,
|
|
110
|
+
type: getDimensionTypeByAxis(otherAxisType),
|
|
111
|
+
dimsDef: defaultValueDimensions.slice()
|
|
112
|
+
}];
|
|
98
113
|
|
|
99
114
|
return createListSimply(
|
|
100
115
|
this,
|
|
101
116
|
{
|
|
102
|
-
coordDimensions:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
tooltip: false,
|
|
108
|
-
itemName: 0
|
|
109
|
-
},
|
|
110
|
-
dimsDef: ['base']
|
|
111
|
-
}, {
|
|
112
|
-
name: otherAxisDim,
|
|
113
|
-
type: getDimensionTypeByAxis(otherAxisType),
|
|
114
|
-
dimsDef: defaultValueDimensions.slice()
|
|
115
|
-
}],
|
|
116
|
-
dimensionsCount: defaultValueDimensions.length + 1
|
|
117
|
+
coordDimensions: coordDimensions,
|
|
118
|
+
dimensionsCount: defaultValueDimensions.length + 1,
|
|
119
|
+
encodeDefaulter: zrUtil.curry(
|
|
120
|
+
makeSeriesEncodeForAxisCoordSys, coordDimensions, this
|
|
121
|
+
)
|
|
117
122
|
}
|
|
118
123
|
);
|
|
119
124
|
},
|
|
@@ -34,7 +34,7 @@ export default SeriesModel.extend({
|
|
|
34
34
|
throw new Error('Line not support coordinateSystem besides cartesian and polar');
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return createListFromArray(this.getSource(), this);
|
|
37
|
+
return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
defaultOption: {
|
|
@@ -354,7 +354,7 @@ export default ChartView.extend({
|
|
|
354
354
|
// FIXME step not support polar
|
|
355
355
|
var step = !isCoordSysPolar && seriesModel.get('step');
|
|
356
356
|
var clipShapeForSymbol;
|
|
357
|
-
if (coordSys && coordSys.getArea) {
|
|
357
|
+
if (coordSys && coordSys.getArea && seriesModel.get('clip', true)) {
|
|
358
358
|
clipShapeForSymbol = coordSys.getArea();
|
|
359
359
|
// Avoid float number rounding error for symbol on the edge of axis extent.
|
|
360
360
|
// See #7913 and `test/dataZoom-clip.html`.
|
|
@@ -369,6 +369,7 @@ export default ChartView.extend({
|
|
|
369
369
|
clipShapeForSymbol.r1 += 0.5;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
+
this._clipShapeForSymbol = clipShapeForSymbol;
|
|
372
373
|
// Initialization animation or coordinate system changed
|
|
373
374
|
if (
|
|
374
375
|
!(polyline && prevCoordSys.type === coordSys.type && step === this._step)
|
|
@@ -521,6 +522,10 @@ export default ChartView.extend({
|
|
|
521
522
|
// Null data
|
|
522
523
|
return;
|
|
523
524
|
}
|
|
525
|
+
// fix #11360: should't draw symbol outside clipShapeForSymbol
|
|
526
|
+
if (this._clipShapeForSymbol && !this._clipShapeForSymbol.contain(pt[0], pt[1])) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
524
529
|
symbol = new SymbolClz(data, dataIndex);
|
|
525
530
|
symbol.position = pt;
|
|
526
531
|
symbol.setZ(
|
|
@@ -24,6 +24,7 @@ import {encodeHTML, addCommas} from '../../util/format';
|
|
|
24
24
|
import dataSelectableMixin from '../../component/helper/selectableMixin';
|
|
25
25
|
import {retrieveRawAttr} from '../../data/helper/dataProvider';
|
|
26
26
|
import geoSourceManager from '../../coord/geo/geoSourceManager';
|
|
27
|
+
import {makeSeriesEncodeForNameBased} from '../../data/helper/sourceHelper';
|
|
27
28
|
|
|
28
29
|
var MapSeries = SeriesModel.extend({
|
|
29
30
|
|
|
@@ -46,7 +47,10 @@ var MapSeries = SeriesModel.extend({
|
|
|
46
47
|
seriesGroup: [],
|
|
47
48
|
|
|
48
49
|
getInitialData: function (option) {
|
|
49
|
-
var data = createListSimply(this,
|
|
50
|
+
var data = createListSimply(this, {
|
|
51
|
+
coordDimensions: ['value'],
|
|
52
|
+
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
|
|
53
|
+
});
|
|
50
54
|
var valueDim = data.mapDimension('value');
|
|
51
55
|
var dataNameMap = zrUtil.createHashMap();
|
|
52
56
|
var selectTargetList = [];
|
|
@@ -24,6 +24,8 @@ import * as modelUtil from '../../util/model';
|
|
|
24
24
|
import {getPercentWithPrecision} from '../../util/number';
|
|
25
25
|
import dataSelectableMixin from '../../component/helper/selectableMixin';
|
|
26
26
|
import {retrieveRawAttr} from '../../data/helper/dataProvider';
|
|
27
|
+
import {makeSeriesEncodeForNameBased} from '../../data/helper/sourceHelper';
|
|
28
|
+
import LegendVisualProvider from '../../visual/LegendVisualProvider';
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
var PieSeries = echarts.extendSeriesModel({
|
|
@@ -36,9 +38,9 @@ var PieSeries = echarts.extendSeriesModel({
|
|
|
36
38
|
|
|
37
39
|
// Enable legend selection for each data item
|
|
38
40
|
// Use a function instead of direct access because data reference may changed
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
this.legendVisualProvider = new LegendVisualProvider(
|
|
42
|
+
zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this)
|
|
43
|
+
);
|
|
42
44
|
|
|
43
45
|
this.updateSelectedMap(this._createSelectableList());
|
|
44
46
|
|
|
@@ -53,7 +55,10 @@ var PieSeries = echarts.extendSeriesModel({
|
|
|
53
55
|
},
|
|
54
56
|
|
|
55
57
|
getInitialData: function (option, ecModel) {
|
|
56
|
-
return createListSimply(this,
|
|
58
|
+
return createListSimply(this, {
|
|
59
|
+
coordDimensions: ['value'],
|
|
60
|
+
encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
|
|
61
|
+
});
|
|
57
62
|
},
|
|
58
63
|
|
|
59
64
|
_createSelectableList: function () {
|
|
@@ -142,12 +147,28 @@ var PieSeries = echarts.extendSeriesModel({
|
|
|
142
147
|
|
|
143
148
|
// cursor: null,
|
|
144
149
|
|
|
150
|
+
left: 0,
|
|
151
|
+
top: 0,
|
|
152
|
+
right: 0,
|
|
153
|
+
bottom: 0,
|
|
154
|
+
width: null,
|
|
155
|
+
height: null,
|
|
156
|
+
|
|
145
157
|
label: {
|
|
146
158
|
// If rotate around circle
|
|
147
159
|
rotate: false,
|
|
148
160
|
show: true,
|
|
149
161
|
// 'outer', 'inside', 'center'
|
|
150
|
-
position: 'outer'
|
|
162
|
+
position: 'outer',
|
|
163
|
+
// 'none', 'labelLine', 'edge'. Works only when position is 'outer'
|
|
164
|
+
alignTo: 'none',
|
|
165
|
+
// Closest distance between label and chart edge.
|
|
166
|
+
// Works only position is 'outer' and alignTo is 'edge'.
|
|
167
|
+
margin: '25%',
|
|
168
|
+
// Works only position is 'outer' and alignTo is not 'edge'.
|
|
169
|
+
bleedMargin: 10,
|
|
170
|
+
// Distance between text and label line.
|
|
171
|
+
distanceToLabelLine: 5
|
|
151
172
|
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
|
|
152
173
|
// 默认使用全局文本样式,详见TEXTSTYLE
|
|
153
174
|
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
|
package/src/chart/pie/PieView.js
CHANGED
|
@@ -273,7 +273,7 @@ piePieceProto._updateLabel = function (data, idx, withAnimation) {
|
|
|
273
273
|
{
|
|
274
274
|
labelFetcher: data.hostModel,
|
|
275
275
|
labelDataIndex: idx,
|
|
276
|
-
defaultText:
|
|
276
|
+
defaultText: labelLayout.text,
|
|
277
277
|
autoColor: visualColor,
|
|
278
278
|
useInsideStyle: !!labelLayout.inside
|
|
279
279
|
},
|
|
@@ -20,16 +20,21 @@
|
|
|
20
20
|
// FIXME emphasis label position is not same with normal label position
|
|
21
21
|
|
|
22
22
|
import * as textContain from 'zrender/src/contain/text';
|
|
23
|
+
import {parsePercent} from '../../util/number';
|
|
23
24
|
|
|
24
25
|
var RADIAN = Math.PI / 180;
|
|
25
26
|
|
|
26
|
-
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
27
|
+
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
|
|
27
28
|
list.sort(function (a, b) {
|
|
28
29
|
return a.y - b.y;
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
function shiftDown(start, end, delta, dir) {
|
|
32
33
|
for (var j = start; j < end; j++) {
|
|
34
|
+
if (list[j].y + delta > viewTop + viewHeight) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
list[j].y += delta;
|
|
34
39
|
if (j > start
|
|
35
40
|
&& j + 1 < end
|
|
@@ -45,6 +50,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
45
50
|
|
|
46
51
|
function shiftUp(end, delta) {
|
|
47
52
|
for (var j = end; j >= 0; j--) {
|
|
53
|
+
if (list[j].y - delta < viewTop) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
list[j].y -= delta;
|
|
49
58
|
if (j > 0
|
|
50
59
|
&& list[j].y > list[j - 1].y + list[j - 1].height
|
|
@@ -64,6 +73,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
64
73
|
: 0; // up
|
|
65
74
|
|
|
66
75
|
for (var i = 0, l = list.length; i < l; i++) {
|
|
76
|
+
if (list[i].labelAlignTo !== 'none') {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
67
80
|
var deltaY = Math.abs(list[i].y - cy);
|
|
68
81
|
var length = list[i].len;
|
|
69
82
|
var length2 = list[i].len2;
|
|
@@ -93,6 +106,12 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
93
106
|
var upList = [];
|
|
94
107
|
var downList = [];
|
|
95
108
|
for (var i = 0; i < len; i++) {
|
|
109
|
+
if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
|
|
110
|
+
var dx = list[i].x - farthestX;
|
|
111
|
+
list[i].linePoints[1][0] += dx;
|
|
112
|
+
list[i].x = farthestX;
|
|
113
|
+
}
|
|
114
|
+
|
|
96
115
|
delta = list[i].y - lastY;
|
|
97
116
|
if (delta < 0) {
|
|
98
117
|
shiftDown(i, len, -delta, dir);
|
|
@@ -114,39 +133,85 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
114
133
|
changeX(downList, true, cx, cy, r, dir);
|
|
115
134
|
}
|
|
116
135
|
|
|
117
|
-
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
136
|
+
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
118
137
|
var leftList = [];
|
|
119
138
|
var rightList = [];
|
|
139
|
+
var leftmostX = Number.MAX_VALUE;
|
|
140
|
+
var rightmostX = -Number.MAX_VALUE;
|
|
120
141
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
121
142
|
if (isPositionCenter(labelLayoutList[i])) {
|
|
122
143
|
continue;
|
|
123
144
|
}
|
|
124
145
|
if (labelLayoutList[i].x < cx) {
|
|
146
|
+
leftmostX = Math.min(leftmostX, labelLayoutList[i].x);
|
|
125
147
|
leftList.push(labelLayoutList[i]);
|
|
126
148
|
}
|
|
127
149
|
else {
|
|
150
|
+
rightmostX = Math.max(rightmostX, labelLayoutList[i].x);
|
|
128
151
|
rightList.push(labelLayoutList[i]);
|
|
129
152
|
}
|
|
130
153
|
}
|
|
131
154
|
|
|
132
|
-
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
|
|
133
|
-
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
|
|
155
|
+
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
|
|
156
|
+
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
|
|
134
157
|
|
|
135
158
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
136
|
-
|
|
159
|
+
var layout = labelLayoutList[i];
|
|
160
|
+
if (isPositionCenter(layout)) {
|
|
137
161
|
continue;
|
|
138
162
|
}
|
|
139
|
-
|
|
163
|
+
|
|
164
|
+
var linePoints = layout.linePoints;
|
|
140
165
|
if (linePoints) {
|
|
166
|
+
var isAlignToEdge = layout.labelAlignTo === 'edge';
|
|
167
|
+
|
|
168
|
+
var realTextWidth = layout.textRect.width;
|
|
169
|
+
var targetTextWidth;
|
|
170
|
+
if (isAlignToEdge) {
|
|
171
|
+
if (layout.x < cx) {
|
|
172
|
+
targetTextWidth = linePoints[2][0] - layout.labelDistance
|
|
173
|
+
- viewLeft - layout.labelMargin;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
targetTextWidth = viewLeft + viewWidth - layout.labelMargin
|
|
177
|
+
- linePoints[2][0] - layout.labelDistance;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (layout.x < cx) {
|
|
182
|
+
targetTextWidth = layout.x - viewLeft - layout.bleedMargin;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
targetTextWidth = viewLeft + viewWidth - layout.x - layout.bleedMargin;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (targetTextWidth < layout.textRect.width) {
|
|
189
|
+
layout.text = textContain.truncateText(layout.text, targetTextWidth, layout.font);
|
|
190
|
+
if (layout.labelAlignTo === 'edge') {
|
|
191
|
+
realTextWidth = textContain.getWidth(layout.text, layout.font);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
141
195
|
var dist = linePoints[1][0] - linePoints[2][0];
|
|
142
|
-
if (
|
|
143
|
-
|
|
196
|
+
if (isAlignToEdge) {
|
|
197
|
+
if (layout.x < cx) {
|
|
198
|
+
linePoints[2][0] = viewLeft + layout.labelMargin + realTextWidth + layout.labelDistance;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
linePoints[2][0] = viewLeft + viewWidth - layout.labelMargin
|
|
202
|
+
- realTextWidth - layout.labelDistance;
|
|
203
|
+
}
|
|
144
204
|
}
|
|
145
205
|
else {
|
|
146
|
-
|
|
206
|
+
if (layout.x < cx) {
|
|
207
|
+
linePoints[2][0] = layout.x + layout.labelDistance;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
linePoints[2][0] = layout.x - layout.labelDistance;
|
|
211
|
+
}
|
|
212
|
+
linePoints[1][0] = linePoints[2][0] + dist;
|
|
147
213
|
}
|
|
148
|
-
linePoints[1][1] = linePoints[2][1] =
|
|
149
|
-
linePoints[1][0] = linePoints[2][0] + dist;
|
|
214
|
+
linePoints[1][1] = linePoints[2][1] = layout.y;
|
|
150
215
|
}
|
|
151
216
|
}
|
|
152
217
|
}
|
|
@@ -156,7 +221,7 @@ function isPositionCenter(layout) {
|
|
|
156
221
|
return layout.position === 'center';
|
|
157
222
|
}
|
|
158
223
|
|
|
159
|
-
export default function (seriesModel, r, viewWidth, viewHeight,
|
|
224
|
+
export default function (seriesModel, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
160
225
|
var data = seriesModel.getData();
|
|
161
226
|
var labelLayoutList = [];
|
|
162
227
|
var cx;
|
|
@@ -171,10 +236,17 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
171
236
|
var labelModel = itemModel.getModel('label');
|
|
172
237
|
// Use position in normal or emphasis
|
|
173
238
|
var labelPosition = labelModel.get('position') || itemModel.get('emphasis.label.position');
|
|
239
|
+
var labelDistance = labelModel.get('distanceToLabelLine');
|
|
240
|
+
var labelAlignTo = labelModel.get('alignTo');
|
|
241
|
+
var labelMargin = parsePercent(labelModel.get('margin'), viewWidth);
|
|
242
|
+
var bleedMargin = labelModel.get('bleedMargin');
|
|
243
|
+
var font = labelModel.getFont();
|
|
174
244
|
|
|
175
245
|
var labelLineModel = itemModel.getModel('labelLine');
|
|
176
246
|
var labelLineLen = labelLineModel.get('length');
|
|
247
|
+
labelLineLen = parsePercent(labelLineLen, viewWidth);
|
|
177
248
|
var labelLineLen2 = labelLineModel.get('length2');
|
|
249
|
+
labelLineLen2 = parsePercent(labelLineLen2, viewWidth);
|
|
178
250
|
|
|
179
251
|
if (layout.angle < minShowLabelRadian) {
|
|
180
252
|
return;
|
|
@@ -192,6 +264,12 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
192
264
|
cx = layout.cx;
|
|
193
265
|
cy = layout.cy;
|
|
194
266
|
|
|
267
|
+
var text = seriesModel.getFormattedLabel(idx, 'normal')
|
|
268
|
+
|| data.getName(idx);
|
|
269
|
+
var textRect = textContain.getBoundingRect(
|
|
270
|
+
text, font, textAlign, 'top'
|
|
271
|
+
);
|
|
272
|
+
|
|
195
273
|
var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
|
|
196
274
|
if (labelPosition === 'center') {
|
|
197
275
|
textX = layout.cx;
|
|
@@ -212,14 +290,25 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
212
290
|
var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
|
|
213
291
|
var y3 = y2;
|
|
214
292
|
|
|
215
|
-
|
|
293
|
+
if (labelAlignTo === 'edge') {
|
|
294
|
+
// Adjust textX because text align of edge is opposite
|
|
295
|
+
textX = dx < 0
|
|
296
|
+
? viewLeft + labelMargin
|
|
297
|
+
: viewLeft + viewWidth - labelMargin;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
textX = x3 + (dx < 0 ? -labelDistance : labelDistance);
|
|
301
|
+
}
|
|
216
302
|
textY = y3;
|
|
217
303
|
linePoints = [[x1, y1], [x2, y2], [x3, y3]];
|
|
218
304
|
}
|
|
219
305
|
|
|
220
|
-
textAlign = isLabelInside
|
|
306
|
+
textAlign = isLabelInside
|
|
307
|
+
? 'center'
|
|
308
|
+
: (labelAlignTo === 'edge'
|
|
309
|
+
? (dx > 0 ? 'right' : 'left')
|
|
310
|
+
: (dx > 0 ? 'left' : 'right'));
|
|
221
311
|
}
|
|
222
|
-
var font = labelModel.getFont();
|
|
223
312
|
|
|
224
313
|
var labelRotate;
|
|
225
314
|
var rotate = labelModel.get('rotate');
|
|
@@ -231,11 +320,7 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
231
320
|
? (dx < 0 ? -midAngle + Math.PI : -midAngle)
|
|
232
321
|
: 0;
|
|
233
322
|
}
|
|
234
|
-
|
|
235
|
-
|| data.getName(idx);
|
|
236
|
-
var textRect = textContain.getBoundingRect(
|
|
237
|
-
text, font, textAlign, 'top'
|
|
238
|
-
);
|
|
323
|
+
|
|
239
324
|
hasLabelRotate = !!labelRotate;
|
|
240
325
|
layout.label = {
|
|
241
326
|
x: textX,
|
|
@@ -248,7 +333,14 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
248
333
|
textAlign: textAlign,
|
|
249
334
|
verticalAlign: 'middle',
|
|
250
335
|
rotation: labelRotate,
|
|
251
|
-
inside: isLabelInside
|
|
336
|
+
inside: isLabelInside,
|
|
337
|
+
labelDistance: labelDistance,
|
|
338
|
+
labelAlignTo: labelAlignTo,
|
|
339
|
+
labelMargin:labelMargin,
|
|
340
|
+
bleedMargin: bleedMargin,
|
|
341
|
+
textRect: textRect,
|
|
342
|
+
text: text,
|
|
343
|
+
font: font
|
|
252
344
|
};
|
|
253
345
|
|
|
254
346
|
// Not layout the inside label
|
|
@@ -257,6 +349,6 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
257
349
|
}
|
|
258
350
|
});
|
|
259
351
|
if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
|
|
260
|
-
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
|
|
352
|
+
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
|
|
261
353
|
}
|
|
262
354
|
}
|
|
@@ -19,16 +19,27 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
import {parsePercent, linearMap} from '../../util/number';
|
|
22
|
+
import * as layout from '../../util/layout';
|
|
22
23
|
import labelLayout from './labelLayout';
|
|
23
24
|
import * as zrUtil from 'zrender/src/core/util';
|
|
24
25
|
|
|
25
26
|
var PI2 = Math.PI * 2;
|
|
26
27
|
var RADIAN = Math.PI / 180;
|
|
27
28
|
|
|
29
|
+
function getViewRect(seriesModel, api) {
|
|
30
|
+
return layout.getLayoutRect(
|
|
31
|
+
seriesModel.getBoxLayoutParams(), {
|
|
32
|
+
width: api.getWidth(),
|
|
33
|
+
height: api.getHeight()
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
export default function (seriesType, ecModel, api, payload) {
|
|
29
39
|
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
|
30
40
|
var data = seriesModel.getData();
|
|
31
41
|
var valueDim = data.mapDimension('value');
|
|
42
|
+
var viewRect = getViewRect(seriesModel, api);
|
|
32
43
|
|
|
33
44
|
var center = seriesModel.get('center');
|
|
34
45
|
var radius = seriesModel.get('radius');
|
|
@@ -40,11 +51,11 @@ export default function (seriesType, ecModel, api, payload) {
|
|
|
40
51
|
center = [center, center];
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
var width = api.getWidth();
|
|
44
|
-
var height = api.getHeight();
|
|
54
|
+
var width = parsePercent(viewRect.width, api.getWidth());
|
|
55
|
+
var height = parsePercent(viewRect.height, api.getHeight());
|
|
45
56
|
var size = Math.min(width, height);
|
|
46
|
-
var cx = parsePercent(center[0], width);
|
|
47
|
-
var cy = parsePercent(center[1], height);
|
|
57
|
+
var cx = parsePercent(center[0], width) + viewRect.x;
|
|
58
|
+
var cy = parsePercent(center[1], height) + viewRect.y;
|
|
48
59
|
var r0 = parsePercent(radius[0], size / 2);
|
|
49
60
|
var r = parsePercent(radius[1], size / 2);
|
|
50
61
|
|
|
@@ -90,7 +101,8 @@ export default function (seriesType, ecModel, api, payload) {
|
|
|
90
101
|
r0: r0,
|
|
91
102
|
r: roseType
|
|
92
103
|
? NaN
|
|
93
|
-
: r
|
|
104
|
+
: r,
|
|
105
|
+
viewRect: viewRect
|
|
94
106
|
});
|
|
95
107
|
return;
|
|
96
108
|
}
|
|
@@ -123,7 +135,8 @@ export default function (seriesType, ecModel, api, payload) {
|
|
|
123
135
|
r0: r0,
|
|
124
136
|
r: roseType
|
|
125
137
|
? linearMap(value, extent, [r0, r])
|
|
126
|
-
: r
|
|
138
|
+
: r,
|
|
139
|
+
viewRect: viewRect
|
|
127
140
|
});
|
|
128
141
|
|
|
129
142
|
currentAngle = endAngle;
|
|
@@ -161,6 +174,6 @@ export default function (seriesType, ecModel, api, payload) {
|
|
|
161
174
|
}
|
|
162
175
|
}
|
|
163
176
|
|
|
164
|
-
labelLayout(seriesModel, r, width, height);
|
|
177
|
+
labelLayout(seriesModel, r, viewRect.width, viewRect.height, viewRect.x, viewRect.y);
|
|
165
178
|
});
|
|
166
179
|
}
|
|
@@ -21,6 +21,7 @@ import SeriesModel from '../../model/Series';
|
|
|
21
21
|
import createListSimply from '../helper/createListSimply';
|
|
22
22
|
import * as zrUtil from 'zrender/src/core/util';
|
|
23
23
|
import {encodeHTML} from '../../util/format';
|
|
24
|
+
import LegendVisualProvider from '../../visual/LegendVisualProvider';
|
|
24
25
|
|
|
25
26
|
var RadarSeries = SeriesModel.extend({
|
|
26
27
|
|
|
@@ -35,9 +36,10 @@ var RadarSeries = SeriesModel.extend({
|
|
|
35
36
|
|
|
36
37
|
// Enable legend selection for each data item
|
|
37
38
|
// Use a function instead of direct access because data reference may changed
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
this.legendVisualProvider = new LegendVisualProvider(
|
|
40
|
+
zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this)
|
|
41
|
+
);
|
|
42
|
+
|
|
41
43
|
},
|
|
42
44
|
|
|
43
45
|
getInitialData: function (option, ecModel) {
|