-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Mulitple fixes for multi-heatmap-trace plots #655
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 all commits
2ef4411
90d7a94
48dc191
221a5a1
5084daf
897cb6f
7a2dc05
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 |
---|---|---|
|
@@ -137,10 +137,24 @@ function plotOne(gd, plotinfo, cd) { | |
var imageWidth = Math.round(right - left), | ||
imageHeight = Math.round(bottom - top); | ||
|
||
// now redraw | ||
// setup image nodes | ||
|
||
// if image is entirely off-screen, don't even draw it | ||
if(imageWidth <= 0 || imageHeight <= 0) return; | ||
var isOffScreen = (imageWidth <= 0 || imageHeight <= 0); | ||
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.
|
||
|
||
var plotgroup = plotinfo.plot.select('.imagelayer') | ||
.selectAll('g.hm.' + id) | ||
.data(isOffScreen ? [] : [0]); | ||
|
||
plotgroup.enter().append('g') | ||
.classed('hm', true) | ||
.classed(id, true); | ||
|
||
plotgroup.exit().remove(); | ||
|
||
if(isOffScreen) return; | ||
|
||
// generate image data | ||
|
||
var canvasW, canvasH; | ||
if(zsmooth === 'fast') { | ||
|
@@ -363,26 +377,21 @@ function plotOne(gd, plotinfo, cd) { | |
gd._hmpixcount = (gd._hmpixcount||0) + pixcount; | ||
gd._hmlumcount = (gd._hmlumcount||0) + pixcount * avgColor.getLuminance(); | ||
|
||
var plotgroup = plotinfo.plot.select('.imagelayer') | ||
.selectAll('g.hm.' + id) | ||
.data([0]); | ||
plotgroup.enter().append('g') | ||
.classed('hm', true) | ||
.classed(id, true); | ||
plotgroup.exit().remove(); | ||
|
||
var image3 = plotgroup.selectAll('image') | ||
.data(cd); | ||
image3.enter().append('svg:image'); | ||
image3.exit().remove(); | ||
|
||
image3.attr({ | ||
image3.enter().append('svg:image').attr({ | ||
xmlns: xmlnsNamespaces.svg, | ||
'xlink:href': canvas.toDataURL('image/png'), | ||
preserveAspectRatio: 'none' | ||
}); | ||
|
||
image3.attr({ | ||
height: imageHeight, | ||
width: imageWidth, | ||
x: left, | ||
y: top, | ||
preserveAspectRatio: 'none' | ||
y: top | ||
}); | ||
|
||
image3.exit().remove(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"x": [ | ||
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. We didn't have a mock for a subplot with multiple heatmap traces on it yet. We have numerous multiple subplots mocks with one heatmap per subplot, but none for multiple heatmap on the same x/y subplot. So, here's one. |
||
1, | ||
1, | ||
1, | ||
1, | ||
1, | ||
1 | ||
], | ||
"y": [ | ||
0, | ||
1, | ||
2, | ||
3, | ||
4, | ||
5 | ||
], | ||
"z": [ | ||
3, | ||
4, | ||
2, | ||
5, | ||
3, | ||
1 | ||
], | ||
"type": "heatmap", | ||
"showlegend": false, | ||
"showscale": false, | ||
"zmax": 5, | ||
"zmin": 1 | ||
}, | ||
{ | ||
"x": [ | ||
2, | ||
2, | ||
2, | ||
2, | ||
2 | ||
], | ||
"y": [ | ||
0.2, | ||
1.2, | ||
2.2, | ||
3.2, | ||
4.2 | ||
], | ||
"z": [ | ||
6, | ||
1, | ||
3, | ||
2, | ||
4 | ||
], | ||
"type": "heatmap", | ||
"showlegend": false, | ||
"showscale": false, | ||
"zmax": 6, | ||
"zmin": 1 | ||
}, | ||
{ | ||
"x": [ | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3, | ||
3 | ||
], | ||
"y": [ | ||
0, | ||
0.5, | ||
1, | ||
1.5, | ||
2, | ||
2.5, | ||
3, | ||
3.5, | ||
4, | ||
4.5, | ||
5 | ||
], | ||
"z": [ | ||
6, | ||
1, | ||
3, | ||
2, | ||
4, | ||
2, | ||
7, | ||
4, | ||
3, | ||
2, | ||
5 | ||
], | ||
"type": "heatmap", | ||
"showlegend": false, | ||
"showscale": false, | ||
"zmax": 7, | ||
"zmin": 1 | ||
}, | ||
{ | ||
"x": [ | ||
4, | ||
4, | ||
4, | ||
4, | ||
4, | ||
4 | ||
], | ||
"y": [ | ||
0, | ||
0.2, | ||
0.5, | ||
1.2, | ||
3.5, | ||
4 | ||
], | ||
"z": [ | ||
2, | ||
4, | ||
7, | ||
3, | ||
2, | ||
1 | ||
], | ||
"type": "heatmap", | ||
"showlegend": false, | ||
"showscale": false, | ||
"zmax": 7, | ||
"zmin": 1 | ||
}, | ||
{ | ||
"x": [ | ||
5.2, | ||
5.2, | ||
5.2, | ||
5.2, | ||
5.2, | ||
5.2 | ||
], | ||
"y": [ | ||
0, | ||
0.2, | ||
0.5, | ||
1.2, | ||
3.5, | ||
4 | ||
], | ||
"z": [ | ||
2, | ||
4, | ||
7, | ||
3, | ||
2, | ||
1 | ||
], | ||
"type": "heatmap", | ||
"showlegend": false, | ||
"showscale": true, | ||
"zmax": 10, | ||
"zmin": 0 | ||
} | ||
], | ||
"layout": { | ||
"hovermode": "closest", | ||
"xaxis": { | ||
"type": "linear", | ||
"range": [ | ||
0.5, | ||
5.7 | ||
], | ||
"autorange": true | ||
}, | ||
"yaxis": { | ||
"type": "linear", | ||
"range": [ | ||
-0.5, | ||
5.5 | ||
], | ||
"autorange": true | ||
}, | ||
"height": 450, | ||
"width": 1100, | ||
"autosize": true | ||
} | ||
} |
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.
This bug was pretty painful to track down.
It was introduced in d7abd18 when some
graph_interact.js
constants got moved toplots/cartesian/constants.js
.Unfortunately,
Fx.MAXDIST
was still being used in heatmap hover which wasundefined
.Reminder: don't forgot to grep/ack/ag when moving things around!
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.
sorry about that @etpinard - as a bit of karmic penance, I fixed this myself in #673 then had to undo my fix when I merged master and got your fix too!