Skip to content

Commit 8a137e3

Browse files
committed
center title of horizontal colorbars on the right side
1 parent fb56f8e commit 8a137e3

File tree

5 files changed

+6
-2
lines changed

5 files changed

+6
-2
lines changed

src/components/colorbar/draw.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ function drawColorBar(g, opts, gd) {
365365
}
366366

367367
drawTitle(ax._id + 'title', {
368-
attributes: {x: x, y: y, 'text-anchor': 'start'}
368+
attributes: {x: x, y: y, 'text-anchor': isVertical ? 'start' : 'middle'}
369369
});
370370
}
371371
}
@@ -639,7 +639,11 @@ function drawColorBar(g, opts, gd) {
639639
}
640640
}
641641

642-
if(rightSideHorizontal) titleWidth += titleFontSize / 2;
642+
if(rightSideHorizontal) {
643+
titleEl.attr('transform', strTranslate(titleWidth / 2 + titleFontSize / 2, 0));
644+
645+
titleWidth *= 2;
646+
}
643647

644648
innerThickness = Math.max(innerThickness,
645649
isVertical ? titleWidth : _titleHeight

test/image/baselines/h-colorbar01.png

-74 Bytes
Loading

test/image/baselines/h-colorbar02.png

-20 Bytes
Loading

test/image/baselines/h-colorbar09.png

18 Bytes
Loading

test/image/baselines/h-colorbar12.png

5 Bytes
Loading

0 commit comments

Comments
 (0)