提交 a6e52294 编写于 作者: L lang

tweak

上级 733281de
......@@ -4,6 +4,7 @@ define(function(require) {
var List = require('../../data/List');
var SeriesModel = require('../../model/Series');
var modelUtil = require('../../util/model');
var FunnelSeries = SeriesModel.extend({
......@@ -17,14 +18,8 @@ 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();
this._defaultLabelLine(option);
},
getInitialData: function (option, ecModel) {
......@@ -33,11 +28,10 @@ define(function(require) {
return list;
},
_defaultLabelLine: function () {
_defaultLabelLine: function (option) {
// Extend labelLine emphasis
this.defaultEmphasis('labelLine', ['show']);
modelUtil.defaultEmphasis(option.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`
......
......@@ -145,13 +145,13 @@ define(function(require) {
);
}
// Always update, or it is wrong in the case turning on legend
// Always update, or it is wrong in the case turning on legend because points is not changed
symbolDraw.updateData(data, api, isSymbolIgnore);
// Stop symbol animation and sync with line points
// FIXME performance?
data.eachItemGraphicEl(function (el) {
el.stopAnimation();
el.stopAnimation(true);
});
// In the case data zoom triggerred refreshing frequently
......@@ -293,6 +293,7 @@ define(function(require) {
/**
* @private
*/
// FIXME Two value axis
_updateAnimation: function (data, stackedOnPoints, coordSys, api) {
var polyline = this._polyline;
var polygon = this._polygon;
......@@ -339,7 +340,7 @@ define(function(require) {
}
}
if (polyline.animators) {
if (polyline.animators && polyline.animators.length) {
polyline.animators[0].during(function () {
for (var i = 0; i < updatedDataInfo.length; i++) {
var el = updatedDataInfo[i].el;
......
......@@ -5,6 +5,7 @@ define(function(require) {
var List = require('../../data/List');
var SeriesModel = require('../../model/Series');
var zrUtil = require('zrender/core/util');
var modelUtil = require('../../util/model');
var dataSelectableMixin = require('../helper/dataSelectableMixin');
......@@ -26,15 +27,13 @@ define(function(require) {
this.updateSelectedMap();
this._defaultLabelLine();
this._defaultLabelLine(option);
},
// Overwrite
mergeOption: function (newOption) {
seriesModelProto.mergeOption.call(this, newOption);
this.updateSelectedMap();
this._defaultLabelLine();
},
getInitialData: function (option, ecModel) {
......@@ -54,11 +53,10 @@ define(function(require) {
return params;
},
_defaultLabelLine: function () {
_defaultLabelLine: function (option) {
// Extend labelLine emphasis
this.defaultEmphasis('labelLine', ['show']);
modelUtil.defaultEmphasis(option.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`
......@@ -82,6 +80,8 @@ define(function(require) {
minAngle: 0,
// 选中是扇区偏移量
selectedOffset: 10,
// If use strategy to avoid label overlapping
avoidLabelOverlap: true,
// 选择模式,默认关闭,可选single,multiple
// selectedMode: false,
......
......@@ -93,6 +93,19 @@ define(function (require) {
var piePieceProto = PiePiece.prototype;
function getLabelStyle(data, idx, state, labelModel) {
var textStyleModel = labelModel.getModel('textStyle');
var position = labelModel.get('position');
var isLabelInside = position === 'inside' || position === 'inner';
return {
fill: textStyleModel.get('color')
|| isLabelInside ? '#fff' : data.getItemVisual(idx, 'color'),
textFont: textStyleModel.getFont(),
text: data.hostModel.getFormattedLabel(idx, state)
|| data.getName(idx)
};
}
piePieceProto.updateData = function (data, idx, api, firstCreate) {
var sector = this.childAt(0);
......@@ -167,17 +180,7 @@ define(function (require) {
var labelLineModel = itemModel.getModel('labelLine.normal');
var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
var textStyleModel = labelModel.getModel('textStyle');
var labelPosition = labelModel.get('position');
var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
labelText.setStyle({
fill: textStyleModel.get('color')
|| isLabelInside ? '#fff' : visualColor,
text: seriesModel.getFormattedLabel(idx, 'normal')
|| data.getName(idx),
textFont: textStyleModel.getFont()
});
labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel));
labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
labelText.hoverIgnore = !labelHoverModel.get('show');
......@@ -189,7 +192,7 @@ define(function (require) {
labelLine.setStyle({
stroke: visualColor
});
labelLine.setStyle(labelLineModel.getLineStyle());
labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
sector.setStyle(
zrUtil.extend(
......@@ -200,8 +203,8 @@ define(function (require) {
)
);
sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
labelText.hoverStyle = labelHoverModel.getModel('textStyle').getItemStyle();
labelLine.hoverStyle = labelLineHoverModel.getLineStyle();
labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel);
labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
graphic.setHoverStyle(this);
......
......@@ -216,7 +216,8 @@ define(function (require) {
labelLayoutList.push(layout.label);
});
!hasLabelRotate && avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
}
};
});
\ No newline at end of file
......@@ -77,7 +77,7 @@ define(function (require) {
}
var mpData = createList(coordSys, seriesData, mpModel);
var dims = coordSys.dimensions;
var dims = coordSys && coordSys.dimensions;
// Overwrite getRawValue
// FIXME
......@@ -97,7 +97,7 @@ define(function (require) {
if (xPx != null && yPx != null) {
point = [xPx, yPx];
}
else {
else if (coordSys) {
var x = mpData.get(dims[0], idx);
var y = mpData.get(dims[1], idx);
point = coordSys.dataToPoint([x, y]);
......@@ -129,7 +129,7 @@ define(function (require) {
/**
* @inner
* @param {module:echarts/coord/*} coordSys
* @param {module:echarts/coord/*} [coordSys]
* @param {module:echarts/data/List} seriesData
* @param {module:echarts/model/Model} mpModel
*/
......
......@@ -62,10 +62,22 @@ define(function (require) {
average: curry(markerTypeCalculatorWithExtent, 0.5)
};
/**
* Transform markPoint data item to format used in List by do the following
* 1. Calculate statistic like `max`, `min`, `average`
* 2. Convert `item.xAxis`, `item.yAxis` to `item.value` array
* @param {module:echarts/data/List} data
* @param {module:echarts/coord/*} [coordSys]
* @param {Object} item
* @return {Object}
*/
var dataTransform = function (data, coordSys, item) {
// 1. If not specify the position with pixel directly
// 2. If value is not a data array. Which uses xAxis, yAxis to specify the value on each dimension
if (isNaN(item.x) || isNaN(item.y) && !zrUtil.isArray(item.value)) {
if (isNaN(item.x) || isNaN(item.y)
&& !zrUtil.isArray(item.value)
&& coordSys
) {
var valueAxisDim;
var baseAxisDim;
var valueAxis;
......@@ -113,11 +125,20 @@ define(function (require) {
return item;
};
// Filter data which is out of coordinateSystem range
/**
* Filter data which is out of coordinateSystem range
* [dataFilter description]
* @param {module:echarts/coord/*} [coordSys]
* @param {Array.<number>} coordDataIdx
* @param {Object} item
* @return {boolean}
*/
var dataFilter = function (coordSys, coordDataIdx, item) {
var value = item.value;
value = [value[coordDataIdx[0]], value[coordDataIdx[1]]];
return coordSys.containData(value);
// Alwalys return true if there is no coordSys
return coordSys ? coordSys.containData(value) : true;
};
return {
......
......@@ -790,18 +790,17 @@ define(function (require) {
/**
* Create a data differ
* @param {module:echarts/data/List} oldList
* @param {module:echarts/data/List} otherList
* @return {module:echarts/data/DataDiffer}
*/
listProto.diff = function (oldList) {
listProto.diff = function (otherList) {
var idList = this._idList;
return new DataDiffer(
oldList ? oldList.indices : [], this.indices, function (idx) {
otherList ? otherList.indices : [], this.indices, function (idx) {
return idList[idx] || (idx + '');
}
);
};
/**
* Get visual property.
* @param {string} key
......
......@@ -4,6 +4,7 @@ define(function(require) {
var zrUtil = require('zrender/core/util');
var formatUtil = require('../util/format');
var modelUtil = require('../util/model');
var ComponentModel = require('./Component');
var encodeHTML = formatUtil.encodeHTML;
......@@ -64,7 +65,7 @@ define(function(require) {
zrUtil.merge(option, this.getDefaultOption());
// Default label emphasis `position` and `show`
this.defaultEmphasis('label');
modelUtil.defaultEmphasis(option.label);
},
mergeOption: function (newSeriesOption, ecModel) {
......@@ -76,25 +77,11 @@ 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]);
});
}
// FIXME
// Default label emphasis `position` and `show`
// Do it after option is merged. In case newSeriesOption only
// set the value in emphasis
// modelUtil.defaultNormalEmphasis(this.option.label);
},
/**
......
......@@ -18,7 +18,7 @@ define(function () {
// 浅色
// color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
// 深色
color: ['#314656', '#61a0a8', '#c23531', '#dd8668', '#91c7ae', '#6e7074', '#61a0a8', '#bda29a', '#44525d', '#c4ccd3'],
color: ['#c23531', '#314656', '#61a0a8', '#dd8668', '#91c7ae', '#6e7074', '#61a0a8', '#bda29a', '#44525d', '#c4ccd3'],
// color: ['#0088bb', '#a4d2aa', '#ea9695', '#eddf93', '#9bd6ec', '#f7c753', '#c78682', '#6bc3bc', '#e5362d', '#fbeabf'],
// 默认需要 Grid 配置项
......
......@@ -302,15 +302,15 @@ define(function(require) {
/**
* Set text option in the style
* @param {Object} style
* @param {Object} textStyle
* @param {module:echarts/model/Model} labelModel
* @param {string} color
*/
graphic.setText = function (style, labelModel, color) {
graphic.setText = function (textStyle, labelModel, color) {
var labelPosition = labelModel.get('position') || 'inside';
var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
var textStyleModel = labelModel.getModel('textStyle');
zrUtil.extend(style, {
zrUtil.extend(textStyle, {
textFont: textStyleModel.getFont(),
textPosition: labelPosition,
textFill: textStyleModel.get('color') || labelColor
......
......@@ -4,7 +4,7 @@ define(function(require) {
var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle'];
var util = {};
var modelUtil = {};
/**
* Create "each" method to iterate names.
......@@ -14,11 +14,11 @@ define(function(require) {
* @param {Array.<string>=} attrs
* @return {Function}
*/
util.createNameEach = function (names, attrs) {
modelUtil.createNameEach = function (names, attrs) {
names = names.slice();
var capitalNames = zrUtil.map(names, util.capitalFirst);
var capitalNames = zrUtil.map(names, modelUtil.capitalFirst);
attrs = (attrs || []).slice();
var capitalAttrs = zrUtil.map(attrs, util.capitalFirst);
var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst);
return function (callback, context) {
zrUtil.each(names, function (name, index) {
......@@ -36,7 +36,7 @@ define(function(require) {
/**
* @public
*/
util.capitalFirst = function (str) {
modelUtil.capitalFirst = function (str) {
return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
};
......@@ -54,14 +54,14 @@ define(function(require) {
* }
* @param {Object} context
*/
util.eachAxisDim = util.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']);
modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']);
/**
* If value is not array, then translate it to array.
* @param {*} value
* @return {Array} [value] or value
*/
util.normalizeToArray = function (value) {
modelUtil.normalizeToArray = function (value) {
return zrUtil.isArray(value)
? value
: value == null
......@@ -80,7 +80,7 @@ define(function(require) {
* @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
* @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
*/
util.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
return function (sourceNode) {
var result = {
......@@ -139,5 +139,36 @@ define(function(require) {
}
};
return util;
/**
* Sync default option between normal and emphasis like `position` and `show`
* In case some one will write code like
* label: {
* normal: {
* show: false
* },
* emphasis: {
* show: true,
* position: 'outside',
* textStyle: {
* fontSize: 18
* }
* }
* }
* @param {Object} opt
* @param {Array.<string>} [subOpts=['position', 'show']]
*/
modelUtil.defaultEmphasis = function (opt, subOpts) {
if (opt) {
var emphasisOpt = opt.emphasis = opt.emphasis || {};
var normalOpt = opt.normal = opt.normal || {};
subOpts = subOpts || ['position', 'show', 'textStyle'];
// Default emphasis option from normal
zrUtil.each(subOpts, function (subOptName) {
emphasisOpt[subOptName] = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]);
});
}
};
return modelUtil;
});
\ No newline at end of file
......@@ -85,7 +85,7 @@ define(function (require) {
number.round = function (x) {
// PENDING
return +(+x).toFixed(12);
}
};
number.asc = function (arr) {
arr.sort(function (a, b) {
......
......@@ -97,14 +97,12 @@ define(function (require) {
*/
function elSetState(el, state) {
if (el) {
el.trigger(state);
if (el.type === 'group') {
for (var i = 0; i < el.childCount(); i++) {
elSetState(el.childAt(i), state);
}
}
else {
el.trigger(state);
}
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册