提交 bf2f13f5 编写于 作者: L lang

Enhancement

上级 e5f2822d
......@@ -7,6 +7,15 @@ define(function (require) {
zrUtil.extend(require('../../model/Model').prototype, require('./barItemStyle'));
function fixLayoutWithLineWidth(layout, lineWidth) {
var signX = layout.width > 0 ? 1 : -1;
var signY = layout.height > 0 ? 1 : -1;
layout.x += signX * lineWidth / 2;
layout.y += signY * lineWidth / 2;
layout.width -= signX * lineWidth;
layout.height -= signY * lineWidth;
}
return require('../../echarts').extendChartView({
type: 'bar',
......@@ -32,6 +41,8 @@ define(function (require) {
var enableAnimation = ecModel.get('animation');
var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth'];
data.diff(oldData)
.add(function (dataIndex) {
// 空数据
......@@ -40,6 +51,10 @@ define(function (require) {
}
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)
});
......@@ -68,8 +83,12 @@ define(function (require) {
return;
}
var layout = data.getItemLayout(newIndex);
var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0;
fixLayoutWithLineWidth(layout, lineWidth);
api.updateGraphicEl(rect, {
shape: data.getItemLayout(newIndex)
shape: layout
});
data.setItemGraphicEl(newIndex, rect);
......
......@@ -37,7 +37,7 @@ define(function (require) {
z2: 100
});
symbolPath.attr('scale', [0, 0]);
this.add(symbolPath);
var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
api.initGraphicEl(symbolPath, {
......@@ -45,6 +45,8 @@ define(function (require) {
});
this._symbolType = symbolType;
this.add(symbolPath);
};
/**
......@@ -72,6 +74,7 @@ define(function (require) {
// Update common properties
var normalStyleAccessPath = ['itemStyle', 'normal'];
var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
symbolProto._updateCommon = function (data, idx) {
var symbolPath = this.childAt(0);
var seriesModel = data.hostModel;
......@@ -115,6 +118,25 @@ define(function (require) {
}
graphic.setHoverStyle(symbolPath, hoverStyle);
var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
function onEmphasis() {
this.animateTo({
scale: [size[0] * 1.1, size[1] * 1.1]
}, 400, 'elasticOut');
}
function onNormal() {
this.animateTo({
scale: size
}, 400, 'elasticOut');
}
if (itemModel.get('hoverAnimation')) {
symbolPath.on('mouseover', onEmphasis)
.on('mouseout', onNormal)
.on('emphasis', onEmphasis)
.on('normal', onNormal);
}
};
symbolProto.fadeOut = function (cb, api) {
......
......@@ -114,7 +114,7 @@ define(function(require) {
// 多个散点图系列在同一个地区的时候
return {
dimensions: [
{name: 'lon'},
{name: 'lng'},
{name: 'lat'},
{name: 'value'}
]
......
......@@ -20,6 +20,8 @@ define(function(require) {
z: 2, // 二级层叠
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
hoverAnimation: true,
// stack: null
xAxisIndex: 0,
yAxisIndex: 0,
......
......@@ -3,7 +3,6 @@ define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var vector = require('zrender/core/vector');
var SymbolDraw = require('../helper/SymbolDraw');
var lineAnimationDiff = require('./lineAnimationDiff');
var graphic = require('../../util/graphic');
......
......@@ -60,6 +60,11 @@ define(function (require) {
var layout = data.getItemLayout(idx);
if (!layout || !layout.point) {
// Not exists in map
return;
}
var point = layout.point;
var offset = layout.offset;
......
......@@ -70,6 +70,8 @@ define(function(require) {
zlevel: 0,
z: 2,
legendHoverLink: true,
hoverAnimation: true,
// 默认全局居中
center: ['50%', '50%'],
radius: [0, '75%'],
......
......@@ -216,6 +216,27 @@ define(function (require) {
seriesModel.get('selectedOffset'),
seriesModel.ecModel.get('animation')
);
function onEmphasis() {
sector.animateTo({
shape: {
r: layout.r + 10
}
}, 300, 'elasticOut');
}
function onNormal() {
sector.animateTo({
shape: {
r: layout.r
}
}, 300, 'elasticOut');
}
if (itemModel.get('hoverAnimation')) {
sector.on('mouseover', onEmphasis)
.on('mouseout', onNormal)
.on('emphasis', onEmphasis)
.on('normal', onNormal);
}
};
zrUtil.inherits(PiePiece, graphic.Group);
......
......@@ -26,6 +26,7 @@ define(function (require) {
z: 2, // 二级层叠
legendHoverLink: true,
hoverAnimation: true,
// Cartesian coordinate system
xAxisIndex: 0,
yAxisIndex: 0,
......
......@@ -146,7 +146,8 @@ define(function (require) {
},
style: {
strokeNoScale: true
}
},
culling: true
});
polygon.setStyle(itemStyle);
......
......@@ -25,7 +25,7 @@ define(function (require) {
function mousemove(e) {
if (this._dragging) {
var rawE = e.event;
rawE.preventDefault();
rawE.preventDefault && rawE.preventDefault();
var x = e.offsetX;
var y = e.offsetY;
......
......@@ -25,7 +25,8 @@ define(function(require) {
});
function getAxisType(axisDim, option) {
return option.type || (axisDim === 'x' ? 'category' : 'value');
// Default xAxis and axis with data is category axis
return option.type || ((axisDim === 'x' || option.data) ? 'category' : 'value');
}
zrUtil.merge(AxisModel.prototype, require('../axisModelCommonMixin'));
......
......@@ -29,7 +29,7 @@ define(function (require) {
* @param {Array.<string>}
* @readOnly
*/
this.dimensions = ['lon', 'lat'];
this.dimensions = ['lng', 'lat'];
this._nameCoordMap = {};
......@@ -147,7 +147,7 @@ define(function (require) {
*/
dataToPoints: function (data) {
var item = [];
return data.mapArray(['lon', 'lat'], function (lon, lat) {
return data.mapArray(['lng', 'lat'], function (lon, lat) {
item[0] = lon;
item[1] = lat;
return this.dataToPoint(item);
......
......@@ -50,9 +50,9 @@ define(function (require) {
var prevX = encodeOffsets[0];
var prevY = encodeOffsets[1];
for (var i = 0; i < coordinate.length; i+=2) {
for (var i = 0; i < coordinate.length; i += 2) {
var x = coordinate.charCodeAt(i) - 64;
var y = coordinate.charCodeAt(i+1) - 64;
var y = coordinate.charCodeAt(i + 1) - 64;
// ZigZag decoding
x = (x >> 1) ^ (-(x & 1));
y = (y >> 1) ^ (-(y & 1));
......@@ -91,7 +91,10 @@ define(function (require) {
decode(geoJson);
return zrUtil.map(geoJson.features, function (featureObj) {
return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
// Output of mapshaper may have geometry null
return featureObj.geometry && featureObj.properties;
}), function (featureObj) {
var properties = featureObj.properties;
var geometry = featureObj.geometry;
......
......@@ -13,7 +13,7 @@ define(function (require) {
var ComponentView = require('./view/Component');
var ChartView = require('./view/Chart');
var Scale = require('./scale/Scale');
// var Scale = require('./scale/Scale');
var zrender = require('zrender');
var zrUtil = require('zrender/core/util');
......@@ -65,7 +65,7 @@ define(function (require) {
* @type {Object}
* @private
*/
this._theme = zrUtil.clone(theme);
this._theme = zrUtil.clone(theme, true);
/**
* @type {Array.<module:echarts/view/Chart>}
......
......@@ -153,60 +153,58 @@ define(function(require) {
var barMinHeight = seriesModel.get('barMinHeight') || 0;
if (data.type === 'list') {
var valueAxisStart = baseAxis.onZero
? valueAxis.dataToCoord(0) : valueAxis.getExtent()[0];
var coords = cartesian.dataToPoints(data, true);
lastStackCoords[stackId] = lastStackCoords[stackId] || [];
data.each(valueAxis.dim, function (value, idx) {
// 空数据
if (isNaN(value)) {
return;
}
if (!lastStackCoords[stackId][idx]) {
lastStackCoords[stackId][idx] = {
// Positive stack
p: valueAxisStart,
// Negative stack
n: valueAxisStart
};
}
var sign = value >= 0 ? 'p' : 'n';
var coord = coords[idx];
var lastCoord = lastStackCoords[stackId][idx][sign];
var x, y, width, height;
if (valueAxis.isHorizontal()) {
x = lastCoord;
y = coord[1] + columnOffset;
width = coord[0] - lastCoord;
height = columnWidth;
if (Math.abs(width) < barMinHeight) {
width = (width < 0 ? -1 : 1) * barMinHeight;
}
var valueAxisStart = baseAxis.onZero
? valueAxis.dataToCoord(0) : valueAxis.getExtent()[0];
var coords = cartesian.dataToPoints(data, true);
lastStackCoords[stackId] = lastStackCoords[stackId] || [];
data.each(valueAxis.dim, function (value, idx) {
// 空数据
if (isNaN(value)) {
return;
}
if (!lastStackCoords[stackId][idx]) {
lastStackCoords[stackId][idx] = {
// Positive stack
p: valueAxisStart,
// Negative stack
n: valueAxisStart
};
}
var sign = value >= 0 ? 'p' : 'n';
var coord = coords[idx];
var lastCoord = lastStackCoords[stackId][idx][sign];
var x, y, width, height;
if (valueAxis.isHorizontal()) {
x = lastCoord;
y = coord[1] + columnOffset;
width = coord[0] - lastCoord;
height = columnWidth;
if (Math.abs(width) < barMinHeight) {
width = (width < 0 ? -1 : 1) * barMinHeight;
}
else {
x = coord[0] + columnOffset;
y = lastCoord;
width = columnWidth;
height = coord[1] - lastCoord;
if (Math.abs(height) < barMinHeight) {
height = (height < 0 ? -1 : 1) * barMinHeight;
}
lastStackCoords[stackId][idx][sign] += width;
}
else {
x = coord[0] + columnOffset;
y = lastCoord;
width = columnWidth;
height = coord[1] - lastCoord;
if (Math.abs(height) < barMinHeight) {
height = (height < 0 ? -1 : 1) * barMinHeight;
}
lastStackCoords[stackId][idx][sign] += height;
}
data.setItemLayout(idx, {
x: x,
y: y,
width: width,
height: height
});
}, true);
}
data.setItemLayout(idx, {
x: x,
y: y,
width: width,
height: height
});
}, true);
}, this);
}
......
......@@ -530,17 +530,6 @@ define(function (require) {
);
},
/**
* @param {Function} cb
* @param {*} context
*/
mapSeries: function (cb, context) {
var componentsMap = this._componentsMap;
componentsMap.series = zrUtil.map(
componentsMap.series, cb, context
);
},
restoreData: function () {
var componentsMap = this._componentsMap;
var componentTypes = [];
......
......@@ -9,8 +9,7 @@ define(function (require) {
var number = {};
function _trim(str) {
return str.replace(/^\s+/, '').replace(/\s+$/, '');
}
return str.replace(/^\s+/, '').replace(/\s+$/, ''); }
/**
* Linear mapping a value from domain to range
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册