Skip to content

Commit 61b3baf

Browse files
committed
parcoords squashed
1 parent b823573 commit 61b3baf

25 files changed

+1988
-7
lines changed

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Plotly.register([
1818
require('./histogram'),
1919
require('./histogram2d'),
2020
require('./histogram2dcontour'),
21+
require('./parcoords'),
2122
require('./pie'),
2223
require('./contour'),
2324
require('./scatterternary'),

lib/parcoords.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = require('../src/traces/parcoords');

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@
7979
"mapbox-gl": "^0.22.0",
8080
"mouse-change": "^1.1.1",
8181
"mouse-wheel": "^1.0.2",
82-
"ndarray": "^1.0.16",
82+
"ndarray": "^1.0.18",
8383
"ndarray-fill": "^1.0.1",
8484
"ndarray-homography": "^1.0.0",
8585
"ndarray-ops": "^1.2.2",
86+
"regl": "^1.3.0",
8687
"right-now": "^1.0.0",
8788
"robust-orientation": "^1.1.3",
8889
"sane-topojson": "^2.0.0",
@@ -103,6 +104,7 @@
103104
"fs-extra": "^1.0.0",
104105
"fuse.js": "^2.2.0",
105106
"glob": "^7.0.0",
107+
"glslify": "^4.0.0",
106108
"gzip-size": "^3.0.0",
107109
"image-size": "^0.5.0",
108110
"jasmine-core": "^2.4.1",

src/components/updatemenus/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ function menuDefaults(menuIn, menuOut, layoutOut) {
6262
coerce('borderwidth');
6363
}
6464

65+
// todo consider unifying it with other similar array coercions
66+
// - though `Array.isArray(buttonIn.args)` is quite spedific...
6567
function buttonsDefaults(menuIn, menuOut) {
6668
var buttonsIn = menuIn.buttons || [],
6769
buttonsOut = menuOut.buttons = [];

src/traces/heatmap/colorbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var Plots = require('../../plots/plots');
1616
var Colorscale = require('../../components/colorscale');
1717
var drawColorbar = require('../../components/colorbar/draw');
1818

19-
19+
// TODO unify parcoords, scatter and heatmap colorbar
2020
module.exports = function colorbar(gd, cd) {
2121
var trace = cd[0].trace,
2222
cbId = 'cb' + trace.uid,

src/traces/parcoords/attributes.js

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var colorAttributes = require('../../components/colorscale/color_attributes');
12+
var colorbarAttrs = require('../../components/colorbar/attributes');
13+
14+
var extendFlat = require('../../lib/extend').extendFlat;
15+
16+
/*
17+
todo comments (some of them relating to items that should be unexposed anyway):
18+
- `domain` should be DRYed up across other plots
19+
- add attribute to `dimensions` for switching dimensions on/off
20+
- add attribute to `dimensions` for initial filter domain
21+
- clarify what the actual use of `_isLinkedToArray: 'dimension'` - esp. the value - is below
22+
- add attribute for color clamping
23+
- switch to ploty standard color notation rather than RGB tuple
24+
- switch to 0..1 for opacity rather than 0..255
25+
- tie pixelratio to window.devicePixelRatio in `defaults.js`
26+
- consider if we need a `focusopacity` attribute besides focusalphablending; making settings more symmetric between
27+
focus and context
28+
- hardcode verticalpadding
29+
- this minor but ergonomic `integerpadding` isn't fully working yet - either finish it or remove it
30+
*/
31+
32+
module.exports = {
33+
34+
domain: {
35+
x: {
36+
valType: 'info_array',
37+
role: 'info',
38+
items: [
39+
{valType: 'number', min: 0, max: 1},
40+
{valType: 'number', min: 0, max: 1}
41+
],
42+
dflt: [0, 1],
43+
description: [
44+
'Sets the horizontal domain of this `parcoords` trace',
45+
'(in plot fraction).'
46+
].join(' ')
47+
},
48+
y: {
49+
valType: 'info_array',
50+
role: 'info',
51+
items: [
52+
{valType: 'number', min: 0, max: 1},
53+
{valType: 'number', min: 0, max: 1}
54+
],
55+
dflt: [0, 1],
56+
description: [
57+
'Sets the vertical domain of this `parcoords` trace',
58+
'(in plot fraction).'
59+
].join(' ')
60+
}
61+
},
62+
63+
dimensions: {
64+
_isLinkedToArray: 'dimension',
65+
id: {
66+
valType: 'string',
67+
role: 'info',
68+
description: 'Identifier of a dimension. Must be a unique string across all dimensions.'
69+
},
70+
label: {
71+
valType: 'string',
72+
role: 'info',
73+
description: 'The shown name of the dimension.'
74+
},
75+
integer: {
76+
valType: 'boolean',
77+
dflt: false,
78+
role: 'info',
79+
description: 'The shown name of the dimension.'
80+
},
81+
values: {
82+
valType: 'data_array',
83+
role: 'info',
84+
description: [
85+
'Dimension values. `values[n]` represents the value of the `n`th point in the dataset,',
86+
'therefore the `values` vector for all dimensions must be the same (longer vectors',
87+
'will be truncated). Each value must be a finite number.'
88+
].join(' ')
89+
},
90+
description: 'The dimensions (variables) of the parallel coordinates chart.'
91+
},
92+
93+
tickdistance: {
94+
valType: 'number',
95+
dflt: 50,
96+
min: 32,
97+
role: 'style',
98+
description: 'The desired approximate tick distance (in pixels) between axis ticks on an axis.'
99+
},
100+
101+
line: extendFlat({},
102+
colorAttributes('line'),
103+
{
104+
showscale: {
105+
valType: 'boolean',
106+
role: 'info',
107+
dflt: false,
108+
description: [
109+
'Has an effect only if `marker.color` is set to a numerical array.',
110+
'Determines whether or not a colorbar is displayed.'
111+
].join(' ')
112+
},
113+
colorbar: colorbarAttrs
114+
}
115+
),
116+
117+
lines: {
118+
contextcolor: {
119+
valType: 'data_array',
120+
dflt: [0, 0, 0],
121+
role: 'style',
122+
description: 'Color of the context line layer as an RGB triplet where each number is 0..255.'
123+
},
124+
125+
contextopacity: {
126+
valType: 'number',
127+
dflt: 16,
128+
min: 0,
129+
max: 255,
130+
role: 'style',
131+
description: 'Opacity of the context lines, on a scale of 0 (invisible) to 255 (fully opaque).'
132+
},
133+
134+
pixelratio: {
135+
valType: 'number',
136+
dflt: 1,
137+
min: 0.25,
138+
max: 4,
139+
role: 'style',
140+
description: 'Line rendering pixel ratio. A lower value yields faster rendering but blockier lines.'
141+
},
142+
143+
blocklinecount: {
144+
valType: 'number',
145+
dflt: 5000,
146+
min: 1,
147+
role: 'info',
148+
description: [
149+
'The number of lines rendered in one 16ms rendering frame. Use 2000-5000 on low-end hardware to remain',
150+
'responsive, and 10000 .. 100000 on strong hardware for faster rendering.'
151+
].join(' ')
152+
},
153+
154+
focusalphablending: {
155+
valType: 'boolean',
156+
dflt: false,
157+
role: 'style',
158+
description: [
159+
'By default, the rendered lines are opaque. Setting it to `true` is necessary if opacity is needed.'
160+
].join(' ')
161+
},
162+
163+
verticalpadding: {
164+
valType: 'number',
165+
dflt: 2,
166+
min: 0,
167+
max: 4,
168+
role: 'style',
169+
description: 'Lines have thickness, and without padding, horizontal lines at extreme values appear thinner.'
170+
},
171+
172+
integerpadding: {
173+
valType: 'number',
174+
dflt: 0,
175+
min: 0,
176+
max: 1,
177+
role: 'style',
178+
description: 'Setting it to `1` offsets the extreme points on integer axes by half pitch.'
179+
}
180+
},
181+
182+
filterbar: {
183+
184+
width: {
185+
valType: 'number',
186+
dflt: 4,
187+
min: 2,
188+
max: 20,
189+
role: 'style',
190+
description: 'Visible width of the filter bar.'
191+
},
192+
193+
fillcolor: {
194+
valType: 'color',
195+
dflt: 'magenta',
196+
role: 'style',
197+
description: 'Color of the filter bar fill.'
198+
},
199+
200+
fillopacity: {
201+
valType: 'number',
202+
dflt: 1,
203+
min: 0,
204+
max: 1,
205+
role: 'style',
206+
description: 'Filter bar fill opacity.'
207+
},
208+
209+
strokecolor: {
210+
valType: 'color',
211+
dflt: 'white',
212+
role: 'style',
213+
description: 'Color of the filter bar side lines.'
214+
},
215+
216+
strokeopacity: {
217+
valType: 'number',
218+
dflt: 1,
219+
min: 0,
220+
max: 1,
221+
arrayOk: true,
222+
role: 'style',
223+
description: 'Filter bar side stroke opacity.'
224+
},
225+
226+
strokewidth: {
227+
valType: 'number',
228+
dflt: 1,
229+
min: 0,
230+
max: 2,
231+
role: 'style',
232+
description: 'Filter bar side stroke width.'
233+
},
234+
235+
handleheight: {
236+
valType: 'number',
237+
dflt: 16,
238+
min: 2,
239+
max: 20,
240+
role: 'style',
241+
description: 'Height of the filter bar vertical resize areas on top and bottom.'
242+
},
243+
244+
handleopacity: {
245+
valType: 'number',
246+
dflt: 1,
247+
min: 0,
248+
max: 1,
249+
arrayOk: true,
250+
role: 'style',
251+
description: 'Opacity of the filter bar vertical resize areas on top and bottom.'
252+
},
253+
254+
handleoverlap: {
255+
valType: 'number',
256+
dflt: 0,
257+
min: 0,
258+
max: 4,
259+
role: 'style',
260+
description: [
261+
'If zero, the vertical resize areas on top and bottom are just above and below the filter bar itself.',
262+
'A larger than zero value causes overlaps with the filter bar. The overlap is represented as pixels.'
263+
].join(' ')
264+
}
265+
}
266+
};

src/traces/parcoords/base_plot.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
var Registry = require('../../registry');
12+
13+
14+
exports.name = 'paroords';
15+
16+
exports.plot = function(gd) {
17+
var Parcoords = Registry.getModule('parcoords');
18+
var cdParcoords = getCdModule(gd.calcdata, Parcoords);
19+
20+
if(cdParcoords.length) Parcoords.plot(gd, cdParcoords);
21+
};
22+
23+
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
24+
var hadParcoords = (oldFullLayout._has && oldFullLayout._has('parcoords'));
25+
var hasParcoords = (newFullLayout._has && newFullLayout._has('parcoords'));
26+
27+
if(hadParcoords && !hasParcoords) {
28+
oldFullLayout._parcoordslayer.selectAll('g.trace').remove();
29+
}
30+
};
31+
32+
function getCdModule(calcdata, _module) {
33+
var cdModule = [];
34+
35+
for(var i = 0; i < calcdata.length; i++) {
36+
var cd = calcdata[i];
37+
var trace = cd[0].trace;
38+
39+
if((trace._module === _module) && (trace.visible === true)) {
40+
cdModule.push(cd);
41+
}
42+
}
43+
44+
return cdModule;
45+
}

0 commit comments

Comments
 (0)