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