Skip to content

Commit 806c5dc

Browse files
authored
feat: reverse fill color for histograms (#4374)
Histogram reverse sorts by step number and, previously, the first step was the darkest while the last step was the faintest. While this works for most colors, it does not work well for gray based colors. Now, it is true that we have a different set of color palettes in time series and it is less of the problem but now that we let users tweak the run color, it is easy to imagine user picked color being a problem in the histograms. To alleviate the problem, we gave the most important step, the last one, the most salient color.
1 parent be76611 commit 806c5dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tensorboard/plugins/histogram/vz_histogram_timeseries/vz-histogram-timeseries.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ class _VzHistogramTimeseries
419419
.scaleLinear()
420420
.domain(xScale.domain())
421421
.range([0, outlineCanvasSize]);
422-
var outlineColor = d3
422+
const fillColor = d3
423423
.scaleLinear()
424424
.domain(d3.extent(data, timeAccessor))
425-
.range([color.darker(), color.brighter()])
425+
.range([color.brighter(), color.darker()])
426426
.interpolate(d3.interpolateHcl);
427427
var xAxis = d3.axisBottom(xScale).ticks(Math.max(2, width / 20));
428428
var yAxis = d3
@@ -548,19 +548,19 @@ class _VzHistogramTimeseries
548548
')'
549549
)
550550
.style('stroke', function (d) {
551-
return mode === 'offset' ? 'white' : outlineColor(timeAccessor(d));
551+
return mode === 'offset' ? 'white' : fillColor(timeAccessor(d));
552552
})
553553
.style('fill-opacity', function (d) {
554554
return mode === 'offset' ? 1 : 0;
555555
})
556556
.style('fill', function (d) {
557-
return outlineColor(timeAccessor(d));
557+
return fillColor(timeAccessor(d));
558558
});
559559
var hoverEnter = histogramEnter.append('g').attr('class', 'hover');
560560
var hoverUpdate = histogramUpdate
561561
.select('.hover')
562562
.style('fill', function (d) {
563-
return outlineColor(timeAccessor(d));
563+
return fillColor(timeAccessor(d));
564564
});
565565
hoverEnter.append('circle').attr('r', 2);
566566
hoverEnter.append('text').style('display', 'none').attr('dx', 4);

0 commit comments

Comments
 (0)