Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d42a66

Browse files
authored
Merge pull request plotly#3917 from plotly/fix3820-parcoords-rgba-colorscale
treating rgba colors similar to rgb on parallel coordinates
2 parents 7c28505 + 3834bd1 commit 2d42a66

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/traces/parcoords/parcoords.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'use strict';
1010

1111
var d3 = require('d3');
12+
var rgba = require('color-rgba');
1213

1314
var Lib = require('../../lib');
1415
var Drawing = require('../../components/drawing');
@@ -102,7 +103,10 @@ function ordinalScale(dimension) {
102103

103104
function unitToColorScale(cscale) {
104105
var colorStops = cscale.map(function(d) { return d[0]; });
105-
var colorTuples = cscale.map(function(d) { return d3.rgb(d[1]); });
106+
var colorTuples = cscale.map(function(d) {
107+
var RGBA = rgba(d[1]);
108+
return d3.rgb('rgb(' + RGBA[0] + ',' + RGBA[1] + ',' + RGBA[2] + ')');
109+
});
106110
var prop = function(n) { return function(o) { return o[n]; }; };
107111

108112
// We can't use d3 color interpolation as we may have non-uniform color palette raster
Loading
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"data": [
3+
{
4+
"dimensions": [
5+
{
6+
"values": [
7+
0,
8+
1
9+
]
10+
},
11+
{
12+
"values": [
13+
1,
14+
0
15+
]
16+
}
17+
],
18+
"line": {
19+
"cmax": 1,
20+
"cmin": 0,
21+
"color": [
22+
0,
23+
1
24+
],
25+
"colorscale": [
26+
[
27+
0,
28+
"rgba(255,0,0,1)"
29+
],
30+
[
31+
1,
32+
"rgba(0,0,255,1)"
33+
]
34+
],
35+
"showscale": true
36+
},
37+
"type": "parcoords"
38+
}
39+
],
40+
"layout": {
41+
"width": 400,
42+
"height": 400,
43+
"title": {
44+
"text": "should work with rgba colorscale"
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)