Skip to content

Commit e79f045

Browse files
authored
Merge pull request #6216 from plotly/parcoords-unselected-line-color
add `unselected.line.color` and `unselected.line.opacity` options to `parcoords` trace
2 parents 9a2e727 + 9203fe5 commit e79f045

14 files changed

+203
-5
lines changed

draftlogs/6216_add.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add `unselected.line.color` and `unselected.line.opacity` options to `parcoords` trace [[#6216](https://github.com/plotly/plotly.js/pull/6216)]

src/traces/parcoords/attributes.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,33 @@ 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 base color of unselected lines.',
146+
'in connection with `unselected.line.opacity`.'
147+
].join(' ')
148+
},
149+
opacity: {
150+
valType: 'number',
151+
min: 0,
152+
max: 1,
153+
dflt: 'auto',
154+
editType: 'plot',
155+
description: [
156+
'Sets the opacity of unselected lines.',
157+
'The default *auto* decreases the opacity smoothly as the number of lines increases.',
158+
'Use *1* to achieve exact `unselected.line.color`.'
159+
].join(' ')
160+
},
161+
editType: 'plot'
162+
},
163+
editType: 'plot'
164+
}
137165
};

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
107107

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

src/traces/parcoords/lines.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ function makeItem(
183183
var layoutWidth = model.layoutWidth * plotGlPixelRatio;
184184

185185
var deselectedLinesColor = model.deselectedLines.color;
186+
var deselectedLinesOpacity = model.deselectedLines.opacity;
186187

187188
var itemModel = Lib.extendFlat({
188189
key: crossfilterDimensionIndex,
@@ -206,8 +207,8 @@ function makeItem(
206207
deselectedLinesColor[0] / 255,
207208
deselectedLinesColor[1] / 255,
208209
deselectedLinesColor[2] / 255,
209-
deselectedLinesColor[3] < 1 ?
210-
deselectedLinesColor[3] :
210+
deselectedLinesOpacity !== 'auto' ?
211+
deselectedLinesColor[3] * deselectedLinesOpacity :
211212
Math.max(1 / 255, Math.pow(1 / model.lines.color.length, 1 / 3))
212213
],
213214

src/traces/parcoords/parcoords.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ 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 = {
153+
color: rgba(trace.unselected.line.color),
154+
opacity: trace.unselected.line.opacity
155+
};
153156
var cOpts = Colorscale.extractOpts(line);
154157
var cscale = cOpts.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale;
155158
var domain = trace.domain;
Loading
Loading
Loading

test/image/mocks/gl2d_parcoords_256_colors.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"data": [
33
{
44
"type": "parcoords",
5+
"unselected": {
6+
"line": {
7+
"color": "blue"
8+
}
9+
},
510
"line": {
611
"colorscale": [
712
[

0 commit comments

Comments
 (0)