Skip to content

Commit 63658e1

Browse files
committed
Add range attribute and default to rangeslider
1 parent 6e0f7bd commit 63658e1

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/components/rangeslider/attributes.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ module.exports = {
3030
role: 'style',
3131
description: 'Sets the border color of the range slider.'
3232
},
33+
range: {
34+
valType: 'info_array',
35+
role: 'info',
36+
items: [
37+
{valType: 'number'},
38+
{valType: 'number'}
39+
],
40+
description: [
41+
'Sets the range of the range slider.',
42+
'If not set, defaults to the full xaxis range.',
43+
'If the axis `type` is *log*, then you must take the',
44+
'log of your desired range.',
45+
'If the axis `type` is *date*, then you must convert',
46+
'the date to unix time in milliseconds.'
47+
].join(' ')
48+
},
3349
thickness: {
3450
valType: 'number',
3551
dflt: 0.15,

src/components/rangeslider/defaults.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,23 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, axName, coun
2525
attributes, attr, dflt);
2626
}
2727

28-
coerce('visible');
29-
coerce('thickness');
3028
coerce('bgcolor');
3129
coerce('bordercolor');
3230
coerce('borderwidth');
31+
coerce('thickness');
32+
coerce('visible');
33+
coerce('range');
34+
35+
// Expand slider range to the axis range
36+
if(containerOut.range && !layoutOut[axName].autorange) {
37+
var outRange = containerOut.range,
38+
axRange = layoutOut[axName].range;
39+
40+
outRange[0] = Math.min(outRange[0], axRange[0]);
41+
outRange[1] = Math.max(outRange[1], axRange[1]);
42+
} else {
43+
layoutOut[axName]._needsExpand = true;
44+
}
3345

3446
if(containerOut.visible) {
3547
counterAxes.forEach(function(ax) {

0 commit comments

Comments
 (0)