提交 ec271391 编写于 作者: P pah100

Merge branch 'dev-3.0.0' of https://github.com/ecomfe/echarts into dev-3.0.0

......@@ -4,6 +4,7 @@ define(function(require) {
var List = require('../../data/List');
var modelUtil = require('../../util/model');
var completeDimensions = require('../../data/helper/completeDimensions');
require('../../echarts').extendSeriesModel({
......@@ -22,7 +23,8 @@ define(function(require) {
},
getInitialData: function (option, ecModel) {
var list = new List(['value'], this);
var dimensions = completeDimensions(['value'], option.data);
var list = new List(dimensions, this);
list.initData(option.data);
return list;
},
......
......@@ -41,7 +41,7 @@ define(function (require) {
function getLabelStyle(data, idx, state, labelModel) {
var textStyleModel = labelModel.getModel('textStyle');
var position = labelModel.get('position');
var isLabelInside = position === 'inside' || position === 'inner';
var isLabelInside = position === 'inside' || position === 'inner' || position === 'center';
return {
fill: textStyleModel.getTextColor()
|| (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
......
......@@ -40,7 +40,7 @@ define(function (require) {
// 默认显示,属性show控制显示与否
show: true,
lineStyle: { // 属性lineStyle控制线条样式
color: [[0.2, '#91c7ae'],[0.8, '#63869e'],[1, '#c23531']],
color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']],
width: 30
}
},
......@@ -72,7 +72,7 @@ define(function (require) {
type: 'solid'
}
},
axisLabel: { // 坐标轴文本标签,详见axis.axisLabel
axisLabel: {
show: true,
// formatter: null,
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
......
......@@ -33,7 +33,20 @@ define(function (require) {
var nodes = option.data || option.nodes;
if (nodes && edges) {
var graph = createGraphFromNodeEdge(nodes, edges, this, true);
return graph.data;
var list = graph.data;
var self = this;
// Overwrite list.getItemModel to
list.wrapMethod('getItemModel', function (model) {
var categoriesModels = self._categoriesModels;
var categoryIdx = model.getShallow('category');
var categoryModel = categoriesModels[categoryIdx];
if (categoryModel) {
categoryModel.parentModel = model.parentModel;
model.parentModel = categoryModel;
}
return model;
});
return list;
}
},
......@@ -66,12 +79,18 @@ define(function (require) {
_updateCategoriesData: function () {
var categories = zrUtil.map(this.option.categories || [], function (category) {
// Data must has value
return category.value != null ? category : zrUtil.extend({value : 0}, category);
return category.value != null ? category : zrUtil.extend({
value: 0
}, category);
});
var categoriesData = new List(['value'], this);
categoriesData.initData(categories);
this._categoriesData = categoriesData;
this._categoriesModels = categoriesData.mapArray(function (idx) {
return categoriesData.getItemModel(idx, true);
});
},
/**
......@@ -142,7 +161,7 @@ define(function (require) {
nodeScaleRatio: 0.6,
// Line width scale ratio in roam
edgeScaleRatio: 0.1,
// edgeScaleRatio: 0.1,
// categories: [],
......
......@@ -5,6 +5,7 @@ define(function(require) {
var List = require('../../data/List');
var zrUtil = require('zrender/core/util');
var modelUtil = require('../../util/model');
var completeDimensions = require('../../data/helper/completeDimensions');
var dataSelectableMixin = require('../helper/dataSelectableMixin');
......@@ -34,7 +35,8 @@ define(function(require) {
},
getInitialData: function (option, ecModel) {
var list = new List(['value'], this);
var dimensions = completeDimensions(['value'], option.data);
var list = new List(dimensions, this);
list.initData(option.data);
return list;
},
......
......@@ -195,10 +195,27 @@ define(function (require) {
var data = [];
for (var i = 0; i < lines.length; i++) {
var items = trim(lines[i]).split(itemSplitRegex);
data[i] = [];
var name = '';
var value;
var hasName = false;
if (isNaN(items[0])) { // First item is name
hasName = true;
name = items[0];
items = items.slice(1);
data[i] = {
name: name,
value: []
};
value = data[i].value;
}
else {
value = data[i] = [];
}
for (var j = 0; j < items.length; j++) {
var item = items[j];
data[i].push(item);
value.push(+items[j]);
}
if (value.length === 1) {
hasName ? (data[i].value = value[0]) : (data[i] = value[0]);
}
}
......@@ -384,6 +401,10 @@ define(function (require) {
return zrUtil.map(newData, function (newVal, idx) {
var original = originalData && originalData[idx];
if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
newVal = newVal.value;
}
// Original data has option
return zrUtil.defaults({
value: newVal
}, original);
......
......@@ -31,8 +31,8 @@ define(function (require) {
'stackedOn', '_nameList', '_idList', '_rawData'
];
var transferImmuProperties = function (a, b) {
zrUtil.each(IMMUTABLE_PROPERTIES, function (propName) {
var transferImmuProperties = function (a, b, wrappedMethod) {
zrUtil.each(IMMUTABLE_PROPERTIES.concat(wrappedMethod || []), function (propName) {
if (b.hasOwnProperty(propName)) {
a[propName] = b[propName];
}
......@@ -275,10 +275,6 @@ define(function (require) {
this._idList = idList;
};
listProto.getDimValue = function () {
};
/**
* @return {number}
*/
......@@ -676,7 +672,7 @@ define(function (require) {
var indices = list.indices = this.indices;
// FIXME If needs stackedOn, value may already been stacked
transferImmuProperties(list, this);
transferImmuProperties(list, this, this._wrappedMethods);
var storage = list._storage = {};
var thisStorage = this._storage;
......@@ -745,11 +741,11 @@ define(function (require) {
}
else {
model = temporaryModel;
// FIXME If return null when idx not exists
model.option = this._rawData[idx];
model.parentModel = hostModel;
model.ecModel = hostModel.ecModel;
}
// FIXME If return null when idx not exists
model.option = this._rawData[idx];
model.parentModel = hostModel;
model.ecModel = hostModel.ecModel;
return model;
};
......@@ -922,12 +918,30 @@ define(function (require) {
// FIXME
list._storage = this._storage;
transferImmuProperties(list, this);
transferImmuProperties(list, this, this._wrappedMethods);
list.indices = this.indices.slice();
return list;
};
/**
* Wrap some method to add more feature
* @param {string} methodName
* @param {Function} injectFunction
*/
listProto.wrapMethod = function (methodName, injectFunction) {
var originalMethod = this[methodName];
if (typeof originalMethod !== 'function') {
return;
}
this._wrappedMethods = this._wrappedMethods || [];
this._wrappedMethods.push(methodName);
this[methodName] = function () {
var res = originalMethod.apply(this, arguments);
return injectFunction.call(this, res);
};
};
return List;
});
\ No newline at end of file
......@@ -307,7 +307,7 @@ define(function(require) {
/**
* @private
* @readOnly
* @type {Array.<module:echarts/model/Model}
* @type {module:echarts/model/Model}
*/
this.hostModel = hostModel;
......
......@@ -193,7 +193,8 @@ define(function(require) {
height = coord[1] - lastCoord;
if (Math.abs(height) < barMinHeight) {
height = (height < 0 ? -1 : 1) * barMinHeight;
// Include zero to has a positive bar
height = (height <= 0 ? -1 : 1) * barMinHeight;
}
lastStackCoords[stackId][idx][sign] += height;
}
......
......@@ -21,7 +21,7 @@ define(function () {
// 主题,主题
textStyle: {
// color: '#000',
decoration: 'none',
// decoration: 'none',
// PENDING
fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
// fontFamily: 'Arial, Verdana, sans-serif',
......
......@@ -162,18 +162,7 @@ define(function (require) {
* @param {boolean} [fixMax=false]
*/
niceExtent: function (approxTickNum, fixMin, fixMax) {
this.niceTicks(approxTickNum, fixMin, fixMax);
var extent = this._extent;
var interval = this._interval;
if (!fixMin) {
extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
}
if (!fixMax) {
extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
}
// If extent start and end are same, expand them
if (extent[0] === extent[1]) {
// Expand extent
......@@ -187,6 +176,19 @@ define(function (require) {
extent[0] = -1;
this._niceExtent = [-1, 1];
this._interval = 0.5;
return;
}
this.niceTicks(approxTickNum, fixMin, fixMax);
// var extent = this._extent;
var interval = this._interval;
if (!fixMin) {
extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
}
if (!fixMax) {
extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
}
}
});
......
......@@ -2,9 +2,8 @@
define(function (require) {
return function (seriesType, ecModel) {
var colorList = ecModel.get('color');
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
var colorList = seriesModel.get('color');
var dataAll = seriesModel.getRawData();
if (!ecModel.isSeriesFiltered(seriesModel)) {
var data = seriesModel.getData();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册