提交 707799ba 编写于 作者: P pah100

Merge branch 'master' of https://github.com/pissang/echarts-next

Conflicts:
	src/data/List.js
......@@ -43,26 +43,13 @@ define(function (require) {
var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth'];
data.diff(oldData)
.add(function (dataIndex) {
// 空数据
if (!data.hasValue(dataIndex)) {
return;
}
function createRect(dataIndex, isUpdate) {
var layout = data.getItemLayout(dataIndex);
var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0;
fixLayoutWithLineWidth(layout, lineWidth);
var rect = new graphic.Rect({
shape: zrUtil.extend({}, layout)
});
data.setItemGraphicEl(dataIndex, rect);
group.add(rect);
var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0;
fixLayoutWithLineWidth(layout, lineWidth);
// Animation
if (enableAnimation) {
var rectShape = rect.shape;
......@@ -70,10 +57,25 @@ define(function (require) {
var animateTarget = {};
rectShape[animateProperty] = 0;
animateTarget[animateProperty] = layout[animateProperty];
api.initGraphicEl(rect, {
api[isUpdate? 'updateGraphicEl' : 'initGraphicEl'](rect, {
shape: animateTarget
});
}
return rect;
}
data.diff(oldData)
.add(function (dataIndex) {
// 空数据
if (!data.hasValue(dataIndex)) {
return;
}
var rect = createRect(dataIndex);
data.setItemGraphicEl(dataIndex, rect);
group.add(rect);
})
.update(function (newIndex, oldIndex) {
var rect = oldData.getItemGraphicEl(oldIndex);
......@@ -82,6 +84,9 @@ define(function (require) {
group.remove(rect);
return;
}
if (!rect) {
rect = createRect(newIndex, true);
}
var layout = data.getItemLayout(newIndex);
var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0;
......@@ -98,6 +103,7 @@ define(function (require) {
})
.remove(function (idx) {
var rect = oldData.getItemGraphicEl(idx);
if (rect) {
// Not show text when animating
rect.style.text = '';
api.updateGraphicEl(rect, {
......@@ -107,6 +113,7 @@ define(function (require) {
}, function () {
group.remove(rect);
});
}
})
.execute();
......
define(function (require) {
var graphic = require('../../util/graphic');
var symbolUtil = require('../../util/symbol');
var LargeSymbolPath = graphic.extendShape({
shape: {
points: null,
sizes: null
},
symbolProxy: null,
buildPath: function (path, shape) {
var points = shape.points;
var sizes = shape.sizes;
var symbolProxy = this.symbolProxy;
var symbolProxyShape = symbolProxy.shape;
for (var i = 0; i < points.length; i++) {
var pt = points[i];
var size = sizes[i];
if (size < 4) {
// Optimize for small symbol
path.rect(
pt[0] - size / 2, pt[1] - size / 2,
size, size
);
}
else {
symbolProxyShape.x = pt[0] - size / 2;
symbolProxyShape.y = pt[1] - size / 2;
symbolProxyShape.width = size;
symbolProxyShape.height = size;
symbolProxy.buildPath(path, symbolProxyShape);
}
}
}
});
function LargeSymbolDraw() {
this.group = new graphic.Group();
this._symbolEl = new LargeSymbolPath({
silent: true
});
}
var largeSymbolProto = LargeSymbolDraw.prototype;
/**
* Update symbols draw by new data
* @param {module:echarts/data/List} data
* @param {module:echarts/ExtensionAPI} api
*/
largeSymbolProto.updateData = function (data, api) {
var symbolEl = this._symbolEl;
var seriesModel = data.hostModel;
symbolEl.setShape({
points: data.mapArray(data.getItemLayout),
sizes: data.mapArray(
function (idx) {
return data.getItemVisual(idx, 'symbolSize');
}
)
});
// Create symbolProxy to build path for each data
symbolEl.symbolProxy = symbolUtil.createSymbol(
data.getVisual('symbol'), 0, 0, 0, 0
);
// Use symbolProxy setColor method
symbolEl.setColor = symbolEl.symbolProxy.setColor;
symbolEl.setStyle(
seriesModel.getModel('itemStyle.normal').getItemStyle(['color'])
);
var visualColor = data.getVisual('color');
if (visualColor) {
symbolEl.setColor(visualColor);
}
// Add back
this.group.add(this._symbolEl);
};
largeSymbolProto.updateLayout = function (seriesModel) {
var data = seriesModel.getData();
this._symbolEl.setShape({
points: data.mapArray(data.getItemLayout)
});
};
largeSymbolProto.remove = function () {
this.group.removeAll();
};
return LargeSymbolDraw;
});
\ No newline at end of file
......@@ -49,6 +49,29 @@ define(function (require) {
this.add(symbolPath);
};
/**
* Highlight symbol
*/
symbolProto.highlight = function () {
this.childAt(0).trigger('emphasis');
};
/**
* Downplay symbol
*/
symbolProto.downplay = function () {
this.childAt(0).trigger('normal');
};
/**
* @param {number} zlevel
* @param {number} z
*/
symbolProto.setZ = function (zlevel, z) {
var symbolPath = this.childAt(0);
symbolPath.zlevel = zlevel;
symbolPath.z = z;
};
/**
* Update symbol properties
* @param {module:echarts/data/List} data
......
......@@ -4,11 +4,14 @@ define(function(require) {
var zrUtil = require('zrender/core/util');
var SymbolDraw = require('../helper/SymbolDraw');
var Symbol = require('../helper/Symbol');
var lineAnimationDiff = require('./lineAnimationDiff');
var graphic = require('../../util/graphic');
var polyHelper = require('./poly');
var ChartView = require('../../view/Chart');
function isPointsSame(points1, points2) {
if (points1.length !== points2.length) {
return;
......@@ -77,7 +80,16 @@ define(function(require) {
}, true);
}
return require('../../echarts').extendChartView({
function queryDataIndex(data, payload) {
if (payload.dataIndex != null) {
return payload.dataIndex;
}
else if (payload.name != null) {
return data.indexOfName(payload.name);
}
}
return ChartView.extend({
type: 'line',
......@@ -220,6 +232,58 @@ define(function(require) {
this._points = points;
},
highlight: function (seriesModel, ecModel, api, payload) {
var data = seriesModel.getData();
var dataIndex = queryDataIndex(data, payload);
if (dataIndex >= 0) {
var symbol = data.getItemGraphicEl(dataIndex);
if (!symbol) {
// Create a temporary symbol if it is not exists
symbol = new Symbol(data, dataIndex, api);
symbol.position = data.getItemLayout(dataIndex);
symbol.setZ(
seriesModel.get('zlevel'),
seriesModel.get('z')
);
symbol.__temp = true;
data.setItemGraphicEl(dataIndex, symbol);
this.group.add(symbol);
}
symbol.highlight();
}
else {
// Highlight whole series
ChartView.prototype.highlight.call(
this, seriesModel, ecModel, api, payload
);
}
},
downplay: function (seriesModel, ecModel, api, payload) {
var data = seriesModel.getData();
var dataIndex = queryDataIndex(data, payload);
if (dataIndex >= 0) {
var symbol = data.getItemGraphicEl(dataIndex);
if (symbol) {
if (symbol.__temp) {
data.setItemGraphicEl(dataIndex, null);
this.group.remove(symbol);
}
else {
symbol.downplay();
}
}
}
else {
// Downplay whole series
ChartView.prototype.downplay.call(
this, seriesModel, ecModel, api, payload
);
}
},
/**
* @param {module:zrender/container/Group} group
* @param {Array.<Array.<number>>} points
......
......@@ -13,4 +13,6 @@ define(function (require) {
echarts.registerVisualCoding('chart', require('./map/mapVisual'));
echarts.registerProcessor('statistic', require('./map/mapDataStatistic'));
echarts.registerPreprocessor(require('./map/backwardCompat'));
});
\ No newline at end of file
......@@ -136,16 +136,16 @@ define(function (require) {
coordinateSystem: 'geo',
// 各省的 map 暂时都用中文
map: 'china',
mapLocation: {
// 'center' | 'left' | 'right' | 'x%' | {number}
x: 'center',
// 'center' | 'top' | 'bottom' | 'x%' | {number}
y: 'center',
// x2
// y2
width: '60%' // 自适应
// width: '60%'
// height // 自适应
},
// 数值合并方式,默认加和,可选为:
// 'sum' | 'average' | 'max' | 'min'
// mapValueCalculation: 'sum',
......
define(function (require) {
var zrUtil = require('zrender/core/util');
var geoProps = [
'x', 'y', 'x2', 'y2', 'width', 'height', 'map', 'roam', 'roamDetail', 'label', 'itemStyle'
];
var geoCoordsMap = {};
function createGeoFromMap(mapSeriesOpt) {
var geoOpt = {};
zrUtil.each(geoProps, function (propName) {
if (mapSeriesOpt[propName] != null) {
geoOpt[propName] = mapSeriesOpt[propName];
}
});
return geoOpt;
}
return function (option) {
// Save geoCoord
var mapSeries = [];
zrUtil.each(option.series, function (seriesOpt) {
if (seriesOpt.type === 'map') {
mapSeries.push(seriesOpt);
}
zrUtil.extend(geoCoordsMap, seriesOpt.geoCoord);
});
var newCreatedGeoOptMap = {};
zrUtil.each(mapSeries, function (seriesOpt) {
seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
// Put x, y, width, height, x2, y2 in the top level
zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
if (seriesOpt.markPoint) {
var markPoint = seriesOpt.markPoint;
// Convert name or geoCoord in markPoint to lng and lat
// For example
// { name: 'xxx', value: 10} Or
// { geoCoord: [lng, lat], value: 10} to
// { name: 'xxx', value: [lng, lat, 10]}
markPoint.data = zrUtil.map(markPoint.data, function (dataOpt) {
if (!zrUtil.isArray(dataOpt.value)) {
var geoCoord;
if (dataOpt.geoCoord) {
geoCoord = dataOpt.geoCoord;
}
else if (dataOpt.name) {
geoCoord = geoCoordsMap[dataOpt.name];
}
var newValue = geoCoord ? [geoCoord[0], geoCoord[1]] : [NaN, NaN];
if (dataOpt.value != null) {
newValue.push(dataOpt.value);
}
dataOpt.value = newValue;
}
return dataOpt;
});
// Convert map series which only has markPoint without data to scatter series
if (!(seriesOpt.data && seriesOpt.data.length)) {
if (!option.geo) {
option.geo = [];
}
var geoIndex = option.geo.length;
// Use same geo if multiple map series has same map type
var geoOpt = newCreatedGeoOptMap[seriesOpt.map];
if (!geoOpt) {
geoOpt = newCreatedGeoOptMap[seriesOpt.map] = createGeoFromMap(seriesOpt);
option.geo.push(geoOpt);
}
var scatterSeries = seriesOpt.markPoint;
scatterSeries.type = 'scatter';
scatterSeries.coordinateSystem = 'geo';
scatterSeries.geoIndex = geoIndex;
scatterSeries.name = seriesOpt.name;
option.series.splice(zrUtil.indexOf(option.series, seriesOpt), 1, scatterSeries);
}
}
});
};
});
\ No newline at end of file
......@@ -47,7 +47,7 @@ define(function(require) {
var data = this._data;
var params = seriesModelProto.getDataParams.call(this, dataIndex);
// FIXME toFixed?
params.percent = (data.get('value', dataIndex) / data.getSum('value')) * 100;
params.percent = (data.get('value', dataIndex) / data.getSum('value') * 100).toFixed(2);
params.$vars.push('percent');
return params;
......
......@@ -12,4 +12,6 @@ define(function (require) {
echarts.registerLayout(zrUtil.curry(
require('../layout/points'), 'radar'
));
echarts.registerPreprocessor(require('./radar/backwardCompat'));
});
\ No newline at end of file
......@@ -4,6 +4,9 @@ define(function(require) {
var createListFromArray = require('../helper/createListFromArray');
var SeriesModel = require('../../model/Series');
var zrUtil = require('zrender/core/util');
var numberUtil = require('../../util/number');
var linearMap = numberUtil.linearMap;
// Must have polar coordinate system
require('../../component/polar');
......@@ -15,7 +18,34 @@ define(function(require) {
dependencies: ['polar'],
getInitialData: function (option, ecModel) {
return createListFromArray(option.data, this, ecModel);
var indicators = option.indicator;
var data = createListFromArray(option.data, this, ecModel);
if (indicators) {
var indicatorMap = zrUtil.reduce(indicators, function (map, value, idx) {
map[value.name] = value;
return map;
}, {});
// Linear map to indicator min-max
// Only radius axis can be value
data = data.map(['radius'], function (radius, idx) {
var indicator = indicatorMap[data.getName(idx)];
if (indicator && indicator.max) {
// Map to 0-1 percent value
return linearMap(radius, [indicator.min || 0, indicator.max], [0, 1]);
}
});
// FIXME
var oldGetRawValue = data.getRawValue;
data.getRawValue = function (idx) {
var val = oldGetRawValue.call(this, idx);
var indicator = indicatorMap[data.getName(idx)];
if (indicator && indicator.max != null) {
return linearMap(val, [0, 1], [indicator.min || 0, indicator.max]);
}
};
}
return data;
},
defaultOption: {
......@@ -40,6 +70,13 @@ define(function(require) {
// symbolRotate: null,
// 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
showAllSymbol: false
// Indicators for each chart
// indicator: [{
// name: '',
// min: 0,
// max: 100
// }]
}
});
});
\ No newline at end of file
// Backward compat for radar chart in 2
define(function (require) {
var zrUtil = require('zrender/core/util');
var IntervalScale = require('../../scale/Interval');
var isArray = zrUtil.isArray;
var each = zrUtil.each;
var filter = zrUtil.filter;
return function (option) {
var polarOptList = option.polar;
var radiusAxisOptList = option.radiusAxis;
var angleAxisOptList = option.angleAxis;
var radarSeries = filter(option.series, function (seriesOpt) {
return seriesOpt.type === 'radar';
});
if (polarOptList && radarSeries.length) {
if (!isArray(polarOptList)) {
polarOptList = [polarOptList];
}
// In 2.0 there is no radiusAxis and angleAxis
if (!radiusAxisOptList) {
radiusAxisOptList = option.radiusAxis = [];
}
else if (!isArray(radiusAxisOptList)) {
radiusAxisOptList = [radiusAxisOptList];
}
if (!angleAxisOptList) {
angleAxisOptList = option.angleAxis = [];
}
else if (!isArray(angleAxisOptList)) {
angleAxisOptList = [angleAxisOptList];
}
each(polarOptList, function (polarOpt, idx) {
// Is 2.0 version
if (polarOpt.indicator) {
var indicators = zrUtil.map(polarOpt.indicator, function (indicator) {
var min = indicator.min;
var max = indicator.max;
if (max != null && max >= 0) {
min = 0;
}
return {
name: indicator.text,
min: min,
max: max
};
});
var radiusAxisOpt = zrUtil.find(radiusAxisOptList, function (radiusAxisOpt) {
return (radiusAxisOpt.polarIndex || 0) === idx;
});
var angleAxisOpt = zrUtil.find(angleAxisOptList, function (angleAxisOpt) {
return (angleAxisOpt.polarIndex || 0) === idx;
});
if (!radiusAxisOpt) {
radiusAxisOpt = {
type: 'value',
polarIndex: idx
};
radiusAxisOptList.push(radiusAxisOpt);
}
if (!angleAxisOpt) {
angleAxisOpt = {
type: 'category',
polarIndex: idx
};
angleAxisOptList.push(angleAxisOpt);
}
angleAxisOpt.data = zrUtil.map(polarOpt.indicator, function (indicator) {
var obj = {
value: indicator.text
};
var axisLabel = indicator.axisLabel;
if (axisLabel && axisLabel.textStyle) {
obj.textStyle = axisLabel.textStyle;
}
return obj;
});
angleAxisOpt.startAngle = polarOpt.startAngle || 90;
// axisLine in 2.0 is same like splitLine of angleAxis
if (polarOpt.axisLine) {
angleAxisOpt.splitLine = polarOpt.axisLine;
}
if (polarOpt.axisLabel) {
angleAxisOpt.axisLabel = polarOpt.axisLabel;
}
// splitLine in 2.0 is same with splitLine of radiusAxis
if (polarOpt.splitLine) {
radiusAxisOpt.splitLine = polarOpt.splitLine;
}
if (polarOpt.splitArea) {
radiusAxisOpt.splitArea = polarOpt.splitArea;
}
// Default show splitLine and splitArea
radiusAxisOpt.splitLine = radiusAxisOpt.splitLine || {};
radiusAxisOpt.splitArea = radiusAxisOpt.splitArea || {};
if (radiusAxisOpt.splitLine.show == null) {
radiusAxisOpt.splitLine.show = true;
}
if (radiusAxisOpt.splitArea.show == null) {
radiusAxisOpt.splitArea.show = true;
}
angleAxisOpt.boundaryGap = false;
// indicators will be normalized to 0 - 1
radiusAxisOpt.min = 0;
radiusAxisOpt.max = 1;
radiusAxisOpt.interval = 1 / (polarOpt.splitNumber || 5);
radiusAxisOpt.axisLine = {
show: false
};
radiusAxisOpt.axisLabel = {
show: false
};
radiusAxisOpt.axisTick = {
show: false
};
var radarSeriesOfSamePolar = filter(radarSeries, function (seriesOpt) {
return (seriesOpt.polarIndex || 0) === idx;
});
var dataGroupPyIndicator = zrUtil.map(indicators, function () {
return [];
});
// Find polar use current polarOpt
each(radarSeriesOfSamePolar, function (seriesOpt) {
seriesOpt.indicator = indicators;
// Data format in 2.0 radar is strange, like following
// data : [
// {
// value : [4300, 10000, 28000, 35000, 50000, 19000],
// name : '预算分配(Allocated Budget)'
// },
// {
// value : [5000, 14000, 28000, 31000, 42000, 21000],
// name : '实际开销(Actual Spending)'
// }
// ]
// Convert them to series
if (
seriesOpt.data[0] && zrUtil.isArray(seriesOpt.data[0].value)
) {
var dataList = seriesOpt.data;
var dataOpt = dataList[0];
seriesOpt.data = dataOpt.value;
seriesOpt.name = dataOpt.name;
for (var i = 1; i < dataList.length; i++) {
var dataOpt = dataList[i];
var newSeriesOpt = zrUtil.clone(seriesOpt, true);
option.series.push(zrUtil.extend(newSeriesOpt, {
name: dataOpt.name,
data: dataOpt.value,
indicator: indicators
}));
}
for (var i = 0; i < dataOpt.value.length; i++) {
for (var j = 0; j < dataList.length; j++) {
dataGroupPyIndicator[i].push(dataList[j].value[i]);
}
}
}
});
// Calculate min, max of each indicator from data
each(dataGroupPyIndicator, function (valuePerIndicator, idx) {
var intervalScale = new IntervalScale();
var min = Infinity;
var max = -Infinity;
var len = valuePerIndicator.length;
if (!len) {
return;
}
for (var i = 0; i < len; i++) {
min = Math.min(min, valuePerIndicator[i]);
max = Math.max(max, valuePerIndicator[i]);
}
intervalScale.setExtent(min, max);
intervalScale.niceExtent(polarOpt.splitNumber || 5);
var intervalExtent = intervalScale.getExtent();
if (indicators[idx].min == null) {
indicators[idx].min = intervalExtent[0];
}
if (indicators[idx].max == null) {
indicators[idx].max = intervalExtent[1];
}
});
}
});
}
};
});
\ No newline at end of file
......@@ -38,6 +38,10 @@ define(function (require) {
symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
// symbolRotate: null, // 图形旋转控制
large: false,
// Available when large is true
largeThreshold: 2000,
// label: {
// normal: {
// show: false
......
define(function (require) {
var SymbolDraw = require('../helper/SymbolDraw');
var LargeSymbolDraw = require('../helper/LargeSymbolDraw');
require('../../echarts').extendChartView({
type: 'scatter',
init: function () {
this._symbolDraw = new SymbolDraw();
this.group.add(this._symbolDraw.group);
this._normalSymbolDraw = new SymbolDraw();
this._largeSymbolDraw = new LargeSymbolDraw();
},
render: function (seriesModel, ecModel, api) {
this._symbolDraw.updateData(seriesModel.getData(), api);
var data = seriesModel.getData();
var largeSymbolDraw = this._largeSymbolDraw;
var normalSymbolDraw = this._normalSymbolDraw;
var group = this.group;
var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold')
? largeSymbolDraw : normalSymbolDraw;
this._symbolDraw = symbolDraw;
symbolDraw.updateData(data, api);
group.add(symbolDraw.group);
group.remove(
symbolDraw === largeSymbolDraw
? normalSymbolDraw.group : largeSymbolDraw.group
);
},
updateLayout: function () {
......
......@@ -175,6 +175,50 @@ define(function (require) {
*/
_splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
var splitAreaModel = angleAxisModel.getModel('splitArea');
var areaStyleModel = splitAreaModel.getModel('areaStyle');
var areaColors = areaStyleModel.get('color');
var lineCount = 0;
areaColors = areaColors instanceof Array ? areaColors : [areaColors];
var splitAreas = [];
var RADIAN = Math.PI / 180;
var prevAngle = -ticksAngles[0] * RADIAN;
var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
var clockwise = angleAxisModel.get('clockwise');
for (var i = 1; i < ticksAngles.length; i++) {
var colorIndex = (lineCount++) % areaColors.length;
splitAreas[colorIndex] = splitAreas[colorIndex] || [];
splitAreas[colorIndex].push(new graphic.Sector({
shape: {
cx: polar.cx,
cy: polar.cy,
r0: r0,
r: r1,
startAngle: prevAngle,
endAngle: -ticksAngles[i] * RADIAN,
clockwise: clockwise
},
silent: true
}));
prevAngle = -ticksAngles[i] * RADIAN;
}
// Simple optimization
// Batching the lines if color are the same
for (var i = 0; i < splitAreas.length; i++) {
this.group.add(graphic.mergePath(splitAreas[i], {
style: zrUtil.defaults({
fill: areaColors[i % areaColors.length]
}, areaStyleModel.getAreaStyle()),
silent: true
}));
}
}
});
});
\ No newline at end of file
......@@ -207,6 +207,43 @@ define(function (require) {
*/
_splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
var splitAreaModel = radiusAxisModel.getModel('splitArea');
var areaStyleModel = splitAreaModel.getModel('areaStyle');
var areaColors = areaStyleModel.get('color');
var lineCount = 0;
areaColors = areaColors instanceof Array ? areaColors : [areaColors];
var splitAreas = [];
var prevRadius = ticksCoords[0];
for (var i = 1; i < ticksCoords.length; i++) {
var colorIndex = (lineCount++) % areaColors.length;
splitAreas[colorIndex] = splitAreas[colorIndex] || [];
splitAreas[colorIndex].push(new graphic.Sector({
shape: {
cx: polar.cx,
cy: polar.cy,
r0: prevRadius,
r: ticksCoords[i],
startAngle: 0,
endAngle: Math.PI * 2
},
silent: true
}));
prevRadius = ticksCoords[i];
}
// Simple optimization
// Batching the lines if color are the same
for (var i = 0; i < splitAreas.length; i++) {
this.group.add(graphic.mergePath(splitAreas[i], {
style: zrUtil.defaults({
fill: areaColors[i % areaColors.length]
}, areaStyleModel.getAreaStyle()),
silent: true
}));
}
}
});
});
\ No newline at end of file
......@@ -120,6 +120,8 @@ define(function (require) {
// Only visual color of each item will be used. It can be encoded by dataRange
// But visual color of series is used in symbol drawing
//
// Visual color for each series is for the symbol draw
var visualColor = data.getItemVisual(dataIdx, 'color', true);
itemStyleModel = itemModel.getModel(itemStyleAccessPath);
......
......@@ -37,6 +37,10 @@ define(function (require) {
return symbolPath;
}
function isSymbolArrow(symbol) {
return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow';
}
function updateSymbolBeforeLineUpdate () {
var line = this;
var symbolFrom = line.__symbolFrom;
......@@ -53,10 +57,10 @@ define(function (require) {
symbolTo.attr('position', toPos);
// Rotate the arrow
// FIXME Hard coded ?
if (symbolTo.type === 'arrow') {
if (isSymbolArrow(symbolTo)) {
symbolTo.attr('rotation', tangentRotation(fromPos, toPos));
}
if (symbolFrom.type === 'arrow') {
if (isSymbolArrow(symbolFrom)) {
symbolFrom.attr('rotation', tangentRotation(toPos, fromPos));
}
label.attr('position', toPos);
......
......@@ -5,7 +5,6 @@ define(function(require) {
var echarts = require('../echarts');
var graphic = require('../util/graphic');
var layout = require('../util/layout');
var formatUtil = require('../util/format');
// Model
echarts.extendComponentModel({
......
......@@ -123,7 +123,8 @@ define(function (require) {
zr.on('mousemove', this._mouseMove, this);
zr.on('mouseout', this._hide, this);
this._tooltipContent = new TooltipContent(api.getDom(), api);
var tooltipContent = new TooltipContent(api.getDom(), api);
this._tooltipContent = tooltipContent;
},
render: function (tooltipModel, ecModel, api) {
......@@ -165,7 +166,9 @@ define(function (require) {
// seriesIndex
};
this._tooltipContent.update();
var tooltipContent = this._tooltipContent;
tooltipContent.update();
tooltipContent.enterable = tooltipModel.get('enterbale');
/**
* @type {Object.<string, Array>}
......@@ -234,7 +237,7 @@ define(function (require) {
_mouseMove: function (e) {
var el = e.target;
var tooltipModel = this._tooltipModel;
var trigger = tooltipModel.get('trigger');
var globalTrigger = tooltipModel.get('trigger');
var ecModel = this._ecModel;
if (!tooltipModel) {
......@@ -250,7 +253,7 @@ define(function (require) {
var dataIndex = el.dataIndex;
var itemModel = hostModel.getData().getItemModel(dataIndex);
// Series or single data may use item trigger when global is axis trigger
if ((itemModel.get('tooltip.trigger') || trigger) === 'axis') {
if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') {
this._showAxisTooltip(tooltipModel, ecModel, e);
}
else {
......@@ -262,7 +265,7 @@ define(function (require) {
}
}
else {
if (trigger === 'item') {
if (globalTrigger === 'item') {
this._hide();
}
else {
......@@ -282,7 +285,6 @@ define(function (require) {
_showAxisTooltip: function (tooltipModel, ecModel, e) {
var axisPointerModel = tooltipModel.getModel('axisPointer');
var axisPointerType = axisPointerModel.get('type');
var api = this._api;
if (axisPointerType === 'cross') {
var el = e.target;
......@@ -646,18 +648,20 @@ define(function (require) {
var val = value[baseAxis.dim === 'x' ? 0 : 1];
var dataIndex = data.indexOfNearest(baseAxis.dim, val);
// FIXME Not here
var lastHover = this._lastHover;
if (lastHover.seriesIndex != null) {
if (lastHover.seriesIndex != null && !contentNotChange) {
this._api.dispatch({
type: 'downplay',
seriesIndex: lastHover.seriesIndex,
dataIndex: lastHover.dataIndex
});
}
// Dispatch highlight action
if (!contentNotChange) {
var seriesIndices = zrUtil.map(seriesList, function (series) {
return series.seriesIndex;
});
// Dispatch highlight action
this._api.dispatch({
type: 'highlight',
seriesIndex: seriesIndices,
......@@ -665,6 +669,7 @@ define(function (require) {
});
lastHover.seriesIndex = seriesIndices;
lastHover.dataIndex = dataIndex;
}
if (baseAxis && rootTooltipModel.get('showContent')) {
......@@ -677,9 +682,9 @@ define(function (require) {
});
// If only one series
// FIXME
if (paramsList.length === 1) {
paramsList = paramsList[0];
}
// if (paramsList.length === 1) {
// paramsList = paramsList[0];
// }
tooltipContent.show(rootTooltipModel);
......
......@@ -19,8 +19,9 @@ define(function (require) {
* @inner
*/
function assembleTransition(duration) {
var transitionText = 'left ' + duration + 's,'
+ 'top ' + duration + 's';
var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)';
var transitionText = 'left ' + duration + 's ' + transitionCurve + ','
+ 'top ' + duration + 's ' + transitionCurve;
return zrUtil.map(vendors, function (vendorPrefix) {
return vendorPrefix + 'transition:' + transitionText;
}).join(';');
......@@ -110,20 +111,45 @@ define(function (require) {
this.el = el;
el.style.left = api.getWidth() / 2 + 'px';
el.style.top = api.getHeight() / 2 + 'px';
this._x = api.getWidth() / 2;
this._y = api.getHeight() / 2;
container.appendChild(el);
this._container = container;
this._show = false;
/**
* @private
*/
this._hideTimeout;
var self = this;
el.onmouseover = function () {
// clear the timeout in hideLater and keep showing tooltip
if (self.enterable) {
clearTimeout(self._hideTimeout);
self._show = true;
}
self._inContent = true;
};
el.onmouseout = function () {
if (self.enterable) {
if (self._show) {
self.hideLater(self._hideDelay);
}
}
self._inContent = false;
};
}
TooltipContent.prototype = {
constructor: TooltipContent,
enterable: true,
/**
* Update when tooltip is rendered
*/
......@@ -143,7 +169,9 @@ define(function (require) {
show: function (tooltipModel) {
clearTimeout(this._hideTimeout);
this.el.style.cssText = gCssText + assembleCssText(tooltipModel);
this.el.style.cssText = gCssText + assembleCssText(tooltipModel)
// http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
+ ';left:' + this._x + 'px;top:' + this._y + 'px;';
this._show = true;
},
......@@ -158,22 +186,30 @@ define(function (require) {
var style = this.el.style;
style.left = x + 'px';
style.top = y + 'px';
this._x = x;
this._y = y;
},
hide: function () {
if (this._show) {
this.el.style.display = 'none';
}
this._show = false;
},
// showLater: function ()
hideLater: function (time) {
if (this._show && !(this._inContent && this.enterable)) {
if (time) {
// Set show false to avoid invoke hideLater mutiple times
this._hideDelay = time;
this._show = false;
this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time);
}
else {
this.hide();
}
}
},
isShow: function () {
......
......@@ -31,9 +31,6 @@ define(function (require) {
// 数据孤岛内容格式器
islandFormatter: '{a} <br/>{b} : {c}',
// 显示延迟,添加显示延迟可以避免频繁切换,单位ms
showDelay: 20,
// 隐藏延迟,单位ms
hideDelay: 100,
......@@ -94,7 +91,8 @@ define(function (require) {
}
},
textStyle: {
color: '#fff'
color: '#fff',
fontSize: 14
}
}
});
......
......@@ -120,8 +120,9 @@ define(function (require) {
dataToCoord: function (data, clamp) {
data = this.scale.normalize(data);
var extent = this.getExtent();
if (this.onBand) {
fixExtentWithBands(extent, this.scale.count());
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
fixExtentWithBands(extent, scale.count());
}
return linearMap(data, [0, 1], extent, clamp);
......
......@@ -43,6 +43,16 @@ define(function (require) {
}
scale.setExtent(min, max);
scale.niceExtent(model.get('splitNumber'), fixMin, fixMax);
// If some one specified the min, max. And the default calculated interval
// is not good enough. He can specify the interval. It is often appeared
// in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
// to be 60.
// FIXME
var interval = model.get('interval');
if (interval != null) {
scale.setInterval && scale.setInterval(interval);
}
};
/**
......
......@@ -3,10 +3,12 @@ define(function (require) {
var zrUtil = require('zrender/core/util');
function getName(obj) {
if (typeof obj === 'string') {
if (zrUtil.isObject(obj) && obj.value != null) {
return obj.value;
}
else {
return obj;
}
return obj.value;
}
/**
* Get categories
......
......@@ -23,14 +23,12 @@ define(function (require) {
y: 'center',
// 自适应
// width:,
// height:,
// x2
// y2
width: '70%',
// 默认 height 会根据 width 自适应
// height: 'auto',
// Map type
map: '',
......
......@@ -15,20 +15,29 @@ define(function (require) {
* @param {module:echarts/ExtensionAPI} api
*/
function resizeGeo (geoModel, api) {
var locModel = geoModel;
if (geoModel.type === 'series.map') {
locModel = geoModel.getModel('mapLocation');
}
var rect = this.getBoundingRect();
var width = geoModel.get('width');
var height = geoModel.get('height');
if (!width && !height) {
var viewportWidth = api.getWidth();
var viewportHeight = api.getHeight();
if (rect.width / viewportWidth > rect.height / viewportHeight) {
width = viewportWidth * 0.8;
}
else {
height = viewportHeight * 0.8;
}
}
var viewRect = layout.parsePositionInfo({
x: locModel.get('x'),
y: locModel.get('y'),
x2: locModel.get('x2'),
y2: locModel.get('y2'),
width: locModel.get('width'),
height: locModel.get('height'),
x: geoModel.get('x'),
y: geoModel.get('y'),
x2: geoModel.get('x2'),
y2: geoModel.get('y2'),
width: width,
height: height,
// 0.75 rate
aspect: rect.width / rect.height * 0.75
}, {
......
......@@ -119,11 +119,12 @@ define(function (require) {
setPolarAxisFromSeries(polarList, ecModel, api);
// Fix extent of category angle axis
// FIXME
zrUtil.each(polarList, function (polar) {
var angleAxis = polar.getAngleAxis();
if (angleAxis.type === 'category' && !angleAxis.onBand) {
var extent = angleAxis.getExtent();
var diff = 360 / (angleAxis.scale.count() + 1);
var diff = 360 / angleAxis.scale.count();
angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
angleAxis.setExtent(extent[0], extent[1]);
}
......
......@@ -27,12 +27,17 @@ define(function (require) {
var IMMUTABLE_PROPERTIES = [
'stackedOn', '_nameList', '_idList',
'_rawData', '_valueProp', '_optionModels'
'_rawData', '_valueProp', '_optionModels',
// Get raw value may be wrapped by creator
// FIXME
'getRawValue'
];
var transferImmuProperties = function (a, b) {
zrUtil.each(IMMUTABLE_PROPERTIES, function (propName) {
if (b.hasOwnProperty(propName)) {
a[propName] = b[propName];
}
});
};
......
......@@ -28,6 +28,13 @@ define(function (require) {
// TODO Transform first or filter first
var PROCESSOR_STAGES = ['transform', 'filter', 'statistic'];
/**
* @module echarts~MessageCenter
*/
function MessageCenter() {
Eventful.call(this);
}
zrUtil.mixin(MessageCenter, Eventful);
/**
* @module echarts~ECharts
*/
......@@ -105,6 +112,12 @@ define(function (require) {
Eventful.call(this);
/**
* @type {module:echarts~MessageCenter}
* @private
*/
this._messageCenter = new MessageCenter();
// Init mouse events
this._initEvents();
......@@ -313,7 +326,7 @@ define(function (require) {
*/
echartsProto.resize = function () {
this._zr.resize();
this._update();
updateMethods.update.call(this);
};
/**
......@@ -346,7 +359,7 @@ define(function (require) {
// Convert type to eventType
var eventObj = zrUtil.extend({}, payload);
eventObj.type = actionInfo.event || eventObj.type;
this.trigger(eventObj.type, eventObj);
this._messageCenter.trigger(eventObj.type, eventObj);
}
}
};
......@@ -553,6 +566,12 @@ define(function (require) {
}
}, this);
}, this);
zrUtil.each(eventActionMap, function (actionType, eventType) {
this._messageCenter.on(eventType, function (event) {
this.trigger(eventType, event);
}, this);
}, this);
};
/**
......@@ -674,7 +693,8 @@ define(function (require) {
// Connecting
zrUtil.each(eventActionMap, function (actionType, eventType) {
chart.on(eventType, function (event) {
// FIXME
chart._messageCenter.on(eventType, function (event) {
if (connectedGroups[chart.group]) {
chart.__connectedActionDispatching = true;
for (var id in instances) {
......
......@@ -2,13 +2,7 @@
define(function (require) {
var zrUtil = require('zrender/core/util');
var POSSIBLE_STYLES = [
'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
'chordStyle', 'label', 'labelLine'
];
var each = zrUtil.each;
var compatStyle = require('./helper/compatStyle');
function get(opt, path) {
path = path.split(',');
......@@ -38,72 +32,12 @@ define(function (require) {
}
}
function compatItemStyle(opt) {
var itemStyleOpt = opt.itemStyle;
if (itemStyleOpt) {
each(POSSIBLE_STYLES, function (styleName) {
var normalItemStyleOpt = itemStyleOpt.normal;
var emphasisItemStyleOpt = itemStyleOpt.emphasis;
if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
opt[styleName] = opt[styleName] || {};
if (!opt[styleName].normal) {
opt[styleName].normal = normalItemStyleOpt[styleName];
}
else {
zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
}
normalItemStyleOpt[styleName] = null;
}
if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
opt[styleName] = opt[styleName] || {};
if (!opt[styleName].emphasis) {
opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
}
else {
zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
}
emphasisItemStyleOpt[styleName] = null;
}
});
}
}
return function (option) {
zrUtil.each(option.series, function (seriesOpt) {
compatItemStyle(seriesOpt);
var data = seriesOpt.data;
if (data) {
for (var i = 0; i < data.length; i++) {
compatItemStyle(data[i]);
}
// mark point data
var markPoint = seriesOpt.markPoint;
if (markPoint && markPoint.data) {
var mpData = markPoint.data;
for (var i = 0; i < mpData.length; i++) {
compatItemStyle(mpData[i]);
}
}
// mark line data
var markLine = seriesOpt.markLine;
if (markLine && markLine.data) {
var mlData = markLine.data;
for (var i = 0; i < mlData.length; i++) {
if (zrUtil.isArray(mlData[i])) {
compatItemStyle(mlData[i][0]);
compatItemStyle(mlData[i][1]);
}
else {
compatItemStyle(mlData[i]);
}
}
}
}
var seriesType = seriesOpt.type;
if (seriesType === 'map') {
seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
}
compatStyle(seriesOpt);
if (seriesType === 'pie' || seriesType === 'gauge') {
if (seriesOpt.clockWise != null) {
seriesOpt.clockwise = seriesOpt.clockWise;
......
define(function (require) {
var zrUtil = require('zrender/core/util');
var POSSIBLE_STYLES = [
'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
'chordStyle', 'label', 'labelLine'
];
function compatItemStyle(opt) {
var itemStyleOpt = opt.itemStyle;
if (itemStyleOpt) {
zrUtil.each(POSSIBLE_STYLES, function (styleName) {
var normalItemStyleOpt = itemStyleOpt.normal;
var emphasisItemStyleOpt = itemStyleOpt.emphasis;
if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
opt[styleName] = opt[styleName] || {};
if (!opt[styleName].normal) {
opt[styleName].normal = normalItemStyleOpt[styleName];
}
else {
zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
}
normalItemStyleOpt[styleName] = null;
}
if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
opt[styleName] = opt[styleName] || {};
if (!opt[styleName].emphasis) {
opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
}
else {
zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
}
emphasisItemStyleOpt[styleName] = null;
}
});
}
}
return function (seriesOpt) {
compatItemStyle(seriesOpt);
var data = seriesOpt.data;
if (data) {
for (var i = 0; i < data.length; i++) {
compatItemStyle(data[i]);
}
// mark point data
var markPoint = seriesOpt.markPoint;
if (markPoint && markPoint.data) {
var mpData = markPoint.data;
for (var i = 0; i < mpData.length; i++) {
compatItemStyle(mpData[i]);
}
}
// mark line data
var markLine = seriesOpt.markLine;
if (markLine && markLine.data) {
var mlData = markLine.data;
for (var i = 0; i < mlData.length; i++) {
if (zrUtil.isArray(mlData[i])) {
compatItemStyle(mlData[i][0]);
compatItemStyle(mlData[i][1]);
}
else {
compatItemStyle(mlData[i]);
}
}
}
}
};
});
\ No newline at end of file
......@@ -21,6 +21,21 @@ define(function (require) {
_interval: 0,
setExtent: function (start, end) {
var thisExtent = this._extent;
if (!isNaN(start)) {
thisExtent[0] = start;
}
if (!isNaN(end)) {
thisExtent[1] = end;
}
if (thisExtent[0] === thisExtent[1]) {
// Expand extent
var expandSize = thisExtent[0] / 2 || 1;
thisExtent[0] -= expandSize;
thisExtent[1] += expandSize;
}
},
/**
* Get interval
*/
......@@ -31,6 +46,13 @@ define(function (require) {
return this._interval;
},
/**
* Set interval
*/
setInterval: function (interval) {
this._interval = interval;
},
/**
* @return {Array.<number>}
*/
......@@ -128,7 +150,7 @@ define(function (require) {
* @param {boolean} [fixMax=false]
*/
niceExtent: function (approxTickNum, fixMin, fixMax) {
this.niceTicks(approxTickNum);
this.niceTicks(approxTickNum, fixMin, fixMax);
var extent = this._extent;
var interval = this._interval;
......
......@@ -56,7 +56,7 @@ define(function (require) {
setExtent: function (start, end) {
start = mathLog(start) / mathLog(LOG_BASE);
end = mathLog(end) / mathLog(LOG_BASE);
scaleProto.setExtent.call(this, start, end);
intervalScaleProto.setExtent.call(this, start, end);
},
/**
......
......@@ -32,12 +32,15 @@ define(function (require) {
};
/**
* Normalize value to linear [0, 1]
* Normalize value to linear [0, 1], return 0.5 if extent span is 0
* @param {number} val
* @return {number}
*/
scaleProto.normalize = function (val) {
var extent = this._extent;
if (extent[1] === extent[0]) {
return 0.5;
}
return (val - extent[0]) / (extent[1] - extent[0]);
};
......@@ -59,6 +62,8 @@ define(function (require) {
var extent = this._extent;
other[0] < extent[0] && (extent[0] = other[0]);
other[1] > extent[1] && (extent[1] = other[1]);
// Set again
this.setExtent(extent[0], extent[1]);
};
/**
......@@ -82,12 +87,6 @@ define(function (require) {
if (!isNaN(end)) {
thisExtent[1] = end;
}
if (thisExtent[0] === thisExtent[1]) {
// Expand extent
var expandSize = thisExtent[0] / 2;
thisExtent[0] -= expandSize;
thisExtent[1] += expandSize;
}
};
/**
......
......@@ -71,7 +71,7 @@ define(function(require) {
beforeBrush: function () {
var style = this.style;
if (style.textPosition === 'inside') {
style.textPosition = ['50%', '40%'];
style.textPosition = ['50%', '35%'];
style.textAlign = 'center';
style.textBaseline = 'middle';
}
......@@ -172,97 +172,112 @@ define(function(require) {
var symbolShapeMakers = {
line: function (x, y, w, h) {
line: function (x, y, w, h, shape) {
// FIXME
return {
x1: x,
y1: y + h / 2,
x2: x + w,
y2: y + h / 2
};
shape.x1 = x;
shape.y1 = y + h / 2;
shape.x2 = x + w;
shape.y2 = y + h / 2;
},
rect: function (x, y, w, h) {
return {
x: x,
y: y,
width: w,
height: h
};
rect: function (x, y, w, h, shape) {
shape.x = x;
shape.y = y;
shape.width = w;
shape.height = h;
},
roundRect: function (x, y, w, h, r) {
return {
x: x,
y: y,
width: w,
height: h,
r: r || Math.min(w, h) / 4
};
roundRect: function (x, y, w, h, shape) {
shape.x = x;
shape.y = y;
shape.width = w;
shape.height = h;
shape.r = Math.min(w, h) / 4;
},
square: function (x, y, size) {
return {
x: x,
y: y,
width: size / 2,
height: size / 2
};
square: function (x, y, w, h, shape) {
var size = Math.min(w, h);
shape.x = x;
shape.y = y;
shape.width = size;
shape.height = size;
},
circle: function (x, y, w, h) {
circle: function (x, y, w, h, shape) {
// Put circle in the center of square
var size = Math.min(w, h);
return {
cx: x + w / 2,
cy: y + h / 2,
r: size / 2
};
shape.cx = x + w / 2;
shape.cy = y + h / 2;
shape.r = Math.min(w, h) / 2;
},
diamond: function (x, y, w, h) {
return {
cx: x + w / 2,
cy: y + h / 2,
width: w,
height: h
};
diamond: function (x, y, w, h, shape) {
shape.cx = x + w / 2;
shape.cy = y + h / 2;
shape.width = w;
shape.height = h;
},
pin: function (x, y, w, h) {
return {
x: x + w / 2,
// FIXME Why not y + h ?
y: y + h / 2,
width: w,
height: h
};
pin: function (x, y, w, h, shape) {
shape.x = x + w / 2;
shape.y = y + h / 2;
shape.width = w;
shape.height = h;
},
arrow: function (x, y, w, h) {
return {
x: x + w / 2,
y: y + h / 2,
width: w,
height: h
};
arrow: function (x, y, w, h, shape) {
shape.x = x + w / 2;
shape.y = y + h / 2;
shape.width = w;
shape.height = h;
},
triangle: function (x, y, w, h) {
return {
cx: x + w / 2,
cy: y + h / 2,
width: w,
height: h
};
triangle: function (x, y, w, h, shape) {
shape.cx = x + w / 2;
shape.cy = y + h / 2;
shape.width = w;
shape.height = h;
}
};
var symbolBuildProxies = {};
for (var name in symbolCtors) {
symbolBuildProxies[name] = new symbolCtors[name]();
}
var Symbol = graphic.extendShape({
type: 'symbol',
shape: {
symbolType: '',
x: 0,
y: 0,
width: 0,
height: 0
},
buildPath: function (ctx, shape) {
var proxySymbol = symbolBuildProxies[shape.symbolType];
if (proxySymbol) {
symbolShapeMakers[shape.symbolType](
shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
);
proxySymbol.buildPath(ctx, proxySymbol.shape);
}
}
});
// Provide setColor helper method to avoid determine if set the fill or stroke outside
var symbolPathSetColor = function (color) {
if (this.type !== 'image') {
var symbolStyle = this.style;
if (this.__isEmptyBrush) {
var symbolShape = this.shape;
if (symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
......@@ -270,6 +285,7 @@ define(function(require) {
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty();
}
};
var symbolUtil = {
......@@ -304,19 +320,18 @@ define(function(require) {
symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
}
else {
// Default rect
if (!symbolShapeMakers[symbolType]) {
symbolType = 'rect';
}
symbolPath = new symbolCtors[symbolType]({
shape: symbolShapeMakers[symbolType](x, y, w, h)
});
symbolPath = new Symbol({
shape: {
symbolType: symbolType,
x: x,
y: y,
width: w,
height: h
}
var symbolStyle = symbolPath.style;
if (isEmpty) {
symbolStyle.set({
fill: '#fff',
lineWidth: 2
});
}
......@@ -327,39 +342,6 @@ define(function(require) {
symbolPath.setColor(color);
return symbolPath;
},
/**
* Get symbol shape object by given x, y, w, h
* @param {string} symbolType
* @param {number} x
* @param {number} y
* @param {number} w
* @param {number} h
* @return {Object}
*/
getSymbolShape: function (symbolType, x, y, w, h) {
if (symbolType.indexOf('empty') === 0) {
symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
}
if (symbolType.indexOf('image://') === 0) {
return {
style: {
x: x,
y: y,
width: w,
height: h
}
};
}
else if (symbolType.indexOf('path://') !== 0) {
if (!symbolShapeMakers[symbolType]) {
symbolType = 'rect';
}
return {
shape: symbolShapeMakers[symbolType](x, y, w, h)
};
}
}
};
......
......@@ -2,10 +2,9 @@
define(function (require) {
return function (seriesType, ecModel) {
var offset = 0;
var colorList = ecModel.get('color');
ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
var dataAll = seriesModel.getRawData();
if (!ecModel.isSeriesFiltered(seriesModel)) {
var data = seriesModel.getData();
......@@ -13,13 +12,12 @@ define(function (require) {
var itemModel = data.getItemModel(idx);
var rawIdx = data.getRawIndex(idx);
var color = itemModel.get('itemStyle.normal.color')
|| colorList[(offset + rawIdx) % colorList.length];
|| colorList[rawIdx % colorList.length];
// Legend may use the visual info in data before processed
dataAll.setItemVisual(rawIdx, 'color', color);
data.setItemVisual(idx, 'color', color);
});
}
offset += dataAll.count();
});
};
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册