提交 c0300ec5 编写于 作者: L lang

tweak, improve markLine

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