Skip to content

Commit ef423fa

Browse files
committed
only adjust graph title position when yanchor is bottom
1 parent eab32b3 commit ef423fa

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

src/components/colorbar/draw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ function drawColorBar(g, opts, gd) {
652652
) * 2 + innerThickness + borderwidth + outlinewidth / 2;
653653

654654
var hColorbarMoveTitle = 0;
655-
if(!isVertical && title.text && optsY <= 0) {
655+
if(!isVertical && title.text && yanchor === 'bottom' && optsY <= 0) {
656656
hColorbarMoveTitle = outerThickness / 2;
657657

658658
outerThickness += hColorbarMoveTitle;
24.8 KB
Loading

test/image/mocks/z_h-colorbar09.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"data": [
3+
{
4+
"x": [-1, 0, 1],
5+
"y": [0, 0, 0],
6+
"mode": "markers",
7+
"marker": {
8+
"size": 100,
9+
"color": [0, 50, 100],
10+
"colorscale": "Reds",
11+
"showscale": true,
12+
"colorbar": {
13+
"orientation": "h",
14+
"yanchor": "top",
15+
"y": 1,
16+
"len": 0.5,
17+
"ticks": "outside",
18+
"ticklen": 10,
19+
"bgcolor": "rgba(255,255,0,0.5)",
20+
"borderwidth": 1,
21+
"bordercolor": "gray",
22+
"title": {
23+
"text": "Colorbar<br>title",
24+
"font": {
25+
"size": 16
26+
}
27+
}
28+
}
29+
}
30+
}
31+
],
32+
"layout": {
33+
"width": 600,
34+
"height": 400,
35+
"plot_bgcolor": "lightblue",
36+
"title": {
37+
"text": "Graph title",
38+
"font": {
39+
"size": 24
40+
}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)