diff --git a/src/chart/funnel/FunnelSeries.js b/src/chart/funnel/FunnelSeries.js index 565446573a9e6396cf47607f9c691d47fd2ac328..f6efa8ffa41e8d0f980d7bab5a4837a493438ea1 100644 --- a/src/chart/funnel/FunnelSeries.js +++ b/src/chart/funnel/FunnelSeries.js @@ -5,7 +5,7 @@ define(function(require) { var List = require('../../data/List'); var SeriesModel = require('../../model/Series'); - var PieSeries = SeriesModel.extend({ + var FunnelSeries = SeriesModel.extend({ type: 'series.funnel', @@ -17,6 +17,14 @@ define(function(require) { this.legendDataProvider = function () { return this._dataBeforeProcessed; }; + + // Extend labelLine emphasis + // this._defaultLabelLine(); + }, + + mergeOption: function (newOption) { + SeriesModel.prototype.mergeOption.call(this, newOption); + this._defaultLabelLine(); }, getInitialData: function (option, ecModel) { @@ -25,6 +33,20 @@ define(function(require) { return list; }, + _defaultLabelLine: function () { + // Extend labelLine emphasis + this.defaultEmphasis('labelLine', ['show']); + + var option = this.option; + var labelLineNormalOpt = option.labelLine.normal; + var labelLineEmphasisOpt = option.labelLine.emphasis; + // Not show label line if `label.normal.show = false` + labelLineNormalOpt.show = labelLineNormalOpt.show + && option.label.normal.show; + labelLineEmphasisOpt.show = labelLineEmphasisOpt.show + && option.label.emphasis.show; + }, + defaultOption: { zlevel: 0, // 一级层叠 z: 2, // 二级层叠 @@ -55,13 +77,16 @@ define(function(require) { } }, labelLine: { - show: true, - length: 20, - lineStyle: { - // color: 各异, - width: 1, - type: 'solid' - } + normal: { + show: true, + length: 20, + lineStyle: { + // color: 各异, + width: 1, + type: 'solid' + } + }, + emphasis: {} }, itemStyle: { normal: { @@ -76,5 +101,5 @@ define(function(require) { } }); - return PieSeries; + return FunnelSeries; }); \ No newline at end of file diff --git a/src/chart/funnel/FunnelView.js b/src/chart/funnel/FunnelView.js index 7153b0dccb7c73adc7023a7bb676f072b2521ee6..b7f5cd156f5dae156e7246714bd97095e460feb3 100644 --- a/src/chart/funnel/FunnelView.js +++ b/src/chart/funnel/FunnelView.js @@ -185,7 +185,7 @@ define(function (require) { textFont: textStyleModel.getFont() }); // Default use item visual color - labelLine.attr('ignore', !itemModel.get('labelLine.show')); + labelLine.attr('ignore', !itemModel.get('labelLine.normal.show')); labelLine.setStyle({ stroke: visualColor }); diff --git a/src/chart/funnel/funnelLayout.js b/src/chart/funnel/funnelLayout.js index d510f1616473aaf3f5cceee0c51111652c85b69e..ae9d184c06d6c3fe26045d04f892c674c6a4ad96 100644 --- a/src/chart/funnel/funnelLayout.js +++ b/src/chart/funnel/funnelLayout.js @@ -40,7 +40,7 @@ define(function (require) { var labelModel = itemModel.getModel('label.normal'); var labelPosition = labelModel.get('position'); - var labelLineModel = itemModel.getModel('labelLine'); + var labelLineModel = itemModel.getModel('labelLine.normal'); var layout = data.getItemLayout(idx); var points = layout.points; diff --git a/src/chart/pie/PieSeries.js b/src/chart/pie/PieSeries.js index c9570e9ad9abcc43431e36cd02d8f36a6e2b833d..c7b02bd3378e9a56c4c7623a3a5437b1e0f20ebc 100644 --- a/src/chart/pie/PieSeries.js +++ b/src/chart/pie/PieSeries.js @@ -25,12 +25,16 @@ define(function(require) { }; this.updateSelectedMap(); + + this._defaultLabelLine(); }, // Overwrite mergeOption: function (newOption) { seriesModelProto.mergeOption.call(this, newOption); this.updateSelectedMap(); + + this._defaultLabelLine(); }, getInitialData: function (option, ecModel) { @@ -49,6 +53,20 @@ define(function(require) { return params; }, + _defaultLabelLine: function () { + // Extend labelLine emphasis + this.defaultEmphasis('labelLine', ['show']); + + var option = this.option; + var labelLineNormalOpt = option.labelLine.normal; + var labelLineEmphasisOpt = option.labelLine.emphasis; + // Not show label line if `label.normal.show = false` + labelLineNormalOpt.show = labelLineNormalOpt.show + && option.label.normal.show; + labelLineEmphasisOpt.show = labelLineEmphasisOpt.show + && option.label.emphasis.show; + }, + defaultOption: { zlevel: 0, z: 2, diff --git a/src/chart/pie/PieView.js b/src/chart/pie/PieView.js index b388030350ab1a4d055d1986282ca50b5d332f27..7822640753630d8649a29468b2ede60e9dd9f666 100644 --- a/src/chart/pie/PieView.js +++ b/src/chart/pie/PieView.js @@ -169,7 +169,7 @@ define(function (require) { var textStyleModel = labelModel.getModel('textStyle'); var labelPosition = labelModel.get('position'); - var isLabelInside = labelPosition === 'inside'; + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; labelText.setStyle({ fill: textStyleModel.get('color') diff --git a/src/chart/pie/labelLayout.js b/src/chart/pie/labelLayout.js index d77f031f85589a5c39312e5f9b33a46844940357..112828273c843285408265fad6697855817724f8 100644 --- a/src/chart/pie/labelLayout.js +++ b/src/chart/pie/labelLayout.js @@ -167,7 +167,7 @@ define(function (require) { textAlign = 'center'; } else { - var isLabelInside = labelPosition === 'inside'; + var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner'; var x1 = (isLabelInside ? layout.r / 2 * dx : layout.r * dx) + cx; var y1 = (isLabelInside ? layout.r / 2 * dy : layout.r * dy) + cy; diff --git a/src/component/tooltip/TooltipContent.js b/src/component/tooltip/TooltipContent.js index 89aa46cb3f90c6896cb8bcbe0ddf41e68270ad81..fe46557164f26e18b95b904251a5be9796a45915 100644 --- a/src/component/tooltip/TooltipContent.js +++ b/src/component/tooltip/TooltipContent.js @@ -149,7 +149,9 @@ define(function (require) { }, setContent: function (content) { - this.el.innerHTML = content; + var el = this.el; + el.innerHTML = content; + el.style.display = content ? 'block' : 'none'; }, moveTo: function (x, y) { diff --git a/src/echarts.js b/src/echarts.js index b651b38e8a6b0b86b52fb06f37fdc9c086feec4d..ef730784cdaa356dbecd5bf809f20039dda45eeb 100644 --- a/src/echarts.js +++ b/src/echarts.js @@ -879,7 +879,6 @@ define(function (require) { echarts.registerVisualCoding('echarts', require('./visual/seriesColor')); echarts.registerPreprocessor(require('./preprocessor/backwardCompat')); - echarts.registerPreprocessor(require('./preprocessor/fillLabel')); // Default action echarts.registerAction({ diff --git a/src/model/Series.js b/src/model/Series.js index ced53bec5333253e53eef40c66b18ab942b31fbe..e42b4f9476998c5bfc25a3eede2ddd67c672dabd 100644 --- a/src/model/Series.js +++ b/src/model/Series.js @@ -51,12 +51,20 @@ define(function(require) { this._dataBeforeProcessed = this._data.cloneShallow(); }, + /** + * Util for merge default and theme to option + * @param {Object} option + * @param {module:echarts/model/Global} ecModel + */ mergeDefaultAndTheme: function (option, ecModel) { zrUtil.merge( option, ecModel.getTheme().get(ComponentModel.parseClassType(this.type).sub) ); zrUtil.merge(option, this.getDefaultOption()); + + // Default label emphasis `position` and `show` + this.defaultEmphasis('label'); }, mergeOption: function (newSeriesOption, ecModel) { @@ -68,6 +76,25 @@ define(function(require) { this._data = data; this._dataBeforeProcessed = data.cloneShallow(); } + + this.defaultEmphasis('label'); + }, + + /** + * Util for default emphasis option from normal option like `position` and `show` + * @param {string} optName + * @param {Array.} [subOpts=['position', 'show']] + */ + defaultEmphasis: function (optName, subOpts) { + var opt = this.get(optName); + if (opt && opt.normal) { + var emphasisOpt = opt.emphasis = opt.emphasis || {}; + + subOpts = subOpts || ['position', 'show']; + zrUtil.each(subOpts, function (subOptName) { + emphasisOpt[subOptName] = zrUtil.retrieve(emphasisOpt[subOptName], opt.normal[subOptName]); + }); + } }, /** diff --git a/src/preprocessor/fillLabel.js b/src/preprocessor/fillLabel.js deleted file mode 100644 index 77599a1f145c4fa20f5309d403542a6a648c572e..0000000000000000000000000000000000000000 --- a/src/preprocessor/fillLabel.js +++ /dev/null @@ -1,25 +0,0 @@ -define(function (require) { - var zrUtil = require('zrender/core/util'); - - // Extend the emphasis option which has in normal but - // Not in the emphasis, like position, show - function fillLabel(labelOpt) { - if (labelOpt) { - var normalOpt = labelOpt.normal; - if (normalOpt) { - zrUtil.merge(labelOpt.emphasis || (labelOpt.emphasis = {}), normalOpt); - } - } - } - return function (option) { - zrUtil.each(option.series, function (seriesOpt) { - fillLabel(seriesOpt.label); - // Label line for pie and funnel - fillLabel(seriesOpt.labelLine); - zrUtil.each(seriesOpt.data, function (dataOpt) { - fillLabel(dataOpt.label); - fillLabel(dataOpt.labelLine); - }); - }); - }; -}); \ No newline at end of file