提交 d0194afc 编写于 作者: L lang

Tweak

上级 7abad407
......@@ -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
......@@ -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
});
......
......@@ -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;
......
......@@ -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,
......
......@@ -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')
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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({
......
......@@ -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.<string>} [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]);
});
}
},
/**
......
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册