Skip to content

Commit 80b4e17

Browse files
archmojCoding-with-Adam
authored andcommitted
correct icicle and treemap plots without cd
1 parent b2c921e commit 80b4e17

File tree

4 files changed

+641
-570
lines changed

4 files changed

+641
-570
lines changed

src/traces/icicle/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
calc: require('./calc').calc,
1616
crossTraceCalc: require('./calc').crossTraceCalc,
1717

18-
plot: require('../treemap/plot'),
18+
plot: require('./plot'),
1919
style: require('./style').style,
2020

2121
colorbar: require('../scatter/marker_colorbar'),

src/traces/icicle/plot.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
'use strict';
2+
3+
var d3 = require('@plotly/d3');
4+
5+
var helpers = require('../sunburst/helpers');
6+
7+
var uniformText = require('../bar/uniform_text');
8+
var clearMinTextSize = uniformText.clearMinTextSize;
9+
var resizeText = require('../bar/style').resizeText;
10+
var drawDescendants = require('./draw_descendants');
11+
var plotOne = require('../treemap/plot_one');
12+
var type = 'icicle';
13+
14+
module.exports = function _plot(gd, cdmodule, transitionOpts, makeOnCompleteCallback) {
15+
var fullLayout = gd._fullLayout;
16+
var layer = fullLayout['_' + type + 'layer'];
17+
var join, onComplete;
18+
19+
// If transition config is provided, then it is only a partial replot and traces not
20+
// updated are removed.
21+
var isFullReplot = !transitionOpts;
22+
23+
clearMinTextSize(type, fullLayout);
24+
25+
join = layer.selectAll('g.trace.' + type)
26+
.data(cdmodule, function(cd) { return cd[0].trace.uid; });
27+
28+
join.enter().append('g')
29+
.classed('trace', true)
30+
.classed(type, true);
31+
32+
join.order();
33+
34+
if(!fullLayout.uniformtext.mode && helpers.hasTransition(transitionOpts)) {
35+
if(makeOnCompleteCallback) {
36+
// If it was passed a callback to register completion, make a callback. If
37+
// this is created, then it must be executed on completion, otherwise the
38+
// pos-transition redraw will not execute:
39+
onComplete = makeOnCompleteCallback();
40+
}
41+
42+
var transition = d3.transition()
43+
.duration(transitionOpts.duration)
44+
.ease(transitionOpts.easing)
45+
.each('end', function() { onComplete && onComplete(); })
46+
.each('interrupt', function() { onComplete && onComplete(); });
47+
48+
transition.each(function() {
49+
// Must run the selection again since otherwise enters/updates get grouped together
50+
// and these get executed out of order. Except we need them in order!
51+
layer.selectAll('g.trace').each(function(cd) {
52+
plotOne(gd, cd, this, transitionOpts, drawDescendants);
53+
});
54+
});
55+
} else {
56+
join.each(function(cd) {
57+
plotOne(gd, cd, this, transitionOpts, drawDescendants);
58+
});
59+
60+
if(fullLayout.uniformtext.mode) {
61+
resizeText(gd, layer.selectAll('.trace'), type);
62+
}
63+
}
64+
65+
if(isFullReplot) {
66+
join.exit().remove();
67+
}
68+
};

0 commit comments

Comments
 (0)