提交 c0300ec5 编写于 作者: L lang

tweak, improve markLine

上级 840f9f78
......@@ -188,7 +188,11 @@ define(function (require) {
});
api.updateGraphicEl(labelLine, {
shape: {
points: labelLayout.linePoints
points: labelLayout.linePoints || [
[labelLayout.x, labelLayout.y],
[labelLayout.x, labelLayout.y],
[labelLayout.x, labelLayout.y]
]
}
});
api.updateGraphicEl(labelText, {
......
......@@ -38,42 +38,42 @@ define(function (require) {
}
}
function changeX(list, isDownList, cx, cy, r, dir) {
var deltaX;
var deltaY;
var length;
var lastDeltaX = dir > 0
? isDownList // 右侧
? Number.MAX_VALUE // 下
: 0 // 上
: isDownList // 左侧
? Number.MAX_VALUE // 下
: 0; // 上
for (var i = 0, l = list.length; i < l; i++) {
deltaY = Math.abs(list[i].y - cy);
length = list[i]._radius - r;
deltaX = (deltaY < r + length)
? Math.sqrt(
(r + length + 20) * (r + length + 20)
- Math.pow(list[i].y - cy, 2)
)
: Math.abs(
list[i].x - cx
);
if (isDownList && deltaX >= lastDeltaX) {
// 右下,左下
deltaX = lastDeltaX - 10;
}
if (!isDownList && deltaX <= lastDeltaX) {
// 右上,左上
deltaX = lastDeltaX + 10;
}
list[i].x = cx + deltaX * dir;
lastDeltaX = deltaX;
}
}
// function changeX(list, isDownList, cx, cy, r, dir) {
// var deltaX;
// var deltaY;
// var length;
// var lastDeltaX = dir > 0
// ? isDownList // 右侧
// ? Number.MAX_VALUE // 下
// : 0 // 上
// : isDownList // 左侧
// ? Number.MAX_VALUE // 下
// : 0; // 上
// for (var i = 0, l = list.length; i < l; i++) {
// deltaY = Math.abs(list[i].y - cy);
// length = list[i].length;
// deltaX = (deltaY < r + length)
// ? Math.sqrt(
// (r + length + 20) * (r + length + 20)
// - Math.pow(list[i].y - cy, 2)
// )
// : Math.abs(
// list[i].x - cx
// );
// if (isDownList && deltaX >= lastDeltaX) {
// // 右下,左下
// deltaX = lastDeltaX - 10;
// }
// if (!isDownList && deltaX <= lastDeltaX) {
// // 右上,左上
// deltaX = lastDeltaX + 10;
// }
// list[i].x = cx + deltaX * dir;
// lastDeltaX = deltaX;
// }
// }
var lastY = 0;
var delta;
......@@ -98,8 +98,8 @@ define(function (require) {
upList.push(list[i]);
}
}
changeX(downList, true, cx, cy, r, dir);
changeX(upList, false, cx, cy, r, dir);
// changeX(downList, true, cx, cy, r, dir);
// changeX(upList, false, cx, cy, r, dir);
}
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
......@@ -126,6 +126,7 @@ define(function (require) {
else {
linePoints[2][0] = labelLayoutList[i].x - 3;
}
linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
}
}
}
......@@ -204,6 +205,8 @@ define(function (require) {
x: textX,
y: textY,
height: textRect.height,
length: labelLineLen,
length2: labelLineLen2,
linePoints: linePoints,
textAlign: textAlign,
textBaseline: textBaseline,
......
......@@ -122,7 +122,6 @@ define(function (require) {
*/
dataToCoord: function (data, clamp) {
data = this.scale.normalize(data);
var extent = this.getExtent();
if (this.onBand) {
fixExtentWithBands(extent, this.scale.count());
......
......@@ -2,6 +2,7 @@ define(function (require) {
var zrUtil = require('zrender/core/util');
var Axis = require('../Axis');
var axisLabelInterval = require('./axisLabelInterval');
/**
* Extend axis 2d
......@@ -54,6 +55,16 @@ define(function (require) {
isHorizontal: function () {
var position = this.position;
return position === 'top' || position === 'bottom';
},
/**
* @return {number}
*/
getLabelInterval: function () {
var labelInterval = this._labelInterval;
if (!labelInterval) {
labelInterval = this._labelInterval = axisLabelInterval(this);
}
return labelInterval;
}
};
zrUtil.inherits(Axis2D, Axis);
......
......@@ -54,5 +54,5 @@ define(function(require) {
}
return autoLabelInterval;
}
};
});
\ No newline at end of file
......@@ -374,11 +374,15 @@ define(function (require) {
*/
listProto.getDataExtent = function (dim, stack) {
var dimData = this._storage[dim];
var min = Infinity;
var max = -Infinity;
var dimExtent = (this._extent || (this._extent = {}))[dim];
var value;
if (dimExtent) {
return dimExtent;
}
// var dimInfo = this._dimensionInfos[dim];
if (dimData) {
var min = Infinity;
var max = -Infinity;
// var isOrdinal = dimInfo.type === 'ordinal';
for (var i = 0, len = this.count(); i < len; i++) {
value = this.get(dim, i, stack);
......@@ -390,8 +394,11 @@ define(function (require) {
value < min && (min = value);
value > max && (max = value);
}
return (this._extent[dim] = [min, max]);
}
else {
return [Infinity, -Infinity];
}
return [min, max];
};
/**
......
......@@ -23,7 +23,7 @@ define(function () {
// PENDING
fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
// fontFamily: 'Arial, Verdana, sans-serif',
fontSize: 12,
fontSize: 14,
fontStyle: 'normal',
fontWeight: 'normal'
},
......
......@@ -8,6 +8,7 @@ define(function(require) {
var colorTool = require('zrender/tool/color');
var matrix = require('zrender/core/matrix');
var vector = require('zrender/core/vector');
var Gradient = require('zrender/graphic/Gradient');
var graphic = {};
......@@ -172,8 +173,10 @@ define(function(require) {
// Create hoverStyle on mouseover
var hoverStyle = el.__hoverStl;
hoverStyle.fill = hoverStyle.fill || colorTool.lift(fill, -0.1);
hoverStyle.stroke = hoverStyle.stroke || colorTool.lift(stroke, -0.1);
hoverStyle.fill = hoverStyle.fill
|| (fill instanceof Gradient) ? fill : colorTool.lift(fill, -0.1);
hoverStyle.stroke = hoverStyle.stroke
|| (stroke instanceof Gradient) ? stroke : colorTool.lift(stroke, -0.1);
var normalStyle = {};
for (var name in hoverStyle) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册