Skip to content

Icicle Trace #5546

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

Merged
merged 67 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
b3c9c08
start icicle trace by duplicating and adjusting treemap code
archmoj Feb 23, 2021
66c6730
can reuse treemp/draw_ancestors and sunburt/style
archmoj Feb 23, 2021
b3e1bb9
working prototype
archmoj Feb 23, 2021
0822bf5
drop unused treemap props and bring in relevant sunburst props for ic…
archmoj Feb 23, 2021
5aa3310
add tiling orientation for icicle
archmoj Feb 23, 2021
46182ad
add some icicle mocks and baselines and validate them
archmoj Feb 23, 2021
9f4f248
where possible reuse treemap attributes in icicle
archmoj Feb 23, 2021
d5fc016
adjust syntax test for icicle children
archmoj Feb 23, 2021
1477ceb
add(mocks): icicle plots that showcase left, right, top, and down ori…
Coding-with-Adam Mar 11, 2021
4f53fe1
start icicle trace by duplicating and adjusting treemap code
archmoj Feb 23, 2021
f2e0698
can reuse treemp/draw_ancestors and sunburt/style
archmoj Feb 23, 2021
9c0ad73
working prototype
archmoj Feb 23, 2021
77235b4
drop unused treemap props and bring in relevant sunburst props for ic…
archmoj Feb 23, 2021
938cf4a
add tiling orientation for icicle
archmoj Feb 23, 2021
9a57346
add some icicle mocks and baselines and validate them
archmoj Feb 23, 2021
5b5bb5e
where possible reuse treemap attributes in icicle
archmoj Feb 23, 2021
b82fad6
adjust syntax test for icicle children
archmoj Feb 23, 2021
3360d78
add(mocks): icicle plots that showcase left, right, top, and down ori…
Coding-with-Adam Mar 11, 2021
e8f63dc
Merge branch 'master' of https://github.com/plotly/plotly.js into ici…
Coding-with-Adam Mar 16, 2021
4607077
combine all 4 icicle direction mocks into single mock
Coding-with-Adam Mar 16, 2021
be5ec77
Merge branch 'icicle-trace-base' of https://github.com/plotly/plotly.…
Coding-with-Adam Mar 16, 2021
716de6a
test(mocks): remove icicle-max-depth-3 mocks
mtwichan Mar 16, 2021
c6a9420
test(mocks): add icicle_coffee-maxdepth3-all-directions image
mtwichan Mar 16, 2021
154c4ad
test(mocks): add titles and modify layout for icicle_coffee-maxdepth3…
Coding-with-Adam Mar 17, 2021
746804d
test(mocks): update icicle_coffee-maxdepth3-all-directions.png
mtwichan Mar 18, 2021
81a6b5c
add icicle mocks and baselines
Coding-with-Adam Mar 23, 2021
f420d1e
Merge branch 'icicle-trace-base' of https://github.com/plotly/plotly.…
Coding-with-Adam Mar 23, 2021
c8e0b6d
replace baselines with ci-generated baselines
Coding-with-Adam Mar 24, 2021
2931707
add new mocks to mock_test.js for jasmine tests
Coding-with-Adam Mar 24, 2021
6eb3a38
correct jasmine icicle tests in mock_test.js (ALL SUCCESS)
Coding-with-Adam Mar 24, 2021
8ed4b8f
refactor(icicle): remove extra if statement in default.js
mtwichan Mar 24, 2021
feb8785
Merge branch 'icicle-trace-base' of https://github.com/plotly/plotly.…
mtwichan Mar 24, 2021
b2c921e
reuse treemap plot in icicle
archmoj Mar 25, 2021
80b4e17
correct icicle and treemap plots without cd
archmoj Mar 25, 2021
6b0ddd9
reuse treemap plot in icicle
archmoj Mar 25, 2021
74c75ad
cherry-pick two commits for plot refactor
archmoj Mar 25, 2021
595c73d
fix parsing error
Coding-with-Adam Mar 25, 2021
a068139
fix(plot): remove redeclared plotOne() for treemap
Coding-with-Adam Mar 25, 2021
40c0615
modify(mock): reverse order of the leaf-opacity mock
Coding-with-Adam Mar 25, 2021
17164b1
remove(getKey): unused in treemap file
Coding-with-Adam Mar 25, 2021
da3b6ce
fix(mock): correct the annotations
Coding-with-Adam Mar 25, 2021
8065e46
correct(baseline): use ci generated artifact from tests
Coding-with-Adam Mar 25, 2021
8197431
fix(maxdepth): icicles fill up their domain if using maxdepth
Coding-with-Adam Mar 26, 2021
575f3c1
Merge branch 'master' into icicle-trace-base
Coding-with-Adam Mar 26, 2021
d00383a
fix(partition): correct the calculation for the new width of the d3 p…
Coding-with-Adam Mar 26, 2021
06a7c94
fix(transition): ensure elements grow in from zero width/height when …
Coding-with-Adam Mar 26, 2021
7b5d690
fix(partition): correct the height calculation for vertical icicles
Coding-with-Adam Mar 26, 2021
5d9a05c
style(icicle): syntax errors caught in ci
Coding-with-Adam Mar 26, 2021
c755d09
test(mocks): update mock images to reflect current code
Coding-with-Adam Mar 29, 2021
dc24f92
refactor(plot_one): compactify the code that corrects elements transi…
Coding-with-Adam Mar 29, 2021
ef56481
test(jasmine): defaults, calc, hover for icicle
Coding-with-Adam Mar 29, 2021
e9c602d
refactor(jasmine tests): correct syntax-source
Coding-with-Adam Mar 29, 2021
02a9a03
test(mock_test): add uniformtext_icicle
Coding-with-Adam Mar 29, 2021
8e88271
test(jasmine): add more tests for icicle
Coding-with-Adam Mar 30, 2021
b743eff
refactor(test): remove unused functions and variables
Coding-with-Adam Mar 30, 2021
9067c1b
fix(text transition): icicle text now smoothly transitions into its t…
Coding-with-Adam Apr 2, 2021
c2bab55
refactor(plot_one): remove extra spaces after minus sign
Coding-with-Adam Apr 2, 2021
4402d45
fix(icicle): if you click icicle, the root color does not expand acro…
Coding-with-Adam Apr 5, 2021
dd3cc91
refactor(plot_one): add semicolon
Coding-with-Adam Apr 5, 2021
3b17a90
merge with master branch
Coding-with-Adam May 19, 2021
fdff0e7
update icicle_values_colorscale baseline
archmoj May 20, 2021
eaad10d
reuse treemap draw in icicle
archmoj Jun 11, 2021
d96f3f1
reuse flip tree in icicle
archmoj Jun 11, 2021
c57dda5
avoid multiple string comparisons
archmoj Jun 11, 2021
7140c3e
docs(icicle): clarify the description; set default to 0
Coding-with-Adam Jun 16, 2021
ae4be8c
update baselines with zero pad
archmoj Jun 17, 2021
7de2bd9
add pad to uniformtext_icicle mock
archmoj Jun 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/icicle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('../src/traces/icicle');
1 change: 1 addition & 0 deletions lib/index-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Plotly.register([
require('./pie'),
require('./sunburst'),
require('./treemap'),
require('./icicle'),
require('./funnelarea'),
require('./scattergeo'),
require('./choropleth'),
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Plotly.register([
require('./pie'),
require('./sunburst'),
require('./treemap'),
require('./icicle'),
require('./funnelarea'),
require('./scatter3d'),
require('./surface'),
Expand Down
5 changes: 4 additions & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ var traceUIControlPatterns = [
{pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'},
{pattern: /^dimensions\[\d+\]\.constraintrange/},
{pattern: /^node\.(x|y|groups)/}, // for Sankey nodes
{pattern: /^level$/}, // for Sunburst & Treemap traces
{pattern: /^level$/}, // for Sunburst, Treemap and Icicle traces

// below this you must be in editable: true mode
// TODO: I still put name and title with `trace.uirevision`
Expand Down Expand Up @@ -3738,6 +3738,9 @@ function makePlotFramework(gd) {
// single pie layer for the whole plot
fullLayout._pielayer = fullLayout._paper.append('g').classed('pielayer', true);

// single treemap layer for the whole plot
fullLayout._iciclelayer = fullLayout._paper.append('g').classed('iciclelayer', true);

// single treemap layer for the whole plot
fullLayout._treemaplayer = fullLayout._paper.append('g').classed('treemaplayer', true);

Expand Down
3 changes: 2 additions & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2927,10 +2927,11 @@ plots.doCalcdata = function(gd, traces) {
gd._hmpixcount = 0;
gd._hmlumcount = 0;

// for sharing colors across pies / sunbursts / treemap / funnelarea (and for legend)
// for sharing colors across pies / sunbursts / treemap / icicle / funnelarea (and for legend)
fullLayout._piecolormap = {};
fullLayout._sunburstcolormap = {};
fullLayout._treemapcolormap = {};
fullLayout._iciclecolormap = {};
fullLayout._funnelareacolormap = {};

// If traces were specified and this trace was not included,
Expand Down
1 change: 1 addition & 0 deletions src/traces/bar/uniform_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function resizeText(gd, gTrace, traceType) {
selector = 'g.slice';
break;
case 'treemap' :
case 'icicle' :
selector = 'g.slice, g.pathbar';
break;
default :
Expand Down
84 changes: 84 additions & 0 deletions src/traces/icicle/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
'use strict';

var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;

var colorScaleAttrs = require('../../components/colorscale/attributes');
var domainAttrs = require('../../plots/domain').attributes;
var pieAttrs = require('../pie/attributes');
var sunburstAttrs = require('../sunburst/attributes');
var treemapAttrs = require('../treemap/attributes');
var constants = require('../treemap/constants');
var extendFlat = require('../../lib/extend').extendFlat;

module.exports = {
labels: sunburstAttrs.labels,
parents: sunburstAttrs.parents,

values: sunburstAttrs.values,
branchvalues: sunburstAttrs.branchvalues,
count: sunburstAttrs.count,

level: sunburstAttrs.level,
maxdepth: sunburstAttrs.maxdepth,

tiling: {
orientation: {
valType: 'enumerated',
values: ['v', 'h'],
dflt: 'h',
editType: 'plot',
description: [
'Sets the orientation of the icicle.',
'With *v* the icicle grows vertically.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't really clear to me... "v" means "bottom up" and "h" means "left to right" ? It would be helpful to note here that the other two possibilities (top-down and right-to-left) can be achieved via flip if that is indeed how to do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact I might phrase this as "the root node(s) are on the left" rather than talking about icicles "growing" :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point, and I agree with this. I'l add that note.

'With *h* the icicle grows horizontally.',
].join(' ')
},

flip: treemapAttrs.tiling.flip,

pad: treemapAttrs.tiling.pad,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default value for this attribute should be 0, so as to look more like sunbursts and less like treemaps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a good idea as well. I remember when playing around with padding, 0 or close-to-0 looked the best to me.

Will change this.


editType: 'calc',
},

marker: extendFlat({
colors: sunburstAttrs.marker.colors,

line: sunburstAttrs.marker.line,

editType: 'calc'
},
colorScaleAttrs('marker', {
colorAttr: 'colors',
anim: false // TODO: set to anim: true?
})
),

leaf: sunburstAttrs.leaf,

pathbar: treemapAttrs.pathbar,

text: pieAttrs.text,
textinfo: sunburstAttrs.textinfo,
// TODO: incorporate `label` and `value` in the eventData
texttemplate: texttemplateAttrs({editType: 'plot'}, {
keys: constants.eventDataKeys.concat(['label', 'value'])
}),

hovertext: pieAttrs.hovertext,
hoverinfo: sunburstAttrs.hoverinfo,
hovertemplate: hovertemplateAttrs({}, {
keys: constants.eventDataKeys
}),

textfont: pieAttrs.textfont,
insidetextfont: pieAttrs.insidetextfont,
outsidetextfont: treemapAttrs.outsidetextfont,

textposition: treemapAttrs.textposition,
sort: pieAttrs.sort,
root: sunburstAttrs.root,

domain: domainAttrs({name: 'icicle', trace: true, editType: 'calc'}),
};
13 changes: 13 additions & 0 deletions src/traces/icicle/base_plot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

var plots = require('../../plots/plots');

exports.name = 'icicle';

exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
};

exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
};
11 changes: 11 additions & 0 deletions src/traces/icicle/calc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var calc = require('../sunburst/calc');

exports.calc = function(gd, trace) {
return calc.calc(gd, trace);
};

exports.crossTraceCalc = function(gd) {
return calc._runCrossTraceCalc('icicle', gd);
};
101 changes: 101 additions & 0 deletions src/traces/icicle/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
'use strict';

var Lib = require('../../lib');
var attributes = require('./attributes');
var Color = require('../../components/color');
var handleDomainDefaults = require('../../plots/domain').defaults;
var handleText = require('../bar/defaults').handleText;
var TEXTPAD = require('../bar/constants').TEXTPAD;

var Colorscale = require('../../components/colorscale');
var hasColorscale = Colorscale.hasColorscale;
var colorscaleDefaults = Colorscale.handleDefaults;

module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}

var labels = coerce('labels');
var parents = coerce('parents');

if(!labels || !labels.length || !parents || !parents.length) {
traceOut.visible = false;
return;
}

var vals = coerce('values');
if(vals && vals.length) {
coerce('branchvalues');
} else {
coerce('count');
}

coerce('level');
coerce('maxdepth');

coerce('tiling.orientation');
coerce('tiling.flip');
coerce('tiling.pad');

var text = coerce('text');
coerce('texttemplate');
if(!traceOut.texttemplate) coerce('textinfo', Array.isArray(text) ? 'text+label' : 'label');

coerce('hovertext');
coerce('hovertemplate');

var hasPathbar = coerce('pathbar.visible');

var textposition = 'auto';
handleText(traceIn, traceOut, layout, coerce, textposition, {
hasPathbar: hasPathbar,
moduleHasSelected: false,
moduleHasUnselected: false,
moduleHasConstrain: false,
moduleHasCliponaxis: false,
moduleHasTextangle: false,
moduleHasInsideanchor: false
});
coerce('textposition');

var lineWidth = coerce('marker.line.width');
if(lineWidth) coerce('marker.line.color', layout.paper_bgcolor);

coerce('marker.colors');
var withColorscale = traceOut._hasColorscale = (
hasColorscale(traceIn, 'marker', 'colors') ||
(traceIn.marker || {}).coloraxis // N.B. special logic to consider "values" colorscales
);
if(withColorscale) {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'});
}

coerce('leaf.opacity', withColorscale ? 1 : 0.7);

traceOut._hovered = {
marker: {
line: {
width: 2,
color: Color.contrast(layout.paper_bgcolor)
}
}
};

if(hasPathbar) {
// This works even for multi-line labels as icicle pathbar trim out line breaks
coerce('pathbar.thickness', traceOut.pathbar.textfont.size + 2 * TEXTPAD);

coerce('pathbar.side');
coerce('pathbar.edgeshape');
}

coerce('sort');

coerce('root.color');

handleDomainDefaults(traceOut, layout, coerce);

// do not support transforms for now
traceOut._length = null;
};
Loading