Skip to content

Commit 044afe0

Browse files
committed
Relay z verbatim from the plotly.js event in event_data(), fixes #1414
1 parent e082bf0 commit 044afe0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

inst/htmlwidgets/plotly.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ HTMLWidgets.widget({
230230
x: pt.x,
231231
y: pt.y
232232
};
233+
234+
// If 'z' is reported with the event data, then use it!
235+
if (pt.hasOwnProperty("z")) {
236+
obj.z = pt.z;
237+
}
238+
233239
/*
234240
TL;DR: (I think) we have to select the graph div (again) to attach keys...
235241
@@ -243,15 +249,12 @@ HTMLWidgets.widget({
243249
var gd = document.getElementById(el.id);
244250
var trace = gd.data[pt.curveNumber];
245251

246-
// Heatmap z event data should derive from _z calc attribute
247-
// https://github.com/ropensci/plotly/issues/1141
248-
var z = trace.type === "heatmap" ? "_z" : "z";
249252
if (!trace._isSimpleKey) {
250-
var attrsToAttach = ["key", z];
253+
var attrsToAttach = ["key"];
251254
} else {
252255
// simple keys fire the whole key
253256
obj.key = trace.key;
254-
var attrsToAttach = [z];
257+
var attrsToAttach = [];
255258
}
256259

257260
for (var i = 0; i < attrsToAttach.length; i++) {

0 commit comments

Comments
 (0)