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
package/lib/util/graphic.js
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
var mathMax = Math.max;
|
|
16
16
|
var mathMin = Math.min;
|
|
17
17
|
|
|
18
|
+
var EMPTY_OBJ = {};
|
|
19
|
+
|
|
18
20
|
var graphic = {};
|
|
19
21
|
|
|
20
22
|
graphic.Group = require('zrender/lib/container/Group');
|
|
@@ -134,7 +136,6 @@
|
|
|
134
136
|
* @return {Object} Modified param
|
|
135
137
|
*/
|
|
136
138
|
graphic.subPixelOptimizeLine = function (param) {
|
|
137
|
-
var subPixelOptimize = graphic.subPixelOptimize;
|
|
138
139
|
var shape = param.shape;
|
|
139
140
|
var lineWidth = param.style.lineWidth;
|
|
140
141
|
|
|
@@ -161,7 +162,6 @@
|
|
|
161
162
|
* @return {Object} Modified param
|
|
162
163
|
*/
|
|
163
164
|
graphic.subPixelOptimizeRect = function (param) {
|
|
164
|
-
var subPixelOptimize = graphic.subPixelOptimize;
|
|
165
165
|
var shape = param.shape;
|
|
166
166
|
var lineWidth = param.style.lineWidth;
|
|
167
167
|
var originX = shape.x;
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
* @param {boolean=} positiveOrNegative Default false (negative).
|
|
190
190
|
* @return {number} Optimized position.
|
|
191
191
|
*/
|
|
192
|
-
graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
|
|
192
|
+
var subPixelOptimize = graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
|
|
193
193
|
// Assure that (position + lineWidth / 2) is near integer edge,
|
|
194
194
|
// otherwise line will be fuzzy in canvas.
|
|
195
195
|
var doubledPosition = round(position * 2);
|
|
@@ -223,7 +223,8 @@
|
|
|
223
223
|
|
|
224
224
|
var normalStyle = {};
|
|
225
225
|
for (var name in hoverStyle) {
|
|
226
|
-
|
|
226
|
+
// See comment in `doSingleEnterHover`.
|
|
227
|
+
if (hoverStyle[name] != null) {
|
|
227
228
|
normalStyle[name] = el.style[name];
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -248,7 +249,46 @@
|
|
|
248
249
|
el.__zr && el.__zr.addHover(el, el.__hoverStl);
|
|
249
250
|
}
|
|
250
251
|
else {
|
|
251
|
-
el.
|
|
252
|
+
var style = el.style;
|
|
253
|
+
var insideRollbackOpt = style.insideRollbackOpt;
|
|
254
|
+
|
|
255
|
+
// Consider case: only `position: 'top'` is set on emphasis, then text
|
|
256
|
+
// color should be returned to `autoColor`, rather than remain '#fff'.
|
|
257
|
+
// So we should rollback then apply again after style merging.
|
|
258
|
+
insideRollbackOpt && rollbackInsideStyle(style);
|
|
259
|
+
|
|
260
|
+
// styles can be:
|
|
261
|
+
// {
|
|
262
|
+
// label: {
|
|
263
|
+
// normal: {
|
|
264
|
+
// show: false,
|
|
265
|
+
// position: 'outside',
|
|
266
|
+
// fontSize: 18
|
|
267
|
+
// },
|
|
268
|
+
// emphasis: {
|
|
269
|
+
// show: true
|
|
270
|
+
// }
|
|
271
|
+
// }
|
|
272
|
+
// },
|
|
273
|
+
// where properties of `emphasis` may not appear in `normal`. We previously use
|
|
274
|
+
// module:echarts/util/model#defaultEmphasis to merge `normal` to `emphasis`.
|
|
275
|
+
// But consider rich text and setOption in merge mode, it is impossible to cover
|
|
276
|
+
// all properties in merge. So we use merge mode when setting style here, where
|
|
277
|
+
// only properties that is not `null/undefined` can be set. The disadventage:
|
|
278
|
+
// null/undefined can not be used to remove style any more in `emphasis`.
|
|
279
|
+
style.extendFrom(el.__hoverStl);
|
|
280
|
+
|
|
281
|
+
// Do not save `insideRollback`.
|
|
282
|
+
if (insideRollbackOpt) {
|
|
283
|
+
applyInsideStyle(style, style.insideOriginalTextPosition, insideRollbackOpt);
|
|
284
|
+
|
|
285
|
+
// textFill may be rollbacked to null.
|
|
286
|
+
if (style.textFill == null) {
|
|
287
|
+
style.textFill = insideRollbackOpt.autoColor;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
el.dirty(false);
|
|
252
292
|
el.z2 += 1;
|
|
253
293
|
}
|
|
254
294
|
|
|
@@ -268,6 +308,8 @@
|
|
|
268
308
|
el.__zr && el.__zr.removeHover(el);
|
|
269
309
|
}
|
|
270
310
|
else {
|
|
311
|
+
// Consider null/undefined value, should use
|
|
312
|
+
// `setStyle` but not `extendFrom(stl, true)`.
|
|
271
313
|
normalStl && el.setStyle(normalStl);
|
|
272
314
|
el.z2 -= 1;
|
|
273
315
|
}
|
|
@@ -390,27 +432,346 @@
|
|
|
390
432
|
};
|
|
391
433
|
|
|
392
434
|
/**
|
|
393
|
-
*
|
|
435
|
+
* @param {Object|module:zrender/graphic/Style} normalStyle
|
|
436
|
+
* @param {Object} emphasisStyle
|
|
437
|
+
* @param {module:echarts/model/Model} normalModel
|
|
438
|
+
* @param {module:echarts/model/Model} emphasisModel
|
|
439
|
+
* @param {Object} opt Check `opt` of `setTextStyleCommon` to find other props.
|
|
440
|
+
* @param {Object} [opt.defaultText]
|
|
441
|
+
* @param {module:echarts/model/Model} [opt.labelFetcher] Fetch text by
|
|
442
|
+
* `opt.labelFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
|
|
443
|
+
* @param {module:echarts/model/Model} [opt.labelDataIndex] Fetch text by
|
|
444
|
+
* `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
|
|
445
|
+
* @param {module:echarts/model/Model} [opt.labelDimIndex] Fetch text by
|
|
446
|
+
* `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
|
|
447
|
+
* @param {Object} [normalSpecified]
|
|
448
|
+
* @param {Object} [emphasisSpecified]
|
|
449
|
+
*/
|
|
450
|
+
graphic.setLabelStyle = function (
|
|
451
|
+
normalStyle, emphasisStyle,
|
|
452
|
+
normalModel, emphasisModel,
|
|
453
|
+
opt,
|
|
454
|
+
normalSpecified, emphasisSpecified
|
|
455
|
+
) {
|
|
456
|
+
opt = opt || EMPTY_OBJ;
|
|
457
|
+
var labelFetcher = opt.labelFetcher;
|
|
458
|
+
var labelDataIndex = opt.labelDataIndex;
|
|
459
|
+
var labelDimIndex = opt.labelDimIndex;
|
|
460
|
+
|
|
461
|
+
// This scenario, `label.normal.show = true; label.emphasis.show = false`,
|
|
462
|
+
// is not supported util someone requests.
|
|
463
|
+
|
|
464
|
+
var showNormal = normalModel.getShallow('show');
|
|
465
|
+
var showEmphasis = emphasisModel.getShallow('show');
|
|
466
|
+
|
|
467
|
+
// Consider performance, only fetch label when necessary.
|
|
468
|
+
// If `normal.show` is `false` and `emphasis.show` is `true` and `emphasis.formatter` is not set,
|
|
469
|
+
// label should be displayed, where text is fetched by `normal.formatter` or `opt.defaultText`.
|
|
470
|
+
var baseText = (showNormal || showEmphasis)
|
|
471
|
+
? zrUtil.retrieve2(
|
|
472
|
+
labelFetcher
|
|
473
|
+
? labelFetcher.getFormattedLabel(labelDataIndex, 'normal', null, labelDimIndex)
|
|
474
|
+
: null,
|
|
475
|
+
opt.defaultText
|
|
476
|
+
)
|
|
477
|
+
: null;
|
|
478
|
+
var normalStyleText = showNormal ? baseText : null;
|
|
479
|
+
var emphasisStyleText = showEmphasis
|
|
480
|
+
? zrUtil.retrieve2(
|
|
481
|
+
labelFetcher
|
|
482
|
+
? labelFetcher.getFormattedLabel(labelDataIndex, 'emphasis', null, labelDimIndex)
|
|
483
|
+
: null,
|
|
484
|
+
baseText
|
|
485
|
+
)
|
|
486
|
+
: null;
|
|
487
|
+
|
|
488
|
+
// Optimize: If style.text is null, text will not be drawn.
|
|
489
|
+
if (normalStyleText != null || emphasisStyleText != null) {
|
|
490
|
+
// Always set `textStyle` even if `normalStyle.text` is null, because default
|
|
491
|
+
// values have to be set on `normalStyle`.
|
|
492
|
+
// If we set default values on `emphasisStyle`, consider case:
|
|
493
|
+
// Firstly, `setOption(... label: {normal: {text: null}, emphasis: {show: true}} ...);`
|
|
494
|
+
// Secondly, `setOption(... label: {noraml: {show: true, text: 'abc', color: 'red'} ...);`
|
|
495
|
+
// Then the 'red' will not work on emphasis.
|
|
496
|
+
setTextStyle(normalStyle, normalModel, normalSpecified, opt);
|
|
497
|
+
setTextStyle(emphasisStyle, emphasisModel, emphasisSpecified, opt, true);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
normalStyle.text = normalStyleText;
|
|
501
|
+
emphasisStyle.text = emphasisStyleText;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Set basic textStyle properties.
|
|
506
|
+
* @param {Object|module:zrender/graphic/Style} textStyle
|
|
507
|
+
* @param {module:echarts/model/Model} model
|
|
508
|
+
* @param {Object} [specifiedTextStyle] Can be overrided by settings in model.
|
|
509
|
+
* @param {Object} [opt] See `opt` of `setTextStyleCommon`.
|
|
510
|
+
* @param {boolean} [isEmphasis]
|
|
511
|
+
*/
|
|
512
|
+
var setTextStyle = graphic.setTextStyle = function (
|
|
513
|
+
textStyle, textStyleModel, specifiedTextStyle, opt, isEmphasis
|
|
514
|
+
) {
|
|
515
|
+
setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis);
|
|
516
|
+
specifiedTextStyle && zrUtil.extend(textStyle, specifiedTextStyle);
|
|
517
|
+
textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
|
|
518
|
+
|
|
519
|
+
return textStyle;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Set text option in the style.
|
|
524
|
+
* @deprecated
|
|
394
525
|
* @param {Object} textStyle
|
|
395
526
|
* @param {module:echarts/model/Model} labelModel
|
|
396
|
-
* @param {string} color
|
|
527
|
+
* @param {string|boolean} defaultColor Default text color.
|
|
528
|
+
* If set as false, it will be processed as a emphasis style.
|
|
397
529
|
*/
|
|
398
|
-
graphic.setText = function (textStyle, labelModel,
|
|
399
|
-
var
|
|
400
|
-
var
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
530
|
+
graphic.setText = function (textStyle, labelModel, defaultColor) {
|
|
531
|
+
var opt = {isRectText: true};
|
|
532
|
+
var isEmphasis;
|
|
533
|
+
|
|
534
|
+
if (defaultColor === false) {
|
|
535
|
+
isEmphasis = true;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
// Support setting color as 'auto' to get visual color.
|
|
539
|
+
opt.autoColor = defaultColor;
|
|
540
|
+
}
|
|
541
|
+
setTextStyleCommon(textStyle, labelModel, opt, isEmphasis);
|
|
542
|
+
textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
|
|
410
543
|
};
|
|
411
544
|
|
|
545
|
+
/**
|
|
546
|
+
* {
|
|
547
|
+
* disableBox: boolean, Whether diable drawing box of block (outer most).
|
|
548
|
+
* isRectText: boolean,
|
|
549
|
+
* autoColor: string, specify a color when color is 'auto',
|
|
550
|
+
* for textFill, textStroke, textBackgroundColor, and textBorderColor.
|
|
551
|
+
* If autoColor specified, it is used as default textFill.
|
|
552
|
+
* useInsideStyle:
|
|
553
|
+
* `true`: Use inside style (textFill, textStroke, textStrokeWidth)
|
|
554
|
+
* if `textFill` is not specified.
|
|
555
|
+
* `false`: Do not use inside style.
|
|
556
|
+
* `null/undefined`: use inside style if `isRectText` is true and
|
|
557
|
+
* `textFill` is not specified and textPosition contains `'inside'`.
|
|
558
|
+
* forceRich: boolean
|
|
559
|
+
* }
|
|
560
|
+
*/
|
|
561
|
+
function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
|
|
562
|
+
// Consider there will be abnormal when merge hover style to normal style if given default value.
|
|
563
|
+
opt = opt || EMPTY_OBJ;
|
|
564
|
+
|
|
565
|
+
if (opt.isRectText) {
|
|
566
|
+
var textPosition = textStyleModel.getShallow('position')
|
|
567
|
+
|| (isEmphasis ? null : 'inside');
|
|
568
|
+
// 'outside' is not a valid zr textPostion value, but used
|
|
569
|
+
// in bar series, and magric type should be considered.
|
|
570
|
+
textPosition === 'outside' && (textPosition = 'top');
|
|
571
|
+
textStyle.textPosition = textPosition;
|
|
572
|
+
textStyle.textOffset = textStyleModel.getShallow('offset');
|
|
573
|
+
var labelRotate = textStyleModel.getShallow('rotate');
|
|
574
|
+
labelRotate != null && (labelRotate *= Math.PI / 180);
|
|
575
|
+
textStyle.textRotation = labelRotate;
|
|
576
|
+
textStyle.textDistance = zrUtil.retrieve2(
|
|
577
|
+
textStyleModel.getShallow('distance'), isEmphasis ? null : 5
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
var ecModel = textStyleModel.ecModel;
|
|
582
|
+
var globalTextStyle = ecModel && ecModel.option.textStyle;
|
|
583
|
+
|
|
584
|
+
// Consider case:
|
|
585
|
+
// {
|
|
586
|
+
// data: [{
|
|
587
|
+
// value: 12,
|
|
588
|
+
// label: {
|
|
589
|
+
// normal: {
|
|
590
|
+
// rich: {
|
|
591
|
+
// // no 'a' here but using parent 'a'.
|
|
592
|
+
// }
|
|
593
|
+
// }
|
|
594
|
+
// }
|
|
595
|
+
// }],
|
|
596
|
+
// rich: {
|
|
597
|
+
// a: { ... }
|
|
598
|
+
// }
|
|
599
|
+
// }
|
|
600
|
+
var richItemNames = getRichItemNames(textStyleModel);
|
|
601
|
+
var richResult;
|
|
602
|
+
if (richItemNames) {
|
|
603
|
+
richResult = {};
|
|
604
|
+
for (var name in richItemNames) {
|
|
605
|
+
if (richItemNames.hasOwnProperty(name)) {
|
|
606
|
+
// Cascade is supported in rich.
|
|
607
|
+
var richTextStyle = textStyleModel.getModel(['rich', name]);
|
|
608
|
+
// In rich, never `disableBox`.
|
|
609
|
+
setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
textStyle.rich = richResult;
|
|
614
|
+
|
|
615
|
+
setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
|
|
616
|
+
|
|
617
|
+
if (opt.forceRich && !opt.textStyle) {
|
|
618
|
+
opt.textStyle = {};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
return textStyle;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// Consider case:
|
|
625
|
+
// {
|
|
626
|
+
// data: [{
|
|
627
|
+
// value: 12,
|
|
628
|
+
// label: {
|
|
629
|
+
// normal: {
|
|
630
|
+
// rich: {
|
|
631
|
+
// // no 'a' here but using parent 'a'.
|
|
632
|
+
// }
|
|
633
|
+
// }
|
|
634
|
+
// }
|
|
635
|
+
// }],
|
|
636
|
+
// rich: {
|
|
637
|
+
// a: { ... }
|
|
638
|
+
// }
|
|
639
|
+
// }
|
|
640
|
+
function getRichItemNames(textStyleModel) {
|
|
641
|
+
// Use object to remove duplicated names.
|
|
642
|
+
var richItemNameMap;
|
|
643
|
+
while (textStyleModel && textStyleModel !== textStyleModel.ecModel) {
|
|
644
|
+
var rich = (textStyleModel.option || EMPTY_OBJ).rich;
|
|
645
|
+
if (rich) {
|
|
646
|
+
richItemNameMap = richItemNameMap || {};
|
|
647
|
+
for (var name in rich) {
|
|
648
|
+
if (rich.hasOwnProperty(name)) {
|
|
649
|
+
richItemNameMap[name] = 1;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
textStyleModel = textStyleModel.parentModel;
|
|
654
|
+
}
|
|
655
|
+
return richItemNameMap;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, isBlock) {
|
|
659
|
+
// In merge mode, default value should not be given.
|
|
660
|
+
globalTextStyle = !isEmphasis && globalTextStyle || EMPTY_OBJ;
|
|
661
|
+
|
|
662
|
+
textStyle.textFill = getAutoColor(textStyleModel.getShallow('color'), opt)
|
|
663
|
+
|| globalTextStyle.color;
|
|
664
|
+
textStyle.textStroke = getAutoColor(textStyleModel.getShallow('textBorderColor'), opt)
|
|
665
|
+
|| globalTextStyle.textBorderColor;
|
|
666
|
+
textStyle.textStrokeWidth = zrUtil.retrieve2(
|
|
667
|
+
textStyleModel.getShallow('textBorderWidth'),
|
|
668
|
+
globalTextStyle.textBorderWidth
|
|
669
|
+
);
|
|
670
|
+
|
|
671
|
+
if (!isEmphasis) {
|
|
672
|
+
if (isBlock) {
|
|
673
|
+
// Always set `insideRollback`, for clearing previous.
|
|
674
|
+
var originalTextPosition = textStyle.textPosition;
|
|
675
|
+
textStyle.insideRollback = applyInsideStyle(textStyle, originalTextPosition, opt);
|
|
676
|
+
// Save original textPosition, because style.textPosition will be repalced by
|
|
677
|
+
// real location (like [10, 30]) in zrender.
|
|
678
|
+
textStyle.insideOriginalTextPosition = originalTextPosition;
|
|
679
|
+
textStyle.insideRollbackOpt = opt;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// Set default finally.
|
|
683
|
+
if (textStyle.textFill == null) {
|
|
684
|
+
textStyle.textFill = opt.autoColor;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// Do not use `getFont` here, because merge should be supported, where
|
|
689
|
+
// part of these properties may be changed in emphasis style, and the
|
|
690
|
+
// others should remain their original value got from normal style.
|
|
691
|
+
textStyle.fontStyle = textStyleModel.getShallow('fontStyle') || globalTextStyle.fontStyle;
|
|
692
|
+
textStyle.fontWeight = textStyleModel.getShallow('fontWeight') || globalTextStyle.fontWeight;
|
|
693
|
+
textStyle.fontSize = textStyleModel.getShallow('fontSize') || globalTextStyle.fontSize;
|
|
694
|
+
textStyle.fontFamily = textStyleModel.getShallow('fontFamily') || globalTextStyle.fontFamily;
|
|
695
|
+
|
|
696
|
+
textStyle.textAlign = textStyleModel.getShallow('align');
|
|
697
|
+
textStyle.textVerticalAlign = textStyleModel.getShallow('verticalAlign')
|
|
698
|
+
|| textStyleModel.getShallow('baseline');
|
|
699
|
+
|
|
700
|
+
textStyle.textLineHeight = textStyleModel.getShallow('lineHeight');
|
|
701
|
+
textStyle.textWidth = textStyleModel.getShallow('width');
|
|
702
|
+
textStyle.textHeight = textStyleModel.getShallow('height');
|
|
703
|
+
textStyle.textTag = textStyleModel.getShallow('tag');
|
|
704
|
+
|
|
705
|
+
if (!isBlock || !opt.disableBox) {
|
|
706
|
+
textStyle.textBackgroundColor = getAutoColor(textStyleModel.getShallow('backgroundColor'), opt);
|
|
707
|
+
textStyle.textPadding = textStyleModel.getShallow('padding');
|
|
708
|
+
textStyle.textBorderColor = getAutoColor(textStyleModel.getShallow('borderColor'), opt);
|
|
709
|
+
textStyle.textBorderWidth = textStyleModel.getShallow('borderWidth');
|
|
710
|
+
textStyle.textBorderRadius = textStyleModel.getShallow('borderRadius');
|
|
711
|
+
|
|
712
|
+
textStyle.textBoxShadowColor = textStyleModel.getShallow('shadowColor');
|
|
713
|
+
textStyle.textBoxShadowBlur = textStyleModel.getShallow('shadowBlur');
|
|
714
|
+
textStyle.textBoxShadowOffsetX = textStyleModel.getShallow('shadowOffsetX');
|
|
715
|
+
textStyle.textBoxShadowOffsetY = textStyleModel.getShallow('shadowOffsetY');
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
textStyle.textShadowColor = textStyleModel.getShallow('textShadowColor')
|
|
719
|
+
|| globalTextStyle.textShadowColor;
|
|
720
|
+
textStyle.textShadowBlur = textStyleModel.getShallow('textShadowBlur')
|
|
721
|
+
|| globalTextStyle.textShadowBlur;
|
|
722
|
+
textStyle.textShadowOffsetX = textStyleModel.getShallow('textShadowOffsetX')
|
|
723
|
+
|| globalTextStyle.textShadowOffsetX;
|
|
724
|
+
textStyle.textShadowOffsetY = textStyleModel.getShallow('textShadowOffsetY')
|
|
725
|
+
|| globalTextStyle.textShadowOffsetY;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function getAutoColor(color, opt) {
|
|
729
|
+
return color !== 'auto' ? color : (opt && opt.autoColor) ? opt.autoColor : null;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function applyInsideStyle(textStyle, textPosition, opt) {
|
|
733
|
+
var useInsideStyle = opt.useInsideStyle;
|
|
734
|
+
var insideRollback;
|
|
735
|
+
|
|
736
|
+
if (textStyle.textFill == null
|
|
737
|
+
&& useInsideStyle !== false
|
|
738
|
+
&& (useInsideStyle === true
|
|
739
|
+
|| (opt.isRectText
|
|
740
|
+
&& textPosition
|
|
741
|
+
// textPosition can be [10, 30]
|
|
742
|
+
&& typeof textPosition === 'string'
|
|
743
|
+
&& textPosition.indexOf('inside') >= 0
|
|
744
|
+
)
|
|
745
|
+
)
|
|
746
|
+
) {
|
|
747
|
+
insideRollback = {
|
|
748
|
+
textFill: null,
|
|
749
|
+
textStroke: textStyle.textStroke,
|
|
750
|
+
textStrokeWidth: textStyle.textStrokeWidth
|
|
751
|
+
};
|
|
752
|
+
textStyle.textFill = '#fff';
|
|
753
|
+
// Consider text with #fff overflow its container.
|
|
754
|
+
if (textStyle.textStroke == null) {
|
|
755
|
+
textStyle.textStroke = opt.autoColor;
|
|
756
|
+
textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
return insideRollback;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function rollbackInsideStyle(style) {
|
|
764
|
+
var insideRollback = style.insideRollback;
|
|
765
|
+
if (insideRollback) {
|
|
766
|
+
style.textFill = insideRollback.textFill;
|
|
767
|
+
style.textStroke = insideRollback.textStroke;
|
|
768
|
+
style.textStrokeWidth = insideRollback.textStrokeWidth;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
412
772
|
graphic.getFont = function (opt, ecModel) {
|
|
413
|
-
|
|
773
|
+
// ecModel or default text style model.
|
|
774
|
+
var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
|
|
414
775
|
return [
|
|
415
776
|
// FIXME in node-canvas fontWeight is before fontStyle
|
|
416
777
|
opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
|
|
@@ -448,7 +809,7 @@
|
|
|
448
809
|
}
|
|
449
810
|
|
|
450
811
|
duration > 0
|
|
451
|
-
? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
|
|
812
|
+
? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb, !!cb)
|
|
452
813
|
: (el.stopAnimation(), el.attr(props), cb && cb());
|
|
453
814
|
}
|
|
454
815
|
else {
|
|
@@ -639,5 +1000,35 @@
|
|
|
639
1000
|
}
|
|
640
1001
|
};
|
|
641
1002
|
|
|
1003
|
+
/**
|
|
1004
|
+
* @param {string} iconStr Support 'image://' or 'path://' or direct svg path.
|
|
1005
|
+
* @param {Object} [opt] Properties of `module:zrender/Element`, except `style`.
|
|
1006
|
+
* @param {Object} [rect] {x, y, width, height}
|
|
1007
|
+
* @return {module:zrender/Element} Icon path or image element.
|
|
1008
|
+
*/
|
|
1009
|
+
graphic.createIcon = function (iconStr, opt, rect) {
|
|
1010
|
+
opt = zrUtil.extend({rectHover: true}, opt);
|
|
1011
|
+
var style = opt.style = {strokeNoScale: true};
|
|
1012
|
+
rect = rect || {x: -1, y: -1, width: 2, height: 2};
|
|
1013
|
+
|
|
1014
|
+
if (iconStr) {
|
|
1015
|
+
return iconStr.indexOf('image://') === 0
|
|
1016
|
+
? (
|
|
1017
|
+
style.image = iconStr.slice(8),
|
|
1018
|
+
zrUtil.defaults(style, rect),
|
|
1019
|
+
new graphic.Image(opt)
|
|
1020
|
+
)
|
|
1021
|
+
: (
|
|
1022
|
+
graphic.makePath(
|
|
1023
|
+
iconStr.replace('path://', ''),
|
|
1024
|
+
opt,
|
|
1025
|
+
rect,
|
|
1026
|
+
'center'
|
|
1027
|
+
)
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
};
|
|
1032
|
+
|
|
642
1033
|
module.exports = graphic;
|
|
643
1034
|
|
package/lib/util/layout.js
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
function boxLayout(orient, group, gap, maxWidth, maxHeight) {
|
|
30
30
|
var x = 0;
|
|
31
31
|
var y = 0;
|
|
32
|
+
|
|
32
33
|
if (maxWidth == null) {
|
|
33
34
|
maxWidth = Infinity;
|
|
34
35
|
}
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
maxHeight = Infinity;
|
|
37
38
|
}
|
|
38
39
|
var currentLineMaxSize = 0;
|
|
40
|
+
|
|
39
41
|
group.eachChild(function (child, idx) {
|
|
40
42
|
var position = child.position;
|
|
41
43
|
var rect = child.getBoundingRect();
|
|
@@ -43,10 +45,12 @@
|
|
|
43
45
|
var nextChildRect = nextChild && nextChild.getBoundingRect();
|
|
44
46
|
var nextX;
|
|
45
47
|
var nextY;
|
|
48
|
+
|
|
46
49
|
if (orient === 'horizontal') {
|
|
47
50
|
var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
|
|
48
51
|
nextX = x + moveX;
|
|
49
52
|
// Wrap when width exceeds maxWidth or meet a `newline` group
|
|
53
|
+
// FIXME compare before adding gap?
|
|
50
54
|
if (nextX > maxWidth || child.newline) {
|
|
51
55
|
x = 0;
|
|
52
56
|
nextX = moveX;
|
|
@@ -54,6 +58,7 @@
|
|
|
54
58
|
currentLineMaxSize = rect.height;
|
|
55
59
|
}
|
|
56
60
|
else {
|
|
61
|
+
// FIXME: consider rect.y is not `0`?
|
|
57
62
|
currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
@@ -124,7 +129,7 @@
|
|
|
124
129
|
* @param {number|string} [positionInfo.y]
|
|
125
130
|
* @param {number|string} [positionInfo.x2]
|
|
126
131
|
* @param {number|string} [positionInfo.y2]
|
|
127
|
-
* @param {Object} containerRect
|
|
132
|
+
* @param {Object} containerRect {width, height}
|
|
128
133
|
* @param {string|number} margin
|
|
129
134
|
* @return {Object} {width, height}
|
|
130
135
|
*/
|
|
@@ -193,20 +198,23 @@
|
|
|
193
198
|
height = containerHeight - bottom - verticalMargin - top;
|
|
194
199
|
}
|
|
195
200
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
if (aspect != null) {
|
|
202
|
+
// If width and height are not given
|
|
203
|
+
// 1. Graph should not exceeds the container
|
|
204
|
+
// 2. Aspect must be keeped
|
|
205
|
+
// 3. Graph should take the space as more as possible
|
|
206
|
+
// FIXME
|
|
207
|
+
// Margin is not considered, because there is no case that both
|
|
208
|
+
// using margin and aspect so far.
|
|
209
|
+
if (isNaN(width) && isNaN(height)) {
|
|
210
|
+
if (aspect > containerWidth / containerHeight) {
|
|
211
|
+
width = containerWidth * 0.8;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
height = containerHeight * 0.8;
|
|
215
|
+
}
|
|
206
216
|
}
|
|
207
|
-
}
|
|
208
217
|
|
|
209
|
-
if (aspect != null) {
|
|
210
218
|
// Calculate width or height with given aspect
|
|
211
219
|
if (isNaN(width)) {
|
|
212
220
|
width = aspect * height;
|
|
@@ -247,11 +255,11 @@
|
|
|
247
255
|
top = top || 0;
|
|
248
256
|
if (isNaN(width)) {
|
|
249
257
|
// Width may be NaN if only one value is given except width
|
|
250
|
-
width = containerWidth - left - (right || 0);
|
|
258
|
+
width = containerWidth - horizontalMargin - left - (right || 0);
|
|
251
259
|
}
|
|
252
260
|
if (isNaN(height)) {
|
|
253
261
|
// Height may be NaN if only one value is given except height
|
|
254
|
-
height = containerHeight - top - (bottom || 0);
|
|
262
|
+
height = containerHeight - verticalMargin - top - (bottom || 0);
|
|
255
263
|
}
|
|
256
264
|
|
|
257
265
|
var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
|
|
@@ -281,6 +289,8 @@
|
|
|
281
289
|
* @param {number|string} [positionInfo.top]
|
|
282
290
|
* @param {number|string} [positionInfo.right]
|
|
283
291
|
* @param {number|string} [positionInfo.bottom]
|
|
292
|
+
* @param {number|string} [positionInfo.width] Only for opt.boundingModel: 'raw'
|
|
293
|
+
* @param {number|string} [positionInfo.height] Only for opt.boundingModel: 'raw'
|
|
284
294
|
* @param {Object} containerRect
|
|
285
295
|
* @param {string|number} margin
|
|
286
296
|
* @param {Object} [opt]
|
|
@@ -322,6 +332,7 @@
|
|
|
322
332
|
}
|
|
323
333
|
}
|
|
324
334
|
|
|
335
|
+
// The real width and height can not be specified but calculated by the given el.
|
|
325
336
|
positionInfo = layout.getLayoutRect(
|
|
326
337
|
zrUtil.defaults(
|
|
327
338
|
{width: rect.width, height: rect.height},
|
|
@@ -372,7 +383,8 @@
|
|
|
372
383
|
* @param {Object} targetOption
|
|
373
384
|
* @param {Object} newOption
|
|
374
385
|
* @param {Object|string} [opt]
|
|
375
|
-
* @param {boolean|Array.<boolean>} [opt.ignoreSize=false]
|
|
386
|
+
* @param {boolean|Array.<boolean>} [opt.ignoreSize=false] Used for the components
|
|
387
|
+
* that width (or height) should not be calculated by left and right (or top and bottom).
|
|
376
388
|
*/
|
|
377
389
|
layout.mergeLayoutParam = function (targetOption, newOption, opt) {
|
|
378
390
|
!zrUtil.isObject(opt) && (opt = {});
|