-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Range slider fixes (user set y axis types + trace clearance) #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
de1668f
3274284
cb0202c
ea1a458
db85763
339ba49
e1d703f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,6 +345,90 @@ describe('the range slider', function() { | |
}) | ||
.then(done); | ||
}); | ||
|
||
it('should clear traces in range plot when needed', function(done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexcjohnson This commit fixes part 1
of #1473 in a pretty ugly way, unfortunately. Most trace clearance (i.e. deletion or plotinfo.plot.selectAll('g:not(.scatterlayer)').selectAll('g.trace').remove(); except for scatter, heatmap and contour traces. That is, part 1 of #1473 actually only affected scatter, heatmap and contour traces. Scatter traces are exempted from that In brief, this commit ensure that every special There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ugly but... ya gotta do what ya gotta do. Nice tests. 👍 |
||
|
||
function count(query) { | ||
return d3.select(getRangeSlider()).selectAll(query).size(); | ||
} | ||
|
||
Plotly.plot(gd, [{ | ||
type: 'scatter', | ||
x: [1, 2, 3], | ||
y: [2, 1, 2] | ||
}, { | ||
type: 'bar', | ||
x: [1, 2, 3], | ||
y: [2, 5, 2] | ||
}], { | ||
xaxis: { | ||
rangeslider: { visible: true } | ||
} | ||
}) | ||
.then(function() { | ||
expect(count('g.scatterlayer > g.trace')).toEqual(1); | ||
expect(count('g.barlayer > g.trace')).toEqual(1); | ||
|
||
return Plotly.restyle(gd, 'visible', false); | ||
}) | ||
.then(function() { | ||
expect(count('g.scatterlayer > g.trace')).toEqual(0); | ||
expect(count('g.barlayer > g.trace')).toEqual(0); | ||
|
||
return Plotly.restyle(gd, 'visible', true); | ||
}) | ||
.then(function() { | ||
expect(count('g.scatterlayer > g.trace')).toEqual(1); | ||
expect(count('g.barlayer > g.trace')).toEqual(1); | ||
|
||
return Plotly.deleteTraces(gd, [0, 1]); | ||
}) | ||
.then(function() { | ||
expect(count('g.scatterlayer > g.trace')).toEqual(0); | ||
expect(count('g.barlayer > g.trace')).toEqual(0); | ||
|
||
return Plotly.addTraces(gd, [{ | ||
type: 'heatmap', | ||
z: [[1, 2, 3], [2, 1, 3]] | ||
}]); | ||
}) | ||
.then(function() { | ||
expect(count('g.imagelayer > g.hm')).toEqual(1); | ||
|
||
return Plotly.restyle(gd, 'visible', false); | ||
}) | ||
.then(function() { | ||
expect(count('g.imagelayer > g.hm')).toEqual(0); | ||
|
||
return Plotly.restyle(gd, { | ||
visible: true, | ||
type: 'contour' | ||
}); | ||
}) | ||
.then(function() { | ||
expect(count('g.maplayer > g.contour')).toEqual(1); | ||
|
||
return Plotly.restyle(gd, 'type', 'heatmap'); | ||
}) | ||
.then(function() { | ||
expect(count('g.imagelayer > g.hm')).toEqual(1); | ||
expect(count('g.maplayer > g.contour')).toEqual(0); | ||
|
||
return Plotly.restyle(gd, 'type', 'contour'); | ||
}) | ||
.then(function() { | ||
expect(count('g.imagelayer > g.hm')).toEqual(0); | ||
expect(count('g.maplayer > g.contour')).toEqual(1); | ||
|
||
return Plotly.deleteTraces(gd, [0]); | ||
}) | ||
.then(function() { | ||
expect(count('g.imagelayer > g.hm')).toEqual(0); | ||
expect(count('g.maplayer > g.contour')).toEqual(0); | ||
}) | ||
.then(done); | ||
|
||
}); | ||
}); | ||
|
||
describe('handleDefaults function', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose this pattern
over keeping a ref to some underscore key e.g.
fullLayout._rangeSliders
to make these additions work even when there are no range sliders on the graph without having to resort toRegistry
.