提交 bff0884b 编写于 作者: L lang

Legend add newline flag

上级 244534aa
......@@ -59,6 +59,13 @@ define(function (require) {
var legendDrawedMap = {};
zrUtil.each(legendModel.getData(), function (itemModel) {
var seriesName = itemModel.get('name');
// Use empty string or \n as a newline string
if (seriesName === '' || seriesName === '\n') {
group.add(new graphic.Group({
newline: true
}));
}
var seriesModel = ecModel.getSeriesByName(seriesName)[0];
legendDataMap[seriesName] = itemModel;
......
......@@ -29,8 +29,8 @@ define(function(require) {
var nextY;
if (orient === 'horizontal') {
nextX = x + rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
// Wrap
if (nextX > maxWidth) {
// Wrap when width exceeds maxWidth or meet a `newline` group
if (nextX > maxWidth || child.newline) {
x = 0;
y += currentLineMaxSize + gap;
currentLineMaxSize = 0;
......@@ -41,8 +41,8 @@ define(function(require) {
}
else {
nextY = y + rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
// Wrap
if (nextY > maxHeight) {
// Wrap when width exceeds maxHeight or meet a `newline` group
if (nextY > maxHeight || child.newline) {
x += currentLineMaxSize + gap;
y = 0;
currentLineMaxSize = 0;
......@@ -52,6 +52,10 @@ define(function(require) {
}
}
if (child.newline) {
return;
}
position[0] = x;
position[1] = y;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册