Skip to content

Commit 70610ec

Browse files
committed
Add suffix to currentvalue slider label
1 parent 582c643 commit 70610ec

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/components/sliders/attributes.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,17 @@ module.exports = {
193193
prefix: {
194194
valType: 'string',
195195
role: 'info',
196-
description: [
197-
'When currentvalue.visible is true, this sets the prefix of the lable. If provided,',
198-
'it will be joined to the current value with a single space between.'
199-
].join(' ')
196+
description: 'When currentvalue.visible is true, this sets the prefix of the label.'
197+
},
198+
199+
suffix: {
200+
valType: 'string',
201+
role: 'info',
202+
description: 'When currentvalue.visible is true, this sets the suffix of the label.'
200203
},
201204

202205
font: extendFlat({}, fontAttrs, {
203-
description: 'Sets the font of the current value lable text.'
206+
description: 'Sets the font of the current value label text.'
204207
}),
205208
},
206209

src/components/sliders/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function sliderDefaults(sliderIn, sliderOut, layoutOut) {
6868
coerce('currentvalue.visible');
6969
coerce('currentvalue.xanchor');
7070
coerce('currentvalue.prefix');
71+
coerce('currentvalue.suffix');
7172
coerce('currentvalue.offset');
7273

7374
coerce('transition.duration');

src/components/sliders/draw.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function drawCurrentValue(sliderGroup, sliderOpts, valueOverride) {
259259
.classed('user-select-none', true)
260260
.attr('text-anchor', textAnchor);
261261

262-
var str = sliderOpts.currentvalue.prefix ? (sliderOpts.currentvalue.prefix + ' ') : '';
262+
var str = sliderOpts.currentvalue.prefix ? sliderOpts.currentvalue.prefix : '';
263263

264264
if(typeof valueOverride === 'string') {
265265
str += valueOverride;
@@ -268,6 +268,10 @@ function drawCurrentValue(sliderGroup, sliderOpts, valueOverride) {
268268
str += curVal;
269269
}
270270

271+
if(sliderOpts.currentvalue.suffix) {
272+
str += sliderOpts.currentvalue.suffix;
273+
}
274+
271275
text.call(Drawing.font, sliderOpts.currentvalue.font)
272276
.text(str)
273277
.call(svgTextUtils.convertToTspans);

test/image/baselines/sliders.png

1.23 KB
Loading

test/image/mocks/sliders.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@
148148
"size": 15
149149
},
150150
"currentvalue": {
151-
"prefix": "color:",
151+
"prefix": "prefix ",
152+
"suffix": " suffix",
152153
"xanchor": "right",
153154
"font": {
154155
"color": "orange",

0 commit comments

Comments
 (0)