Skip to content

Commit 544977e

Browse files
committed
thanks to a typo leading to apply a better easing option suitable for treemaps
loop in eventDataKeys from sunburst and treemap constants clean up an unused condition check
1 parent 0012fa1 commit 544977e

File tree

6 files changed

+17
-32
lines changed

6 files changed

+17
-32
lines changed

src/traces/sunburst/fx.js

+9-16
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
156156
textAlign: _cast('hoverlabel.align'),
157157
hovertemplate: hovertemplate,
158158
hovertemplateLabels: hoverPt,
159-
eventData: [makeEventData(pt, traceNow)]
159+
eventData: [makeEventData(pt, traceNow, opts.eventDataKeys)]
160160
};
161161

162162
if(isSunburst) {
@@ -187,7 +187,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
187187

188188
trace._hasHoverEvent = true;
189189
gd.emit('plotly_hover', {
190-
points: [makeEventData(pt, traceNow)],
190+
points: [makeEventData(pt, traceNow, opts.eventDataKeys)],
191191
event: d3.event
192192
});
193193
};
@@ -200,7 +200,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
200200
if(trace._hasHoverEvent) {
201201
evt.originalEvent = d3.event;
202202
gd.emit('plotly_unhover', {
203-
points: [makeEventData(pt, traceNow)],
203+
points: [makeEventData(pt, traceNow, opts.eventDataKeys)],
204204
event: d3.event
205205
});
206206
trace._hasHoverEvent = false;
@@ -229,7 +229,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
229229
var traceNow = gd._fullData[trace.index];
230230

231231
var clickVal = Events.triggerHandler(gd, 'plotly_' + trace.type + 'click', {
232-
points: [makeEventData(pt, traceNow)],
232+
points: [makeEventData(pt, traceNow, opts.eventDataKeys)],
233233
event: d3.event
234234
});
235235

@@ -243,7 +243,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
243243
)
244244
) {
245245
if(fullLayoutNow.hovermode) {
246-
gd._hoverdata = [makeEventData(pt, traceNow)];
246+
gd._hoverdata = [makeEventData(pt, traceNow, opts.eventDataKeys)];
247247
Fx.click(gd, d3.event);
248248
}
249249
return;
@@ -316,7 +316,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
316316
sliceTop.on('click', onClick);
317317
};
318318

319-
function makeEventData(pt, trace) {
319+
function makeEventData(pt, trace, keys) {
320320
var cdi = pt.data.data;
321321

322322
var out = {
@@ -328,17 +328,10 @@ function makeEventData(pt, trace) {
328328
// TODO more things like 'children', 'siblings', 'hierarchy?
329329
};
330330

331-
[ // TODO: read these from (sunburst | treemap) trace constants
332-
'parentLabel',
333-
'visibleLabel',
334-
'rootLabel',
335-
'percentParent',
336-
'percentVisible',
337-
'percentRoot',
338-
'currentPath'
339-
].forEach(function(key) {
331+
for(var i = 0; i < keys.length; i++) {
332+
var key = keys[i];
340333
if(key in pt) out[key] = pt[key];
341-
});
334+
}
342335

343336
appendArrayPointValue(out, trace, cdi.i);
344337

src/traces/sunburst/plot.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ function plotOne(gd, cd, element, transitionOpts) {
233233

234234
sliceTop
235235
.call(attachFxHandlers, entry, gd, cd, {
236+
eventDataKeys: constants.eventDataKeys,
236237
transitionTime: constants.CLICK_TRANSITION_TIME,
237-
transitonEasing: constants.CLICK_TRANSITION_EASING
238+
transitionEasing: constants.CLICK_TRANSITION_EASING
238239
})
239240
.call(helpers.setSliceCursor, gd, {
240241
hideOnRoot: true,

src/traces/treemap/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module.exports = {
1212
CLICK_TRANSITION_TIME: 750,
13-
CLICK_TRANSITION_EASING: 'cubic',
13+
CLICK_TRANSITION_EASING: 'poly',
1414
eventDataKeys: [
1515
'currentPath',
1616
'percentRoot',

src/traces/treemap/draw_ancestors.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) {
118118
sliceTop
119119
.call(attachFxHandlers, entry, gd, cd, {
120120
styleOne: styleOne,
121+
eventDataKeys: constants.eventDataKeys,
121122
transitionTime: constants.CLICK_TRANSITION_TIME,
122-
transitonEasing: constants.CLICK_TRANSITION_EASING
123+
transitionEasing: constants.CLICK_TRANSITION_EASING
123124
})
124125
.call(helpers.setSliceCursor, gd, {
125126
hideOnRoot: false,

src/traces/treemap/draw_descendants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
120120
sliceTop
121121
.call(attachFxHandlers, entry, gd, cd, {
122122
styleOne: styleOne,
123+
eventDataKeys: constants.eventDataKeys,
123124
transitionTime: constants.CLICK_TRANSITION_TIME,
124-
transitonEasing: constants.CLICK_TRANSITION_EASING
125+
transitionEasing: constants.CLICK_TRANSITION_EASING
125126
})
126127
.call(helpers.setSliceCursor, gd, { isTransitioning: gd._transitioning });
127128

src/traces/treemap/plot.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,7 @@ function plotOne(gd, cd, element, transitionOpts) {
333333
parentPrev = getPrev(Q, upDown);
334334
} else i = maxDepth;
335335
}
336-
var result = parentPrev || {};
337-
338-
if(upDown && !isNaN(result.x1)) {
339-
// always slide pathbar from the right
340-
var difX = result.x1 - result.x0;
341-
if(result.transform) {
342-
result.transform.scale = 0;
343-
result.transform.targetX += difX;
344-
}
345-
result.x0 += difX;
346-
}
347-
return result;
336+
return parentPrev || {};
348337
};
349338

350339
var makeExitSliceInterpolator = function(pt, upDown, refRect, size) {

0 commit comments

Comments
 (0)