Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcc9a94

Browse files
committed
fix vertical alignment of label for angular gauge
1 parent 1bbbf2b commit fcc9a94

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

src/traces/indicator/plot.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = function plot(gd, cdModule, transitionOpts, makeOnCompleteCallb
9696
// bullet gauge
9797
var isBullet = hasGauge && trace.gauge.shape === 'bullet';
9898

99-
var isWide = !(size.h > radius);
99+
var isWide = (size.h * 0.75 < size.w / 2);
100100

101101
// TODO: Move the following to defaults
102102
// Position elements
@@ -135,7 +135,11 @@ module.exports = function plot(gd, cdModule, transitionOpts, makeOnCompleteCallb
135135
labelFontSize = 0.35 * mainFontSize;
136136
deltaVerticalMargin = bignumberVerticalMargin + deltaFontSize;
137137
if(!hasBigNumber) deltaBaseline = 'bottom';
138-
labelY = size.t + Math.max(labelFontSize / 2, size.h / 2 - radius);
138+
if(isWide) {
139+
labelY = size.t + (0.25 / 2) * size.h - labelFontSize / 2;
140+
} else {
141+
labelY = ((bignumberVerticalMargin - radius) + size.t) / 2;
142+
}
139143
}
140144
if(isBullet) {
141145
// Center the text
1.05 KB
Loading
-4.29 KB
Loading

test/image/mocks/indicator_bignumber.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
"height": 500,
6060
"paper_bgcolor": "black",
6161
"margin": {
62-
"t": 50,
62+
"t": 25,
6363
"r": 25,
6464
"l": 25,
65-
"b": 50
65+
"b": 25
6666
},
6767
"shapes": [{
6868
"type": "rect",

test/image/mocks/indicator_gauge.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"t": 25,
9696
"r": 25,
9797
"l": 25,
98-
"b": 25
98+
"b": 50
9999
},
100100
"font": {
101101
"color": "white",

0 commit comments

Comments
 (0)