-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
use marker.colors with colorscale in treemap and sunburst plots #4242
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
Changes from all commits
1c136f4
2e17994
ba492cf
1d159e6
429324d
f068cb2
7df59a5
280a0a1
aa52dd5
fed26bb
481f660
3b104b1
1dff468
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 | ||||
---|---|---|---|---|---|---|
|
@@ -35,37 +35,57 @@ function styleOne(s, pt, trace, opts) { | |||||
var ptNumber = cdi.i; | ||||||
var lineColor; | ||||||
var lineWidth; | ||||||
var opacity; | ||||||
|
||||||
var depthFade = function(n) { | ||||||
var base = trace.marker.opacitybase; | ||||||
var step = trace.marker.opacitystep; | ||||||
|
||||||
return n === 0 ? base : | ||||||
Math.max(0, Math.min(1, n * step)); | ||||||
}; | ||||||
var fillColor = cdi.color; | ||||||
var isRoot = helpers.isHierarchyRoot(pt); | ||||||
var opacity = 1; | ||||||
|
||||||
if(hovered) { | ||||||
lineColor = trace._hovered.marker.line.color; | ||||||
lineWidth = trace._hovered.marker.line.width; | ||||||
opacity = trace._hovered.marker.opacity; | ||||||
} else { | ||||||
if(helpers.isHierarchyRoot(pt)) { | ||||||
if(isRoot && fillColor === 'rgba(0,0,0,0)') { | ||||||
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. This solution correctly handle the default root case that sets plotly.js/src/traces/sunburst/calc.js Lines 269 to 270 in 1dff468
but, we'll probably need to extend it all other |
||||||
opacity = 0; | ||||||
lineColor = 'rgba(0,0,0,0)'; | ||||||
lineWidth = 0; | ||||||
} else { | ||||||
lineColor = Lib.castOption(trace, ptNumber, 'marker.line.color') || Color.defaultLine; | ||||||
lineWidth = Lib.castOption(trace, ptNumber, 'marker.line.width') || 0; | ||||||
} | ||||||
|
||||||
opacity = | ||||||
trace._hasColorscale || helpers.isLeaf(pt) ? 1 : | ||||||
pt.onPathbar ? trace.pathbar.opacity : | ||||||
depthFade(pt.data.depth - trace._entryDepth); | ||||||
if(!trace._hasColorscale && !pt.onPathbar) { | ||||||
var depthfade = trace.marker.depthfade; | ||||||
if(depthfade) { | ||||||
var fadedColor = Color.combine(Color.addOpacity(trace._backgroundColor, 0.75), fillColor); | ||||||
var n; | ||||||
|
||||||
if(depthfade === true) { | ||||||
var maxDepth = helpers.getMaxDepth(trace); | ||||||
if(isFinite(maxDepth)) { | ||||||
if(helpers.isLeaf(pt)) { | ||||||
n = 0; | ||||||
} else { | ||||||
n = (trace._maxVisibleLayers) - (pt.data.depth - trace._entryDepth); | ||||||
} | ||||||
} else { | ||||||
n = pt.data.height + 1; | ||||||
} | ||||||
} else { // i.e. case of depthfade === 'reversed' | ||||||
n = pt.data.depth - trace._entryDepth; | ||||||
if(!trace._atRootLevel) n++; | ||||||
} | ||||||
|
||||||
if(n > 0) { | ||||||
for(var i = 0; i < n; i++) { | ||||||
var ratio = 0.5 * i / n; | ||||||
fillColor = Color.combine(Color.addOpacity(fadedColor, ratio), fillColor); | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
s.style('stroke-width', lineWidth) | ||||||
.call(Color.fill, cdi.color) | ||||||
.call(Color.fill, fillColor) | ||||||
.call(Color.stroke, lineColor) | ||||||
.style('opacity', opacity); | ||||||
} | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.