Skip to content

Commit 5955336

Browse files
committed
add unselected.line.opacity & use color.a directly
1 parent 8645d4d commit 5955336

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

draftlogs/6216_add.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Add `unselected.line.color` option to `parcoords` trace [[#6216](https://github.com/plotly/plotly.js/pull/6216)]
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

+9-4
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,15 @@ module.exports = {
141141
valType: 'color',
142142
dflt: '#777',
143143
editType: 'plot',
144-
description: [
145-
'Sets the color of lines in the background',
146-
'i.e. unselected lines.'
147-
].join(' ')
144+
description: 'Sets the color of unselected lines.'
145+
},
146+
opacity: {
147+
valType: 'number',
148+
min: 0,
149+
max: 1,
150+
dflt: 'auto',
151+
editType: 'plot',
152+
description: 'Sets the opacity of unselected lines.'
148153
},
149154
editType: 'plot'
150155
},

src/traces/parcoords/defaults.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
7171
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
7272
}
7373

74+
function coerce2(attr, dflt) {
75+
return Lib.coerce2(traceIn, traceOut, attributes, attr, dflt);
76+
}
77+
7478
var dimensionsIn = traceIn.dimensions;
7579
if(Array.isArray(dimensionsIn) && dimensionsIn.length > maxDimensionCount) {
7680
Lib.log('parcoords traces support up to ' + maxDimensionCount + ' dimensions at the moment');
@@ -108,5 +112,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
108112
coerce('labelangle');
109113
coerce('labelside');
110114

111-
coerce('unselected.line.color');
115+
var unselectedLineColor = coerce2('unselected.line.color');
116+
coerce('unselected.line.opacity', unselectedLineColor ? 1 : 'auto');
112117
};

src/traces/parcoords/lines.js

+3-2
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

+4-1
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(trace.unselected.line.color)};
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;

test/plot-schema.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -40359,12 +40359,20 @@
4035940359
"editType": "plot",
4036040360
"line": {
4036140361
"color": {
40362-
"description": "Sets the color of lines in the background i.e. unselected lines.",
40362+
"description": "Sets the color of unselected lines.",
4036340363
"dflt": "#777",
4036440364
"editType": "plot",
4036540365
"valType": "color"
4036640366
},
4036740367
"editType": "plot",
40368+
"opacity": {
40369+
"description": "Sets the opacity of unselected lines.",
40370+
"dflt": "auto",
40371+
"editType": "plot",
40372+
"max": 1,
40373+
"min": 0,
40374+
"valType": "number"
40375+
},
4036840376
"role": "object"
4036940377
},
4037040378
"role": "object"

0 commit comments

Comments
 (0)