echarts 3.6.1 → 3.7.2
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/README.md +1 -0
- package/dist/echarts-en.js +77756 -0
- package/dist/echarts-en.min.js +38 -0
- package/dist/echarts.common-en.js +50169 -0
- package/dist/echarts.common-en.min.js +30 -0
- package/dist/echarts.common.js +5799 -3093
- package/dist/echarts.common.min.js +14 -13
- package/dist/echarts.js +7628 -4679
- package/dist/echarts.min.js +22 -22
- package/dist/echarts.simple-en.js +34988 -0
- package/dist/echarts.simple-en.min.js +27 -0
- package/dist/echarts.simple.js +4472 -2493
- package/dist/echarts.simple.min.js +11 -9
- package/dist/extension/bmap.js +50 -11
- package/dist/extension/bmap.min.js +1 -1
- package/dist/extension/dataTool.js +10 -10
- package/extension/bmap/BMapCoordSys.js +40 -1
- package/index.blank.js +4 -0
- package/index.common.js +1 -1
- package/index.js +1 -1
- package/lib/action/createDataSelectAction.js +6 -2
- package/lib/chart/bar/BarView.js +6 -3
- package/lib/chart/bar/BaseBarSeries.js +4 -3
- package/lib/chart/bar/PictorialBarSeries.js +1 -1
- package/lib/chart/bar/PictorialBarView.js +29 -7
- package/lib/chart/bar/helper.js +14 -31
- package/lib/chart/candlestick/candlestickLayout.js +49 -6
- package/lib/chart/chord/chordCircularLayout.js +2 -2
- package/lib/chart/custom.js +135 -21
- package/lib/chart/funnel/FunnelSeries.js +0 -1
- package/lib/chart/funnel/FunnelView.js +15 -22
- package/lib/chart/funnel/funnelLayout.js +1 -1
- package/lib/chart/gauge/GaugeSeries.js +7 -12
- package/lib/chart/gauge/GaugeView.js +32 -53
- package/lib/chart/graph/GraphSeries.js +2 -1
- package/lib/chart/graph/GraphView.js +39 -45
- package/lib/chart/graph/forceHelper.js +5 -0
- package/lib/chart/graph/forceLayout.js +1 -1
- package/lib/chart/heatmap/HeatmapLayer.js +7 -0
- package/lib/chart/heatmap/HeatmapView.js +10 -9
- package/lib/chart/helper/EffectSymbol.js +3 -3
- package/lib/chart/helper/LargeSymbolDraw.js +6 -1
- package/lib/chart/helper/Line.js +40 -22
- package/lib/chart/helper/Symbol.js +20 -7
- package/lib/chart/helper/SymbolDraw.js +2 -1
- package/lib/chart/helper/labelHelper.js +0 -17
- package/lib/chart/helper/whiskerBoxCommon.js +11 -3
- package/lib/chart/line/LineSeries.js +1 -0
- package/lib/chart/line/LineView.js +14 -2
- package/lib/chart/line/poly.js +5 -0
- package/lib/chart/lines/LinesView.js +22 -7
- package/lib/chart/map/MapSeries.js +3 -7
- package/lib/chart/map/MapView.js +29 -18
- package/lib/chart/pie/PieSeries.js +20 -6
- package/lib/chart/pie/PieView.js +20 -23
- package/lib/chart/pie/labelLayout.js +3 -3
- package/lib/chart/radar/RadarView.js +16 -20
- package/lib/chart/sankey/SankeySeries.js +2 -4
- package/lib/chart/sankey/SankeyView.js +13 -29
- package/lib/chart/sankey/sankeyLayout.js +1 -1
- package/lib/chart/scatter/ScatterSeries.js +2 -1
- package/lib/chart/themeRiver/ThemeRiverSeries.js +2 -4
- package/lib/chart/themeRiver/ThemeRiverView.js +2 -5
- package/lib/chart/themeRiver/themeRiverLayout.js +1 -1
- package/lib/chart/treemap/Breadcrumb.js +1 -1
- package/lib/chart/treemap/TreemapSeries.js +28 -8
- package/lib/chart/treemap/TreemapView.js +88 -77
- package/lib/chart/treemap/treemapLayout.js +29 -13
- package/lib/component/axis/AngleAxisView.js +13 -19
- package/lib/component/axis/AxisBuilder.js +260 -186
- package/lib/component/axis/CartesianAxisView.js +15 -3
- package/lib/component/axis/ParallelAxisView.js +1 -1
- package/lib/component/axis/RadiusAxisView.js +1 -1
- package/lib/component/axis/SingleAxisView.js +8 -2
- package/lib/component/axis/cartesianAxisHelper.js +11 -15
- package/lib/component/axisPointer/AxisPointerModel.js +1 -3
- package/lib/component/axisPointer/BaseAxisPointer.js +15 -38
- package/lib/component/axisPointer/axisTrigger.js +36 -20
- package/lib/component/axisPointer/modelHelper.js +3 -4
- package/lib/component/axisPointer/viewHelper.js +4 -6
- package/lib/component/axisPointer.js +1 -14
- package/lib/component/calendar/CalendarView.js +22 -39
- package/lib/component/dataZoom/AxisProxy.js +3 -2
- package/lib/component/dataZoom/DataZoomModel.js +16 -4
- package/lib/component/dataZoom/InsideZoomView.js +5 -3
- package/lib/component/dataZoom/SliderZoomView.js +21 -32
- package/lib/component/dataZoom/roams.js +33 -9
- package/lib/component/dataZoom/typeDefaulter.js +1 -1
- package/lib/component/graphic.js +17 -5
- package/lib/component/helper/BrushTargetManager.js +1 -1
- package/lib/component/helper/MapDraw.js +26 -22
- package/lib/component/helper/RoamController.js +12 -11
- package/lib/component/helper/listComponent.js +27 -24
- package/lib/component/helper/selectableMixin.js +40 -15
- package/lib/component/legend/LegendModel.js +11 -3
- package/lib/component/legend/LegendView.js +151 -70
- package/lib/component/legend/ScrollableLegendModel.js +75 -0
- package/lib/component/legend/ScrollableLegendView.js +367 -0
- package/lib/component/legend/legendAction.js +1 -0
- package/lib/component/legend/scrollableLegendAction.js +24 -0
- package/lib/component/legend.js +8 -3
- package/lib/component/legendScroll.js +11 -0
- package/lib/component/marker/MarkAreaView.js +12 -26
- package/lib/component/marker/MarkLineView.js +5 -5
- package/lib/component/marker/MarkPointView.js +4 -4
- package/lib/component/marker/MarkerModel.js +1 -4
- package/lib/component/marker/markerHelper.js +1 -0
- package/lib/component/radar/RadarView.js +6 -3
- package/lib/component/timeline/SliderTimelineModel.js +4 -6
- package/lib/component/timeline/SliderTimelineView.js +14 -16
- package/lib/component/timeline/TimelineAxis.js +1 -1
- package/lib/component/timeline/TimelineModel.js +1 -3
- package/lib/component/title.js +9 -10
- package/lib/component/toolbox/ToolboxModel.js +2 -0
- package/lib/component/toolbox/ToolboxView.js +15 -27
- package/lib/component/toolbox/feature/Brush.js +3 -8
- package/lib/component/toolbox/feature/DataView.js +5 -5
- package/lib/component/toolbox/feature/DataZoom.js +3 -4
- package/lib/component/toolbox/feature/MagicType.js +3 -6
- package/lib/component/toolbox/feature/Restore.js +2 -1
- package/lib/component/toolbox/feature/SaveAsImage.js +23 -9
- package/lib/component/tooltip/TooltipContent.js +4 -4
- package/lib/component/tooltip/TooltipView.js +29 -6
- package/lib/component/visualMap/ContinuousModel.js +2 -2
- package/lib/component/visualMap/ContinuousView.js +12 -8
- package/lib/component/visualMap/PiecewiseModel.js +1 -2
- package/lib/component/visualMap/PiecewiseView.js +2 -2
- package/lib/component/visualMap/VisualMapModel.js +18 -12
- package/lib/coord/Axis.js +1 -1
- package/lib/coord/axisDefault.js +3 -3
- package/lib/coord/axisHelper.js +18 -1
- package/lib/coord/axisModelCommonMixin.js +12 -2
- package/lib/coord/calendar/Calendar.js +65 -21
- package/lib/coord/calendar/CalendarModel.js +6 -12
- package/lib/coord/cartesian/Cartesian2D.js +0 -14
- package/lib/coord/cartesian/Grid.js +47 -28
- package/lib/coord/geo/Geo.js +2 -18
- package/lib/coord/geo/GeoModel.js +6 -13
- package/lib/coord/geo/fix/diaoyuIsland.js +30 -0
- package/lib/coord/geo/geoCreator.js +6 -1
- package/lib/coord/polar/Polar.js +0 -13
- package/lib/coord/radar/Radar.js +1 -1
- package/lib/coord/radar/RadarModel.js +6 -2
- package/lib/data/DataDiffer.js +14 -7
- package/lib/data/Graph.js +3 -0
- package/lib/data/List.js +1 -1
- package/lib/data/Tree.js +2 -2
- package/lib/data/helper/completeDimensions.js +2 -11
- package/lib/echarts.js +33 -10
- package/lib/lang/cn.js +4 -0
- package/lib/lang/default.js +42 -0
- package/lib/lang/en.js +42 -0
- package/lib/lang.js +42 -0
- package/lib/langEN.js +42 -0
- package/lib/layout/barGrid.js +11 -3
- package/lib/layout/barPolar.js +9 -2
- package/lib/model/Model.js +2 -1
- package/lib/model/Series.js +14 -6
- package/lib/model/mixin/textStyle.js +11 -9
- package/lib/preprocessor/backwardCompat.js +5 -4
- package/lib/preprocessor/helper/compatStyle.js +157 -45
- package/lib/scale/Interval.js +10 -4
- package/lib/scale/Time.js +14 -6
- package/lib/scale/helper.js +15 -2
- package/lib/util/format.js +4 -24
- package/lib/util/graphic.js +412 -21
- package/lib/util/layout.js +28 -16
- package/lib/util/model.js +26 -11
- package/lib/util/number.js +106 -21
- package/lib/visual/VisualMapping.js +4 -4
- package/package.json +3 -3
- package/rollup.config.js +49 -0
- package/src/action/createDataSelectAction.js +6 -2
- package/src/chart/bar/BarView.js +6 -3
- package/src/chart/bar/BaseBarSeries.js +4 -3
- package/src/chart/bar/PictorialBarSeries.js +1 -1
- package/src/chart/bar/PictorialBarView.js +29 -7
- package/src/chart/bar/helper.js +13 -30
- package/src/chart/candlestick/candlestickLayout.js +49 -6
- package/src/chart/chord/chordCircularLayout.js +2 -2
- package/src/chart/custom.js +135 -21
- package/src/chart/funnel/FunnelSeries.js +0 -1
- package/src/chart/funnel/FunnelView.js +15 -22
- package/src/chart/funnel/funnelLayout.js +1 -1
- package/src/chart/gauge/GaugeSeries.js +7 -12
- package/src/chart/gauge/GaugeView.js +32 -53
- package/src/chart/graph/GraphSeries.js +2 -1
- package/src/chart/graph/GraphView.js +39 -45
- package/src/chart/graph/forceHelper.js +5 -0
- package/src/chart/graph/forceLayout.js +1 -1
- package/src/chart/heatmap/HeatmapLayer.js +7 -0
- package/src/chart/heatmap/HeatmapView.js +10 -9
- package/src/chart/helper/EffectSymbol.js +3 -3
- package/src/chart/helper/LargeSymbolDraw.js +6 -1
- package/src/chart/helper/Line.js +40 -22
- package/src/chart/helper/Symbol.js +20 -7
- package/src/chart/helper/SymbolDraw.js +2 -1
- package/src/chart/helper/labelHelper.js +0 -17
- package/src/chart/helper/whiskerBoxCommon.js +11 -4
- package/src/chart/line/LineSeries.js +1 -0
- package/src/chart/line/LineView.js +14 -2
- package/src/chart/line/poly.js +5 -0
- package/src/chart/lines/LinesView.js +22 -7
- package/src/chart/map/MapSeries.js +3 -7
- package/src/chart/map/MapView.js +29 -18
- package/src/chart/pie/PieSeries.js +20 -6
- package/src/chart/pie/PieView.js +20 -23
- package/src/chart/pie/labelLayout.js +3 -3
- package/src/chart/radar/RadarView.js +16 -20
- package/src/chart/sankey/SankeySeries.js +2 -4
- package/src/chart/sankey/SankeyView.js +13 -29
- package/src/chart/sankey/sankeyLayout.js +1 -1
- package/src/chart/scatter/ScatterSeries.js +2 -1
- package/src/chart/themeRiver/ThemeRiverSeries.js +2 -4
- package/src/chart/themeRiver/ThemeRiverView.js +2 -5
- package/src/chart/themeRiver/themeRiverLayout.js +1 -1
- package/src/chart/treemap/Breadcrumb.js +1 -1
- package/src/chart/treemap/TreemapSeries.js +28 -8
- package/src/chart/treemap/TreemapView.js +88 -77
- package/src/chart/treemap/treemapLayout.js +29 -13
- package/src/component/axis/AngleAxisView.js +13 -19
- package/src/component/axis/AxisBuilder.js +260 -186
- package/src/component/axis/CartesianAxisView.js +15 -3
- package/src/component/axis/ParallelAxisView.js +1 -1
- package/src/component/axis/RadiusAxisView.js +1 -1
- package/src/component/axis/SingleAxisView.js +8 -2
- package/src/component/axis/cartesianAxisHelper.js +11 -15
- package/src/component/axisPointer/AxisPointerModel.js +1 -3
- package/src/component/axisPointer/BaseAxisPointer.js +15 -38
- package/src/component/axisPointer/axisTrigger.js +36 -20
- package/src/component/axisPointer/modelHelper.js +3 -4
- package/src/component/axisPointer/viewHelper.js +4 -6
- package/src/component/axisPointer.js +1 -14
- package/src/component/calendar/CalendarView.js +22 -39
- package/src/component/dataZoom/AxisProxy.js +3 -2
- package/src/component/dataZoom/DataZoomModel.js +16 -4
- package/src/component/dataZoom/InsideZoomView.js +5 -3
- package/src/component/dataZoom/SliderZoomView.js +21 -32
- package/src/component/dataZoom/roams.js +33 -9
- package/src/component/dataZoom/typeDefaulter.js +1 -1
- package/src/component/graphic.js +17 -5
- package/src/component/helper/BrushTargetManager.js +1 -1
- package/src/component/helper/MapDraw.js +26 -22
- package/src/component/helper/RoamController.js +12 -11
- package/src/component/helper/listComponent.js +27 -24
- package/src/component/helper/selectableMixin.js +40 -15
- package/src/component/legend/LegendModel.js +11 -3
- package/src/component/legend/LegendView.js +151 -70
- package/src/component/legend/ScrollableLegendModel.js +76 -0
- package/src/component/legend/ScrollableLegendView.js +368 -0
- package/src/component/legend/legendAction.js +1 -0
- package/src/component/legend/scrollableLegendAction.js +25 -0
- package/src/component/legend.js +8 -3
- package/src/component/legendScroll.js +12 -0
- package/src/component/marker/MarkAreaView.js +12 -26
- package/src/component/marker/MarkLineView.js +5 -5
- package/src/component/marker/MarkPointView.js +4 -4
- package/src/component/marker/MarkerModel.js +1 -4
- package/src/component/marker/markerHelper.js +1 -0
- package/src/component/radar/RadarView.js +6 -3
- package/src/component/timeline/SliderTimelineModel.js +4 -6
- package/src/component/timeline/SliderTimelineView.js +14 -16
- package/src/component/timeline/TimelineAxis.js +1 -1
- package/src/component/timeline/TimelineModel.js +1 -3
- package/src/component/title.js +9 -10
- package/src/component/toolbox/ToolboxModel.js +2 -0
- package/src/component/toolbox/ToolboxView.js +15 -27
- package/src/component/toolbox/feature/Brush.js +3 -8
- package/src/component/toolbox/feature/DataView.js +5 -5
- package/src/component/toolbox/feature/DataZoom.js +3 -4
- package/src/component/toolbox/feature/MagicType.js +3 -6
- package/src/component/toolbox/feature/Restore.js +2 -1
- package/src/component/toolbox/feature/SaveAsImage.js +23 -10
- package/src/component/tooltip/TooltipContent.js +4 -4
- package/src/component/tooltip/TooltipView.js +29 -7
- package/src/component/visualMap/ContinuousModel.js +2 -2
- package/src/component/visualMap/ContinuousView.js +12 -8
- package/src/component/visualMap/PiecewiseModel.js +1 -2
- package/src/component/visualMap/PiecewiseView.js +2 -2
- package/src/component/visualMap/VisualMapModel.js +18 -12
- package/src/coord/Axis.js +1 -1
- package/src/coord/axisDefault.js +3 -3
- package/src/coord/axisHelper.js +18 -1
- package/src/coord/axisModelCommonMixin.js +12 -2
- package/src/coord/calendar/Calendar.js +65 -21
- package/src/coord/calendar/CalendarModel.js +6 -12
- package/src/coord/cartesian/Cartesian2D.js +0 -14
- package/src/coord/cartesian/Grid.js +47 -28
- package/src/coord/geo/Geo.js +2 -18
- package/src/coord/geo/GeoModel.js +6 -13
- package/src/coord/geo/fix/diaoyuIsland.js +30 -0
- package/src/coord/geo/geoCreator.js +6 -1
- package/src/coord/polar/Polar.js +0 -13
- package/src/coord/radar/Radar.js +1 -1
- package/src/coord/radar/RadarModel.js +6 -2
- package/src/data/DataDiffer.js +14 -7
- package/src/data/Graph.js +3 -0
- package/src/data/List.js +1 -1
- package/src/data/Tree.js +2 -2
- package/src/data/helper/completeDimensions.js +2 -11
- package/src/echarts.js +33 -10
- package/src/lang.js +43 -0
- package/src/langEN.js +43 -0
- package/src/layout/barGrid.js +11 -3
- package/src/layout/barPolar.js +9 -2
- package/src/model/Model.js +2 -1
- package/src/model/Series.js +14 -6
- package/src/model/mixin/textStyle.js +11 -9
- package/src/preprocessor/backwardCompat.js +5 -4
- package/src/preprocessor/helper/compatStyle.js +157 -45
- package/src/scale/Interval.js +10 -4
- package/src/scale/Time.js +14 -6
- package/src/scale/helper.js +15 -2
- package/src/util/format.js +4 -24
- package/src/util/graphic.js +412 -21
- package/src/util/layout.js +28 -16
- package/src/util/model.js +26 -11
- package/src/util/number.js +106 -21
- package/src/visual/VisualMapping.js +4 -4
- package/webpack.config.js +21 -7
- package/.npmignore +0 -10
|
@@ -13,6 +13,11 @@ define(function (require) {
|
|
|
13
13
|
var retrieveValue = zrUtil.retrieve;
|
|
14
14
|
var each = zrUtil.each;
|
|
15
15
|
|
|
16
|
+
var PATH_BORDER_WIDTH = ['itemStyle', 'normal', 'borderWidth'];
|
|
17
|
+
var PATH_GAP_WIDTH = ['itemStyle', 'normal', 'gapWidth'];
|
|
18
|
+
var PATH_UPPER_LABEL_SHOW = ['upperLabel', 'normal', 'show'];
|
|
19
|
+
var PATH_UPPER_LABEL_HEIGHT = ['upperLabel', 'normal', 'height'];
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* @public
|
|
18
23
|
*/
|
|
@@ -92,7 +97,7 @@ define(function (require) {
|
|
|
92
97
|
each(viewAbovePath, function (node, index) {
|
|
93
98
|
var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
|
|
94
99
|
node.setLayout(zrUtil.extend(
|
|
95
|
-
{dataExtent: [childValue, childValue], borderWidth: 0},
|
|
100
|
+
{dataExtent: [childValue, childValue], borderWidth: 0, upperHeight: 0},
|
|
96
101
|
viewRootLayout
|
|
97
102
|
));
|
|
98
103
|
});
|
|
@@ -146,16 +151,23 @@ define(function (require) {
|
|
|
146
151
|
height = thisLayout.height;
|
|
147
152
|
|
|
148
153
|
// Considering border and gap
|
|
149
|
-
var
|
|
150
|
-
var borderWidth =
|
|
151
|
-
var halfGapWidth =
|
|
154
|
+
var nodeModel = node.getModel();
|
|
155
|
+
var borderWidth = nodeModel.get(PATH_BORDER_WIDTH);
|
|
156
|
+
var halfGapWidth = nodeModel.get(PATH_GAP_WIDTH) / 2;
|
|
157
|
+
var upperLabelHeight = getUpperLabelHeight(nodeModel);
|
|
158
|
+
var upperHeight = Math.max(borderWidth, upperLabelHeight);
|
|
152
159
|
var layoutOffset = borderWidth - halfGapWidth;
|
|
160
|
+
var layoutOffsetUpper = upperHeight - halfGapWidth;
|
|
153
161
|
var nodeModel = node.getModel();
|
|
154
162
|
|
|
155
|
-
node.setLayout({
|
|
163
|
+
node.setLayout({
|
|
164
|
+
borderWidth: borderWidth,
|
|
165
|
+
upperHeight: upperHeight,
|
|
166
|
+
upperLabelHeight: upperLabelHeight
|
|
167
|
+
}, true);
|
|
156
168
|
|
|
157
169
|
width = mathMax(width - 2 * layoutOffset, 0);
|
|
158
|
-
height = mathMax(height -
|
|
170
|
+
height = mathMax(height - layoutOffset - layoutOffsetUpper, 0);
|
|
159
171
|
|
|
160
172
|
var totalArea = width * height;
|
|
161
173
|
var viewChildren = initChildren(
|
|
@@ -166,7 +178,7 @@ define(function (require) {
|
|
|
166
178
|
return;
|
|
167
179
|
}
|
|
168
180
|
|
|
169
|
-
var rect = {x: layoutOffset, y:
|
|
181
|
+
var rect = {x: layoutOffset, y: layoutOffsetUpper, width: width, height: height};
|
|
170
182
|
var rowFixedLength = mathMin(width, height);
|
|
171
183
|
var best = Infinity; // the best row score so far
|
|
172
184
|
var row = [];
|
|
@@ -459,12 +471,12 @@ define(function (require) {
|
|
|
459
471
|
}
|
|
460
472
|
area *= sum / currNodeValue;
|
|
461
473
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
474
|
+
// Considering border, suppose aspect ratio is 1.
|
|
475
|
+
var parentModel = parent.getModel();
|
|
476
|
+
var borderWidth = parentModel.get(PATH_BORDER_WIDTH);
|
|
477
|
+
var upperHeight = Math.max(borderWidth, getUpperLabelHeight(parentModel, borderWidth));
|
|
478
|
+
area += 4 * borderWidth * borderWidth
|
|
479
|
+
+ (3 * borderWidth + upperHeight) * Math.pow(area, 0.5);
|
|
468
480
|
|
|
469
481
|
area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
|
|
470
482
|
|
|
@@ -551,5 +563,9 @@ define(function (require) {
|
|
|
551
563
|
});
|
|
552
564
|
}
|
|
553
565
|
|
|
566
|
+
function getUpperLabelHeight(model) {
|
|
567
|
+
return model.get(PATH_UPPER_LABEL_SHOW) ? model.get(PATH_UPPER_LABEL_HEIGHT) : 0;
|
|
568
|
+
}
|
|
569
|
+
|
|
554
570
|
return update;
|
|
555
571
|
});
|
|
@@ -105,8 +105,6 @@ define(function (require) {
|
|
|
105
105
|
var categoryData = angleAxisModel.get('data');
|
|
106
106
|
|
|
107
107
|
var labelModel = angleAxisModel.getModel('axisLabel');
|
|
108
|
-
var axisTextStyleModel = labelModel.getModel('textStyle');
|
|
109
|
-
|
|
110
108
|
var labels = angleAxisModel.getFormattedLabels();
|
|
111
109
|
|
|
112
110
|
var labelMargin = labelModel.get('margin');
|
|
@@ -121,27 +119,23 @@ define(function (require) {
|
|
|
121
119
|
|
|
122
120
|
var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
|
|
123
121
|
? 'center' : (p[0] > cx ? 'left' : 'right');
|
|
124
|
-
var
|
|
122
|
+
var labelTextVerticalAlign = Math.abs(p[1] - cy) / r < 0.3
|
|
125
123
|
? 'middle' : (p[1] > cy ? 'top' : 'bottom');
|
|
126
124
|
|
|
127
|
-
var textStyleModel = axisTextStyleModel;
|
|
128
125
|
if (categoryData && categoryData[i] && categoryData[i].textStyle) {
|
|
129
|
-
|
|
130
|
-
categoryData[i].textStyle, axisTextStyleModel
|
|
131
|
-
);
|
|
126
|
+
labelModel = new Model(categoryData[i].textStyle, labelModel, labelModel.ecModel);
|
|
132
127
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}));
|
|
128
|
+
|
|
129
|
+
var textEl = new graphic.Text({silent: true});
|
|
130
|
+
this.group.add(textEl);
|
|
131
|
+
graphic.setTextStyle(textEl.style, labelModel, {
|
|
132
|
+
x: p[0],
|
|
133
|
+
y: p[1],
|
|
134
|
+
textFill: labelModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
|
|
135
|
+
text: labels[i],
|
|
136
|
+
textAlign: labelTextAlign,
|
|
137
|
+
textVerticalAlign: labelTextVerticalAlign
|
|
138
|
+
});
|
|
145
139
|
}
|
|
146
140
|
},
|
|
147
141
|
|
|
@@ -49,7 +49,7 @@ define(function (require) {
|
|
|
49
49
|
* @param {Object} opt Standard axis parameters.
|
|
50
50
|
* @param {Array.<number>} opt.position [x, y]
|
|
51
51
|
* @param {number} opt.rotation by radian
|
|
52
|
-
* @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
|
|
52
|
+
* @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'.
|
|
53
53
|
* @param {number} [opt.tickDirection=1] 1 or -1
|
|
54
54
|
* @param {number} [opt.labelDirection=1] 1 or -1
|
|
55
55
|
* @param {number} [opt.labelOffset=0] Usefull when onZero.
|
|
@@ -171,172 +171,14 @@ define(function (require) {
|
|
|
171
171
|
/**
|
|
172
172
|
* @private
|
|
173
173
|
*/
|
|
174
|
-
|
|
174
|
+
axisTickLabel: function () {
|
|
175
175
|
var axisModel = this.axisModel;
|
|
176
|
-
var axis = axisModel.axis;
|
|
177
|
-
|
|
178
|
-
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
var tickModel = axisModel.getModel('axisTick');
|
|
183
|
-
var opt = this.opt;
|
|
184
|
-
|
|
185
|
-
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
186
|
-
var tickLen = tickModel.get('length');
|
|
187
|
-
|
|
188
|
-
var tickInterval = getInterval(tickModel, opt.labelInterval);
|
|
189
|
-
var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
|
|
190
|
-
var ticks = axis.scale.getTicks();
|
|
191
|
-
|
|
192
|
-
var pt1 = [];
|
|
193
|
-
var pt2 = [];
|
|
194
|
-
var matrix = this._transform;
|
|
195
|
-
|
|
196
|
-
for (var i = 0; i < ticksCoords.length; i++) {
|
|
197
|
-
// Only ordinal scale support tick interval
|
|
198
|
-
if (ifIgnoreOnTick(axis, i, tickInterval)) {
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
var tickCoord = ticksCoords[i];
|
|
203
|
-
|
|
204
|
-
pt1[0] = tickCoord;
|
|
205
|
-
pt1[1] = 0;
|
|
206
|
-
pt2[0] = tickCoord;
|
|
207
|
-
pt2[1] = opt.tickDirection * tickLen;
|
|
208
|
-
|
|
209
|
-
if (matrix) {
|
|
210
|
-
v2ApplyTransform(pt1, pt1, matrix);
|
|
211
|
-
v2ApplyTransform(pt2, pt2, matrix);
|
|
212
|
-
}
|
|
213
|
-
// Tick line, Not use group transform to have better line draw
|
|
214
|
-
this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
|
|
215
|
-
|
|
216
|
-
// Id for animation
|
|
217
|
-
anid: 'tick_' + ticks[i],
|
|
218
|
-
|
|
219
|
-
shape: {
|
|
220
|
-
x1: pt1[0],
|
|
221
|
-
y1: pt1[1],
|
|
222
|
-
x2: pt2[0],
|
|
223
|
-
y2: pt2[1]
|
|
224
|
-
},
|
|
225
|
-
style: zrUtil.defaults(
|
|
226
|
-
lineStyleModel.getLineStyle(),
|
|
227
|
-
{
|
|
228
|
-
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
229
|
-
}
|
|
230
|
-
),
|
|
231
|
-
z2: 2,
|
|
232
|
-
silent: true
|
|
233
|
-
})));
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
|
|
239
|
-
* @param {module:echarts/coord/cartesian/GridModel} gridModel
|
|
240
|
-
* @private
|
|
241
|
-
*/
|
|
242
|
-
axisLabel: function () {
|
|
243
176
|
var opt = this.opt;
|
|
244
|
-
var axisModel = this.axisModel;
|
|
245
|
-
var axis = axisModel.axis;
|
|
246
|
-
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
|
|
247
|
-
|
|
248
|
-
if (!show || axis.scale.isBlank()) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
var labelModel = axisModel.getModel('axisLabel');
|
|
253
|
-
var textStyleModel = labelModel.getModel('textStyle');
|
|
254
|
-
var labelMargin = labelModel.get('margin');
|
|
255
|
-
var ticks = axis.scale.getTicks();
|
|
256
|
-
var labels = axisModel.getFormattedLabels();
|
|
257
|
-
|
|
258
|
-
// Special label rotate.
|
|
259
|
-
var labelRotation = (
|
|
260
|
-
retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
|
|
261
|
-
) * PI / 180;
|
|
262
|
-
|
|
263
|
-
var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
|
|
264
|
-
var categoryData = axisModel.get('data');
|
|
265
|
-
|
|
266
|
-
var textEls = [];
|
|
267
|
-
var silent = isSilent(axisModel);
|
|
268
|
-
var triggerEvent = axisModel.get('triggerEvent');
|
|
269
|
-
|
|
270
|
-
zrUtil.each(ticks, function (tickVal, index) {
|
|
271
|
-
if (ifIgnoreOnTick(axis, index, opt.labelInterval)) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
var itemTextStyleModel = textStyleModel;
|
|
276
|
-
if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
|
|
277
|
-
itemTextStyleModel = new Model(
|
|
278
|
-
categoryData[tickVal].textStyle, textStyleModel, axisModel.ecModel
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
var textColor = itemTextStyleModel.getTextColor()
|
|
282
|
-
|| axisModel.get('axisLine.lineStyle.color');
|
|
283
|
-
|
|
284
|
-
var tickCoord = axis.dataToCoord(tickVal);
|
|
285
|
-
var pos = [
|
|
286
|
-
tickCoord,
|
|
287
|
-
opt.labelOffset + opt.labelDirection * labelMargin
|
|
288
|
-
];
|
|
289
|
-
var labelStr = axis.scale.getLabel(tickVal);
|
|
290
|
-
|
|
291
|
-
var textEl = new graphic.Text({
|
|
292
|
-
|
|
293
|
-
// Id for animation
|
|
294
|
-
anid: 'label_' + tickVal,
|
|
295
|
-
|
|
296
|
-
style: {
|
|
297
|
-
text: labels[index],
|
|
298
|
-
textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
|
|
299
|
-
textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.textVerticalAlign,
|
|
300
|
-
textFont: itemTextStyleModel.getFont(),
|
|
301
|
-
fill: typeof textColor === 'function'
|
|
302
|
-
? textColor(
|
|
303
|
-
// (1) In category axis with data zoom, tick is not the original
|
|
304
|
-
// index of axis.data. So tick should not be exposed to user
|
|
305
|
-
// in category axis.
|
|
306
|
-
// (2) Compatible with previous version, which always returns labelStr.
|
|
307
|
-
// But in interval scale labelStr is like '223,445', which maked
|
|
308
|
-
// user repalce ','. So we modify it to return original val but remain
|
|
309
|
-
// it as 'string' to avoid error in replacing.
|
|
310
|
-
axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
|
|
311
|
-
index
|
|
312
|
-
)
|
|
313
|
-
: textColor
|
|
314
|
-
},
|
|
315
|
-
position: pos,
|
|
316
|
-
rotation: labelLayout.rotation,
|
|
317
|
-
silent: silent,
|
|
318
|
-
z2: 10
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// Pack data for mouse event
|
|
322
|
-
if (triggerEvent) {
|
|
323
|
-
textEl.eventData = makeAxisEventDataBase(axisModel);
|
|
324
|
-
textEl.eventData.targetType = 'axisLabel';
|
|
325
|
-
textEl.eventData.value = labelStr;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// FIXME
|
|
329
|
-
this._dumbGroup.add(textEl);
|
|
330
|
-
textEl.updateTransform();
|
|
331
|
-
|
|
332
|
-
textEls.push(textEl);
|
|
333
|
-
this.group.add(textEl);
|
|
334
177
|
|
|
335
|
-
|
|
178
|
+
var tickEls = buildAxisTick(this, axisModel, opt);
|
|
179
|
+
var labelEls = buildAxisLabel(this, axisModel, opt);
|
|
336
180
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
fixMinMaxLabelShow(axisModel, textEls);
|
|
181
|
+
fixMinMaxLabelShow(axisModel, labelEls, tickEls);
|
|
340
182
|
},
|
|
341
183
|
|
|
342
184
|
/**
|
|
@@ -365,7 +207,7 @@ define(function (require) {
|
|
|
365
207
|
? extent[1] + gapSignal * gap
|
|
366
208
|
: (extent[0] + extent[1]) / 2, // 'middle'
|
|
367
209
|
// Reuse labelOffset.
|
|
368
|
-
nameLocation
|
|
210
|
+
isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0
|
|
369
211
|
];
|
|
370
212
|
|
|
371
213
|
var labelLayout;
|
|
@@ -377,7 +219,7 @@ define(function (require) {
|
|
|
377
219
|
|
|
378
220
|
var axisNameAvailableWidth;
|
|
379
221
|
|
|
380
|
-
if (nameLocation
|
|
222
|
+
if (isNameLocationCenter(nameLocation)) {
|
|
381
223
|
labelLayout = innerTextLayout(
|
|
382
224
|
opt.rotation,
|
|
383
225
|
nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
|
|
@@ -405,6 +247,8 @@ define(function (require) {
|
|
|
405
247
|
var maxWidth = retrieve(
|
|
406
248
|
opt.nameTruncateMaxWidth, truncateOpt.maxWidth, axisNameAvailableWidth
|
|
407
249
|
);
|
|
250
|
+
// FIXME
|
|
251
|
+
// truncate rich text? (consider performance)
|
|
408
252
|
var truncatedText = (ellipsis != null && maxWidth != null)
|
|
409
253
|
? formatUtil.truncateText(
|
|
410
254
|
name, maxWidth, textFont, ellipsis,
|
|
@@ -423,21 +267,12 @@ define(function (require) {
|
|
|
423
267
|
formatterParams[mainType + 'Index'] = axisModel.componentIndex;
|
|
424
268
|
|
|
425
269
|
var textEl = new graphic.Text({
|
|
426
|
-
|
|
427
270
|
// Id for animation
|
|
428
271
|
anid: 'name',
|
|
429
272
|
|
|
430
273
|
__fullText: name,
|
|
431
274
|
__truncatedText: truncatedText,
|
|
432
275
|
|
|
433
|
-
style: {
|
|
434
|
-
text: truncatedText,
|
|
435
|
-
textFont: textFont,
|
|
436
|
-
fill: textStyleModel.getTextColor()
|
|
437
|
-
|| axisModel.get('axisLine.lineStyle.color'),
|
|
438
|
-
textAlign: labelLayout.textAlign,
|
|
439
|
-
textVerticalAlign: labelLayout.textVerticalAlign
|
|
440
|
-
},
|
|
441
276
|
position: pos,
|
|
442
277
|
rotation: labelLayout.rotation,
|
|
443
278
|
silent: isSilent(axisModel),
|
|
@@ -453,6 +288,15 @@ define(function (require) {
|
|
|
453
288
|
: null
|
|
454
289
|
});
|
|
455
290
|
|
|
291
|
+
graphic.setTextStyle(textEl.style, textStyleModel, {
|
|
292
|
+
text: truncatedText,
|
|
293
|
+
textFont: textFont,
|
|
294
|
+
textFill: textStyleModel.getTextColor()
|
|
295
|
+
|| axisModel.get('axisLine.lineStyle.color'),
|
|
296
|
+
textAlign: labelLayout.textAlign,
|
|
297
|
+
textVerticalAlign: labelLayout.textVerticalAlign
|
|
298
|
+
});
|
|
299
|
+
|
|
456
300
|
if (axisModel.get('triggerEvent')) {
|
|
457
301
|
textEl.eventData = makeAxisEventDataBase(axisModel);
|
|
458
302
|
textEl.eventData.targetType = 'axisName';
|
|
@@ -556,32 +400,64 @@ define(function (require) {
|
|
|
556
400
|
);
|
|
557
401
|
}
|
|
558
402
|
|
|
559
|
-
function fixMinMaxLabelShow(axisModel,
|
|
403
|
+
function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
|
|
560
404
|
// If min or max are user set, we need to check
|
|
561
405
|
// If the tick on min(max) are overlap on their neighbour tick
|
|
562
406
|
// If they are overlapped, we need to hide the min(max) tick label
|
|
563
407
|
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
564
408
|
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
409
|
+
|
|
410
|
+
// FIXME
|
|
411
|
+
// Have not consider onBand yet, where tick els is more than label els.
|
|
412
|
+
|
|
413
|
+
labelEls = labelEls || [];
|
|
414
|
+
tickEls = tickEls || [];
|
|
415
|
+
|
|
416
|
+
var firstLabel = labelEls[0];
|
|
417
|
+
var nextLabel = labelEls[1];
|
|
418
|
+
var lastLabel = labelEls[labelEls.length - 1];
|
|
419
|
+
var prevLabel = labelEls[labelEls.length - 2];
|
|
420
|
+
|
|
421
|
+
var firstTick = tickEls[0];
|
|
422
|
+
var nextTick = tickEls[1];
|
|
423
|
+
var lastTick = tickEls[tickEls.length - 1];
|
|
424
|
+
var prevTick = tickEls[tickEls.length - 2];
|
|
569
425
|
|
|
570
426
|
if (showMinLabel === false) {
|
|
571
|
-
firstLabel
|
|
427
|
+
ignoreEl(firstLabel);
|
|
428
|
+
ignoreEl(firstTick);
|
|
572
429
|
}
|
|
573
|
-
else if (
|
|
574
|
-
|
|
430
|
+
else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
|
|
431
|
+
if (showMinLabel) {
|
|
432
|
+
ignoreEl(nextLabel);
|
|
433
|
+
ignoreEl(nextTick);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
ignoreEl(firstLabel);
|
|
437
|
+
ignoreEl(firstTick);
|
|
438
|
+
}
|
|
575
439
|
}
|
|
576
440
|
|
|
577
441
|
if (showMaxLabel === false) {
|
|
578
|
-
lastLabel
|
|
442
|
+
ignoreEl(lastLabel);
|
|
443
|
+
ignoreEl(lastTick);
|
|
579
444
|
}
|
|
580
|
-
else if (
|
|
581
|
-
|
|
445
|
+
else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
|
|
446
|
+
if (showMaxLabel) {
|
|
447
|
+
ignoreEl(prevLabel);
|
|
448
|
+
ignoreEl(prevTick);
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
ignoreEl(lastLabel);
|
|
452
|
+
ignoreEl(lastTick);
|
|
453
|
+
}
|
|
582
454
|
}
|
|
583
455
|
}
|
|
584
456
|
|
|
457
|
+
function ignoreEl(el) {
|
|
458
|
+
el && (el.ignore = true);
|
|
459
|
+
}
|
|
460
|
+
|
|
585
461
|
function isTwoLabelOverlapped(current, next, labelLayout) {
|
|
586
462
|
// current and next has the same rotation.
|
|
587
463
|
var firstRect = current && current.getBoundingRect().clone();
|
|
@@ -602,11 +478,28 @@ define(function (require) {
|
|
|
602
478
|
return firstRect.intersect(nextRect);
|
|
603
479
|
}
|
|
604
480
|
|
|
481
|
+
function isNameLocationCenter(nameLocation) {
|
|
482
|
+
return nameLocation === 'middle' || nameLocation === 'center';
|
|
483
|
+
}
|
|
605
484
|
|
|
606
485
|
/**
|
|
607
486
|
* @static
|
|
608
487
|
*/
|
|
609
|
-
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
|
|
488
|
+
var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
|
|
489
|
+
axis,
|
|
490
|
+
i,
|
|
491
|
+
interval,
|
|
492
|
+
ticksCnt,
|
|
493
|
+
showMinLabel,
|
|
494
|
+
showMaxLabel
|
|
495
|
+
) {
|
|
496
|
+
if (i === 0 && showMinLabel || i === ticksCnt - 1 && showMaxLabel) {
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// FIXME
|
|
501
|
+
// Have not consider label overlap (if label is too long) yet.
|
|
502
|
+
|
|
610
503
|
var rawTick;
|
|
611
504
|
var scale = axis.scale;
|
|
612
505
|
return scale.type === 'ordinal'
|
|
@@ -631,6 +524,187 @@ define(function (require) {
|
|
|
631
524
|
return interval;
|
|
632
525
|
};
|
|
633
526
|
|
|
527
|
+
function buildAxisTick(axisBuilder, axisModel, opt) {
|
|
528
|
+
var axis = axisModel.axis;
|
|
529
|
+
|
|
530
|
+
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
var tickModel = axisModel.getModel('axisTick');
|
|
535
|
+
|
|
536
|
+
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
537
|
+
var tickLen = tickModel.get('length');
|
|
538
|
+
|
|
539
|
+
var tickInterval = getInterval(tickModel, opt.labelInterval);
|
|
540
|
+
var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
|
|
541
|
+
// FIXME
|
|
542
|
+
// Corresponds to ticksCoords ?
|
|
543
|
+
var ticks = axis.scale.getTicks();
|
|
544
|
+
|
|
545
|
+
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
546
|
+
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
547
|
+
|
|
548
|
+
var pt1 = [];
|
|
549
|
+
var pt2 = [];
|
|
550
|
+
var matrix = axisBuilder._transform;
|
|
551
|
+
|
|
552
|
+
var tickEls = [];
|
|
553
|
+
|
|
554
|
+
var ticksCnt = ticksCoords.length;
|
|
555
|
+
for (var i = 0; i < ticksCnt; i++) {
|
|
556
|
+
// Only ordinal scale support tick interval
|
|
557
|
+
if (ifIgnoreOnTick(
|
|
558
|
+
axis, i, tickInterval, ticksCnt,
|
|
559
|
+
showMinLabel, showMaxLabel
|
|
560
|
+
)) {
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
var tickCoord = ticksCoords[i];
|
|
565
|
+
|
|
566
|
+
pt1[0] = tickCoord;
|
|
567
|
+
pt1[1] = 0;
|
|
568
|
+
pt2[0] = tickCoord;
|
|
569
|
+
pt2[1] = opt.tickDirection * tickLen;
|
|
570
|
+
|
|
571
|
+
if (matrix) {
|
|
572
|
+
v2ApplyTransform(pt1, pt1, matrix);
|
|
573
|
+
v2ApplyTransform(pt2, pt2, matrix);
|
|
574
|
+
}
|
|
575
|
+
// Tick line, Not use group transform to have better line draw
|
|
576
|
+
var tickEl = new graphic.Line(graphic.subPixelOptimizeLine({
|
|
577
|
+
// Id for animation
|
|
578
|
+
anid: 'tick_' + ticks[i],
|
|
579
|
+
|
|
580
|
+
shape: {
|
|
581
|
+
x1: pt1[0],
|
|
582
|
+
y1: pt1[1],
|
|
583
|
+
x2: pt2[0],
|
|
584
|
+
y2: pt2[1]
|
|
585
|
+
},
|
|
586
|
+
style: zrUtil.defaults(
|
|
587
|
+
lineStyleModel.getLineStyle(),
|
|
588
|
+
{
|
|
589
|
+
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
590
|
+
}
|
|
591
|
+
),
|
|
592
|
+
z2: 2,
|
|
593
|
+
silent: true
|
|
594
|
+
}));
|
|
595
|
+
axisBuilder.group.add(tickEl);
|
|
596
|
+
tickEls.push(tickEl);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return tickEls;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function buildAxisLabel(axisBuilder, axisModel, opt) {
|
|
603
|
+
var axis = axisModel.axis;
|
|
604
|
+
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
|
|
605
|
+
|
|
606
|
+
if (!show || axis.scale.isBlank()) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
var labelModel = axisModel.getModel('axisLabel');
|
|
611
|
+
var labelMargin = labelModel.get('margin');
|
|
612
|
+
var ticks = axis.scale.getTicks();
|
|
613
|
+
var labels = axisModel.getFormattedLabels();
|
|
614
|
+
|
|
615
|
+
// Special label rotate.
|
|
616
|
+
var labelRotation = (
|
|
617
|
+
retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
|
|
618
|
+
) * PI / 180;
|
|
619
|
+
|
|
620
|
+
var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
|
|
621
|
+
var categoryData = axisModel.get('data');
|
|
622
|
+
|
|
623
|
+
var labelEls = [];
|
|
624
|
+
var silent = isSilent(axisModel);
|
|
625
|
+
var triggerEvent = axisModel.get('triggerEvent');
|
|
626
|
+
|
|
627
|
+
var showMinLabel = axisModel.get('axisLabel.showMinLabel');
|
|
628
|
+
var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
|
|
629
|
+
|
|
630
|
+
zrUtil.each(ticks, function (tickVal, index) {
|
|
631
|
+
if (ifIgnoreOnTick(
|
|
632
|
+
axis, index, opt.labelInterval, ticks.length,
|
|
633
|
+
showMinLabel, showMaxLabel
|
|
634
|
+
)) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
var itemLabelModel = labelModel;
|
|
639
|
+
if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
|
|
640
|
+
itemLabelModel = new Model(
|
|
641
|
+
categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
var textColor = itemLabelModel.getTextColor()
|
|
646
|
+
|| axisModel.get('axisLine.lineStyle.color');
|
|
647
|
+
|
|
648
|
+
var tickCoord = axis.dataToCoord(tickVal);
|
|
649
|
+
var pos = [
|
|
650
|
+
tickCoord,
|
|
651
|
+
opt.labelOffset + opt.labelDirection * labelMargin
|
|
652
|
+
];
|
|
653
|
+
var labelStr = axis.scale.getLabel(tickVal);
|
|
654
|
+
|
|
655
|
+
var textEl = new graphic.Text({
|
|
656
|
+
// Id for animation
|
|
657
|
+
anid: 'label_' + tickVal,
|
|
658
|
+
position: pos,
|
|
659
|
+
rotation: labelLayout.rotation,
|
|
660
|
+
silent: silent,
|
|
661
|
+
z2: 10
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
graphic.setTextStyle(textEl.style, itemLabelModel, {
|
|
665
|
+
text: labels[index],
|
|
666
|
+
textAlign: itemLabelModel.getShallow('align', true)
|
|
667
|
+
|| labelLayout.textAlign,
|
|
668
|
+
textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
|
|
669
|
+
|| itemLabelModel.getShallow('baseline', true)
|
|
670
|
+
|| labelLayout.textVerticalAlign,
|
|
671
|
+
textFill: typeof textColor === 'function'
|
|
672
|
+
? textColor(
|
|
673
|
+
// (1) In category axis with data zoom, tick is not the original
|
|
674
|
+
// index of axis.data. So tick should not be exposed to user
|
|
675
|
+
// in category axis.
|
|
676
|
+
// (2) Compatible with previous version, which always returns labelStr.
|
|
677
|
+
// But in interval scale labelStr is like '223,445', which maked
|
|
678
|
+
// user repalce ','. So we modify it to return original val but remain
|
|
679
|
+
// it as 'string' to avoid error in replacing.
|
|
680
|
+
axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
|
|
681
|
+
index
|
|
682
|
+
)
|
|
683
|
+
: textColor
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
// Pack data for mouse event
|
|
687
|
+
if (triggerEvent) {
|
|
688
|
+
textEl.eventData = makeAxisEventDataBase(axisModel);
|
|
689
|
+
textEl.eventData.targetType = 'axisLabel';
|
|
690
|
+
textEl.eventData.value = labelStr;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// FIXME
|
|
694
|
+
axisBuilder._dumbGroup.add(textEl);
|
|
695
|
+
textEl.updateTransform();
|
|
696
|
+
|
|
697
|
+
labelEls.push(textEl);
|
|
698
|
+
axisBuilder.group.add(textEl);
|
|
699
|
+
|
|
700
|
+
textEl.decomposeTransform();
|
|
701
|
+
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
return labelEls;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
|
|
634
708
|
return AxisBuilder;
|
|
635
709
|
|
|
636
710
|
});
|