Skip to content

Commit

Permalink
handle special root color case
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Oct 7, 2019
1 parent 3b104b1 commit 1dff468
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions src/traces/treemap/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,56 +36,58 @@ function styleOne(s, pt, trace, opts) {
var lineColor;
var lineWidth;
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;
} else {
var isRoot = helpers.isHierarchyRoot(pt);
if(isRoot && fillColor === 'rgba(0,0,0,0)') {
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;

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(!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;
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 = (trace._maxVisibleLayers) - (pt.data.depth - trace._entryDepth);
n = pt.data.height + 1;
}
} else {
n = pt.data.height + 1;
} else { // i.e. case of depthfade === 'reversed'
n = pt.data.depth - trace._entryDepth;
if(!trace._atRootLevel) n++;
}
} 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);
if(n > 0) {
for(var i = 0; i < n; i++) {
var ratio = 0.5 * i / n;
fillColor = Color.combine(Color.addOpacity(fadedColor, ratio), fillColor);
}
}
}
}
}

if(isRoot) {
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;
}
}

s.style('stroke-width', lineWidth)
.call(Color.fill, fillColor)
.call(Color.stroke, lineColor);
.call(Color.stroke, lineColor)
.style('opacity', opacity);
}

module.exports = {
Expand Down
Binary file modified test/image/baselines/treemap_coffee-maxdepth3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_packages_colorscale_allone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_packages_colorscale_novalue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_packings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_pad_mirror.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_pad_transpose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_sunburst_marker_colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_textfit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_textposition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_values_colorscale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_with-without_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/treemap_with-without_values_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1dff468

Please sign in to comment.