Skip to content

Commit abf1dd3

Browse files
committed
add unselected.line.color option
1 parent 3f9f36a commit abf1dd3

File tree

6 files changed

+156
-3
lines changed

6 files changed

+156
-3
lines changed

src/traces/parcoords/attributes.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,21 @@ module.exports = {
133133
autoColorDflt: false,
134134
editTypeOverride: 'calc'
135135
})
136-
)
136+
),
137+
138+
unselected: {
139+
line: {
140+
color: {
141+
valType: 'color',
142+
dflt: '#777',
143+
editType: 'plot',
144+
description: [
145+
'Sets the color of lines in the background',
146+
'i.e. unselected lines.'
147+
].join(' ')
148+
},
149+
editType: 'plot'
150+
},
151+
editType: 'plot'
152+
}
137153
};

src/traces/parcoords/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = {
1111
layers: ['contextLineLayer', 'focusLineLayer', 'pickLineLayer'],
1212
axisTitleOffset: 28,
1313
axisExtentOffset: 10,
14-
deselectedLineColor: '#777',
1514
bar: {
1615
width: 4, // Visible width of the filter bar
1716
captureWidth: 10, // Mouse-sensitive width for interaction (Fitts law)

src/traces/parcoords/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
107107

108108
coerce('labelangle');
109109
coerce('labelside');
110+
111+
coerce('unselected.line.color');
110112
};

src/traces/parcoords/parcoords.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function model(layout, d, i) {
149149
var trace = cd0.trace;
150150
var lineColor = helpers.convertTypedArray(cd0.lineColor);
151151
var line = trace.line;
152-
var deselectedLines = {color: rgba(c.deselectedLineColor)};
152+
var deselectedLines = {color: rgba(trace.unselected.line.color)};
153153
var cOpts = Colorscale.extractOpts(line);
154154
var cscale = cOpts.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale;
155155
var domain = trace.domain;

test/jasmine/tests/parcoords_test.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,128 @@ describe('parcoords Lifecycle methods', function() {
892892
})
893893
.then(done, done.fail);
894894
});
895+
896+
it('@gl unselected.line.color `Plotly.restyle` should change context layer line.color', function(done) {
897+
var testLayer = '.gl-canvas-context';
898+
899+
var list1 = [];
900+
var list2 = [];
901+
for(var i = 0; i <= 100; i++) {
902+
list1[i] = i;
903+
list2[i] = 100 - i;
904+
}
905+
906+
Plotly.newPlot(gd, [{
907+
type: 'parcoords',
908+
dimensions: [{
909+
constraintrange: [1, 10],
910+
values: list1
911+
}, {
912+
values: list2
913+
}],
914+
line: {color: '#0F0'},
915+
unselected: {line: {color: '#F00'}}
916+
}], {
917+
margin: {
918+
t: 0,
919+
b: 0,
920+
l: 0,
921+
r: 0
922+
},
923+
width: 300,
924+
height: 200
925+
})
926+
.then(function() {
927+
var rgb = getAvgPixelByChannel(testLayer);
928+
expect(rgb[0]).not.toBe(0, 'red');
929+
expect(rgb[1]).toBe(0, 'no green');
930+
expect(rgb[2]).toBe(0, 'no blue');
931+
932+
return Plotly.restyle(gd, 'unselected.line.color', '#00F');
933+
})
934+
.then(function() {
935+
var rgb = getAvgPixelByChannel(testLayer);
936+
expect(rgb[0]).toBe(0, 'no red');
937+
expect(rgb[1]).toBe(0, 'no green');
938+
expect(rgb[2]).not.toBe(0, 'blue');
939+
940+
return Plotly.restyle(gd, 'unselected.line.color', 'rgba(0,0,0,0)');
941+
})
942+
.then(function() {
943+
var rgb = getAvgPixelByChannel(testLayer);
944+
expect(rgb[0]).toBe(0, 'no red');
945+
expect(rgb[1]).toBe(0, 'no green');
946+
expect(rgb[2]).toBe(0, 'no blue');
947+
})
948+
.then(done, done.fail);
949+
});
950+
951+
it('@gl unselected.line.color `Plotly.react` should change line.color and unselected.line.color', function(done) {
952+
var unselectedLayer = '.gl-canvas-context';
953+
var selectedLayer = '.gl-canvas-focus';
954+
955+
var list1 = [];
956+
var list2 = [];
957+
for(var i = 0; i <= 100; i++) {
958+
list1[i] = i;
959+
list2[i] = 100 - i;
960+
}
961+
962+
var fig = {
963+
data: [{
964+
type: 'parcoords',
965+
dimensions: [{
966+
constraintrange: [1, 10],
967+
values: list1
968+
}, {
969+
values: list2
970+
}],
971+
line: {color: '#0F0'},
972+
unselected: {line: {color: '#F00'}}
973+
}],
974+
layout: {
975+
margin: {
976+
t: 0,
977+
b: 0,
978+
l: 0,
979+
r: 0
980+
},
981+
width: 300,
982+
height: 200
983+
}
984+
};
985+
986+
var rgb;
987+
988+
Plotly.newPlot(gd, fig)
989+
.then(function() {
990+
rgb = getAvgPixelByChannel(unselectedLayer);
991+
expect(rgb[0]).not.toBe(0, 'red');
992+
expect(rgb[1]).toBe(0, 'no green');
993+
expect(rgb[2]).toBe(0, 'no blue');
994+
995+
rgb = getAvgPixelByChannel(selectedLayer);
996+
expect(rgb[0]).toBe(0, 'no red');
997+
expect(rgb[1]).not.toBe(0, 'green');
998+
expect(rgb[2]).toBe(0, 'no blue');
999+
1000+
fig.data[0].line.color = '#FF0';
1001+
fig.data[0].unselected.line.color = '#00F';
1002+
return Plotly.react(gd, fig);
1003+
})
1004+
.then(function() {
1005+
rgb = getAvgPixelByChannel(selectedLayer);
1006+
expect(rgb[0]).not.toBe(0, 'red');
1007+
expect(rgb[1]).not.toBe(0, 'green');
1008+
expect(rgb[2]).toBe(0, 'no blue');
1009+
1010+
rgb = getAvgPixelByChannel(unselectedLayer);
1011+
expect(rgb[0]).toBe(0, 'no red');
1012+
expect(rgb[1]).toBe(0, 'no green');
1013+
expect(rgb[2]).not.toBe(0, 'blue');
1014+
})
1015+
.then(done, done.fail);
1016+
});
8951017
});
8961018

8971019
describe('parcoords hover', function() {

test/plot-schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40355,6 +40355,20 @@
4035540355
"editType": "none",
4035640356
"valType": "any"
4035740357
},
40358+
"unselected": {
40359+
"editType": "plot",
40360+
"line": {
40361+
"color": {
40362+
"description": "Sets the color of lines in the background i.e. unselected lines.",
40363+
"dflt": "#777",
40364+
"editType": "plot",
40365+
"valType": "color"
40366+
},
40367+
"editType": "plot",
40368+
"role": "object"
40369+
},
40370+
"role": "object"
40371+
},
4035840372
"visible": {
4035940373
"description": "Determines whether or not this trace is visible. If *legendonly*, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).",
4036040374
"dflt": true,

0 commit comments

Comments
 (0)