Skip to content

Commit fdf9849

Browse files
committed
Revert "removed colorbar leftover"
This reverts commit aa41f28.
1 parent dab87ae commit fdf9849

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/traces/parcoords/colorbar.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright 2012-2017, 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+
10+
'use strict';
11+
12+
var isNumeric = require('fast-isnumeric');
13+
14+
var Lib = require('../../lib');
15+
var Plots = require('../../plots/plots');
16+
var Colorscale = require('../../components/colorscale');
17+
var drawColorbar = require('../../components/colorbar/draw');
18+
19+
20+
module.exports = function colorbar(gd, cd) {
21+
var trace = cd[0].trace,
22+
line = trace.line,
23+
cbId = 'cb' + trace.uid;
24+
25+
gd._fullLayout._infolayer.selectAll('.' + cbId).remove();
26+
27+
if((line === undefined) || !line.showscale) {
28+
Plots.autoMargin(gd, cbId);
29+
return;
30+
}
31+
32+
var vals = line.color,
33+
cmin = line.cmin,
34+
cmax = line.cmax;
35+
36+
if(!isNumeric(cmin)) cmin = Lib.aggNums(Math.min, null, vals);
37+
if(!isNumeric(cmax)) cmax = Lib.aggNums(Math.max, null, vals);
38+
39+
var cb = cd[0].t.cb = drawColorbar(gd, cbId);
40+
var sclFunc = Colorscale.makeColorScaleFunc(
41+
Colorscale.extractScale(
42+
line.colorscale,
43+
cmin,
44+
cmax
45+
),
46+
{ noNumericCheck: true }
47+
);
48+
49+
cb.fillcolor(sclFunc)
50+
.filllevels({start: cmin, end: cmax, size: (cmax - cmin) / 254})
51+
.options(line.colorbar)();
52+
};

src/traces/parcoords/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Parcoords.attributes = require('./attributes');
1414
Parcoords.supplyDefaults = require('./defaults');
1515
Parcoords.calc = require('./calc');
1616
Parcoords.plot = require('./plot');
17+
Parcoords.colorbar = require('./colorbar');
1718

1819
Parcoords.moduleType = 'trace';
1920
Parcoords.name = 'parcoords';

0 commit comments

Comments
 (0)