Skip to content

Parcoords: Use paper background color for text shadow for better dark mode #5506

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 6 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
8 changes: 4 additions & 4 deletions src/traces/parcoords/axisbrush.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function attachDragBehavior(selection) {

function startAsc(a, b) { return a[0] - b[0]; }

function renderAxisBrush(axisBrush) {
function renderAxisBrush(axisBrush, paperColor) {
var background = axisBrush.selectAll('.background').data(repeat);

background.enter()
Expand All @@ -378,7 +378,7 @@ function renderAxisBrush(axisBrush) {
.classed('highlight-shadow', true)
.attr('x', -c.bar.width / 2)
.attr('stroke-width', c.bar.width + c.bar.strokeWidth)
.attr('stroke', c.bar.strokeColor)
.attr('stroke', paperColor)
.attr('opacity', c.bar.strokeOpacity)
.attr('stroke-linecap', 'butt');

Expand All @@ -402,15 +402,15 @@ function renderAxisBrush(axisBrush) {
.call(styleHighlight);
}

function ensureAxisBrush(axisOverlays) {
function ensureAxisBrush(axisOverlays, paperColor) {
var axisBrush = axisOverlays.selectAll('.' + c.cn.axisBrush)
.data(repeat, keyFun);

axisBrush.enter()
.append('g')
.classed(c.cn.axisBrush, true);

renderAxisBrush(axisBrush);
renderAxisBrush(axisBrush, paperColor);
}

function getBrushExtent(brush) {
Expand Down
1 change: 0 additions & 1 deletion src/traces/parcoords/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = {
snapDuration: 150, // tween duration in ms for brush snap for ordinal axes
snapRatio: 0.25, // ratio of bar extension relative to the distance between two adjacent ordinal values
snapClose: 0.01, // fraction of inter-value distance to snap to the closer one, even if you're not over it
strokeColor: 'white', // Color of the filter bar side lines
strokeOpacity: 1, // Filter bar side stroke opacity
strokeWidth: 1, // Filter bar side stroke width in pixels
handleHeight: 8, // Height of the filter bar vertical resize areas on top and bottom
Expand Down
11 changes: 9 additions & 2 deletions src/traces/parcoords/parcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
var fullLayout = gd._fullLayout;
var svg = fullLayout._toppaper;
var glContainer = fullLayout._glcontainer;
var paperColor = gd._fullLayout.paper_bgcolor;

calcAllTicks(cdModule);

Expand All @@ -451,6 +452,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
.each(function(d) {
// FIXME: figure out how to handle multiple instances
d.viewModel = vm[0];
d.viewModel.paperColor = paperColor;
d.model = d.viewModel ? d.viewModel.model : null;
});

Expand Down Expand Up @@ -647,7 +649,12 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
.attr('stroke-width', '1px');

axis.selectAll('text')
.style('text-shadow', '1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff')
.style('text-shadow',
paperColor + ' 1px 1px 1px, ' +
paperColor + ' -1px -1px 1px, ' +
paperColor + ' 1px -1px 1px, ' +
paperColor + ' -1px 1px 1px'
)
.style('cursor', 'default');

var axisHeading = axisOverlays.selectAll('.' + c.cn.axisHeading)
Expand Down Expand Up @@ -749,5 +756,5 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
.text(function(d) { return extremeText(d, false); })
.each(function(d) { Drawing.font(d3.select(this), d.model.rangeFont); });

brush.ensureAxisBrush(axisOverlays);
brush.ensureAxisBrush(axisOverlays, paperColor);
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions test/image/mocks/gl2d_parcoords_dark_background.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"layout": {
"width": 284,
"height": 400,
"font": {"color": "white"},
"paper_bgcolor": "black"
},

"data": [
{
"type" : "parcoords",
"dimensions" : [
{
"label" : "Dimension A",
"constraintrange": [1.75, 3.25],
"values" : [4, 3, 2, 1, 0]
},
{
"label" : "Dimension B",
"values" : [0, 1, 2, 3, 4]
}
]
}
]
}