Skip to content

Commit da230bc

Browse files
committed
support ax.side=top with rangesliders
1 parent cda1db3 commit da230bc

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

src/components/rangeslider/draw.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,18 @@ module.exports = function(gd) {
159159

160160
// title goes next to range slider instead of tick labels, so
161161
// just take it over and draw it from here
162-
Titles.draw(gd, axisOpts._id + 'title', {
163-
propContainer: axisOpts,
164-
propName: axisOpts._name + '.title',
165-
placeholder: fullLayout._dfltTitle.x,
166-
attributes: {
167-
x: axisOpts._offset + axisOpts._length / 2,
168-
y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size,
169-
'text-anchor': 'middle'
170-
}
171-
});
162+
if(axisOpts.side === 'bottom') {
163+
Titles.draw(gd, axisOpts._id + 'title', {
164+
propContainer: axisOpts,
165+
propName: axisOpts._name + '.title',
166+
placeholder: fullLayout._dfltTitle.x,
167+
attributes: {
168+
x: axisOpts._offset + axisOpts._length / 2,
169+
y: y + opts._height + opts._offsetShift + 10 + 1.5 * axisOpts.titlefont.size,
170+
'text-anchor': 'middle'
171+
}
172+
});
173+
}
172174

173175
// update margins
174176
Plots.autoMargin(gd, opts._id, {

src/plots/cartesian/axes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2010,8 +2010,8 @@ axes.doTicks = function(gd, axid, skipTitle) {
20102010
// configure their own titles.
20112011
var ax = axisIds.getFromId(gd, axid);
20122012

2013-
// rangeslider takes over the title so drop it here
2014-
if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox) return;
2013+
// rangeslider takes over a bottom title so drop it here
2014+
if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return;
20152015

20162016
var avoidSelection = d3.select(gd).selectAll('g.' + axid + 'tick');
20172017
var avoid = {

src/plots/cartesian/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ exports.finalizeSubplots = function(layoutIn, layoutOut) {
8888
// so if there are NO subplots at all, make one from the first
8989
// x & y axes in the input layout
9090
if(!spAll.length) {
91-
var keys = Object.keys(layoutIn);
9291
xi = '';
9392
yi = '';
94-
for(i = 0; i < keys.length; i++) {
95-
var ki = keys[i];
93+
for(var ki in layoutIn) {
9694
if(constants.attrRegex.test(ki)) {
9795
var axLetter = ki.charAt(0);
9896
if(axLetter === 'x') {
105 Bytes
Loading

test/image/mocks/range_slider_multiple.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"domain": [ 0, 0.45 ],
2222
"range": [ 1, 2 ],
2323
"rangeslider": {},
24-
"title": "X"
24+
"title": "X",
25+
"side": "top"
2526
},
2627
"xaxis2": {
2728
"anchor": "y2",

0 commit comments

Comments
 (0)