-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Icicle Trace #5546
Changes from 64 commits
b3c9c08
66c6730
b3e1bb9
0822bf5
5aa3310
46182ad
9f4f248
d5fc016
1477ceb
4f53fe1
f2e0698
9c0ad73
77235b4
938cf4a
9a57346
5b5bb5e
b82fad6
3360d78
e8f63dc
4607077
be5ec77
716de6a
c6a9420
154c4ad
746804d
81a6b5c
f420d1e
c8e0b6d
2931707
6eb3a38
8ed4b8f
feb8785
b2c921e
80b4e17
6b0ddd9
74c75ad
595c73d
a068139
40c0615
17164b1
da3b6ce
8065e46
8197431
575f3c1
d00383a
06a7c94
7b5d690
5d9a05c
c755d09
dc24f92
ef56481
e9c602d
02a9a03
8e88271
b743eff
9067c1b
c2bab55
4402d45
dd3cc91
3b17a90
fdff0e7
eaad10d
d96f3f1
c57dda5
7140c3e
ae4be8c
7de2bd9
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('../src/traces/icicle'); |
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.', | ||
'With *h* the icicle grows horizontally.', | ||
].join(' ') | ||
}, | ||
|
||
flip: treemapAttrs.tiling.flip, | ||
|
||
pad: treemapAttrs.tiling.pad, | ||
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. I think the default value for this attribute should be 0, so as to look more like sunbursts and less like treemaps 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. 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'}), | ||
}; |
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); | ||
}; |
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); | ||
}; |
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'}); | ||
archmoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
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; | ||
}; |
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 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.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.
In fact I might phrase this as "the root node(s) are on the left" rather than talking about icicles "growing" :)
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.
Great point, and I agree with this. I'l add that note.