提交 62b02fed 编写于 作者: L lang

markLine and markPoint data label fill. Always rotate symbol on markLine. Mark...

markLine and markPoint data label fill. Always rotate symbol on markLine. Mark line label position support 'middle'
上级 139896bb
......@@ -58,9 +58,9 @@ define(function (require) {
}
}
function isSymbolArrow(symbol) {
return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow';
}
// function isSymbolArrow(symbol) {
// return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow';
// }
function updateSymbolBeforeLineUpdate () {
var lineGroup = this;
......@@ -82,15 +82,15 @@ define(function (require) {
symbolFrom.attr('position', fromPos);
// Rotate the arrow
// FIXME Hard coded ?
if (isSymbolArrow(symbolFrom)) {
symbolFrom.attr('rotation', tangentRotation(toPos, fromPos));
}
// if (isSymbolArrow(symbolFrom)) {
symbolFrom.attr('rotation', tangentRotation(toPos, fromPos));
// }
}
if (symbolTo) {
symbolTo.attr('position', toPos);
if (isSymbolArrow(symbolTo)) {
symbolTo.attr('rotation', tangentRotation(fromPos, toPos));
}
// if (isSymbolArrow(symbolTo)) {
symbolTo.attr('rotation', tangentRotation(fromPos, toPos));
// }
}
label.attr('position', toPos);
......@@ -104,6 +104,24 @@ define(function (require) {
textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
}
// Middle
else if (label.__position === 'middle') {
var n = [d[1], -d[0]];
if (n[1] > 0) {
n[0] = -n[0];
n[1] = -n[1];
}
textPosition = [(toPos[0] + fromPos[0]) / 2 + n[0] * 5, (toPos[1] + fromPos[1]) / 2 + n[1] * 5];
textAlign = 'center';
textVerticalAlign = 'bottom';
var rotation = -Math.atan2(
toPos[1] - fromPos[1], toPos[0] - fromPos[0]
);
if (toPos[0] < fromPos[0]) {
rotation = Math.PI + rotation;
}
label.attr('rotation', rotation);
}
// Start
else {
textPosition = [-d[0] * 5 + fromPos[0], -d[1] * 5 + fromPos[1]];
......
define(function (require) {
// Default enable markLine
// var globalDefault = require('../../model/globalDefault');
var modelUtil = require('../../util/model');
var zrUtil = require('zrender/core/util');
// // Force to load markLine component
// globalDefault.markLine = {};
function fillLabel(opt) {
modelUtil.defaultEmphasis(
opt.label,
modelUtil.LABEL_OPTIONS
);
}
var MarkLineModel = require('../../echarts').extendComponentModel({
type: 'markLine',
dependencies: ['series', 'grid', 'polar'],
dependencies: ['series', 'grid', 'polar', 'geo'],
/**
* @overrite
*/
......@@ -32,11 +35,17 @@ define(function (require) {
if (!mlModel) {
if (isInit) {
// Default label emphasis `position` and `show`
modelUtil.defaultEmphasis(
markLineOpt.label,
['position', 'show', 'textStyle', 'distance', 'formatter']
);
fillLabel(markLineOpt);
}
zrUtil.each(markLineOpt.data, function (item) {
if (item instanceof Array) {
fillLabel(item[0]);
fillLabel(item[1]);
}
else {
fillLabel(item);
}
});
var opt = {
// Use the same series index and name
seriesIndex: seriesModel.seriesIndex,
......
define(function (require) {
// Default enable markPoint
// var globalDefault = require('../../model/globalDefault');
var modelUtil = require('../../util/model');
// // Force to load markPoint component
// globalDefault.markPoint = {};
var zrUtil = require('zrender/core/util');
function fillLabel(opt) {
modelUtil.defaultEmphasis(
opt.label,
modelUtil.LABEL_OPTIONS
);
}
var MarkPointModel = require('../../echarts').extendComponentModel({
type: 'markPoint',
......@@ -30,11 +34,9 @@ define(function (require) {
if (!mpModel) {
if (isInit) {
// Default label emphasis `position` and `show`
modelUtil.defaultEmphasis(
markPointOpt.label,
['position', 'show', 'textStyle', 'distance', 'formatter']
);
fillLabel(markPointOpt);
}
zrUtil.each(markPointOpt.data, fillLabel);
var opt = {
// Use the same series index and name
seriesIndex: seriesModel.seriesIndex,
......
......@@ -81,7 +81,7 @@ define(function (require) {
// `yAxis` to specify the coord on each dimension
// parseFloat first because item.x and item.y can be percent string like '20%'
if ((isNaN(parseFloat(item.x)) || isNaN(parseFloat(item.y)))
if (item && (isNaN(parseFloat(item.x)) || isNaN(parseFloat(item.y)))
&& !zrUtil.isArray(item.coord)
&& coordSys
) {
......@@ -155,9 +155,7 @@ define(function (require) {
if (dimIndex < 2) {
return item.coord && item.coord[dimIndex];
}
else {
return item.value;
}
return item.value;
};
var numCalculate = function (data, valueDataDim, mlType) {
......
......@@ -71,9 +71,7 @@ define(function(require) {
// Default label emphasis `position` and `show`
// FIXME Set label in merge
modelUtil.defaultEmphasis(
option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
);
modelUtil.defaultEmphasis(option.label, modelUtil.LABEL_OPTIONS);
if (option.data) {
this._fillDataTextStyle(option.data);
......@@ -99,9 +97,7 @@ define(function(require) {
// FIXME Performance ?
for (var i = 0; i < data.length; i++) {
if (data[i] && data[i].label) {
modelUtil.defaultEmphasis(
data[i].label, ['position', 'show', 'textStyle', 'distance', 'formatter']
);
modelUtil.defaultEmphasis(data[i].label, modelUtil.LABEL_OPTIONS);
}
}
},
......
......@@ -176,6 +176,8 @@ define(function(require) {
}
};
modelUtil.LABEL_OPTIONS = ['position', 'show', 'textStyle', 'distance', 'formatter'];
/**
* Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
* @param {Object} opt
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册