Skip to content

Commit ba0e3a5

Browse files
authored
Merge pull request #1595 from plotly/carpet-rebase
Carpet plot rebase
2 parents 6255f6d + c2a7092 commit ba0e3a5

File tree

152 files changed

+15665
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+15665
-98
lines changed

lib/carpet.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
'use strict';
10+
11+
module.exports = require('../src/traces/carpet');

lib/contourcarpet.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
'use strict';
10+
11+
module.exports = require('../src/traces/contourcarpet');

lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Plotly.register([
3636

3737
require('./scattermapbox'),
3838

39+
require('./carpet'),
40+
require('./scattercarpet'),
41+
require('./contourcarpet'),
42+
3943
require('./ohlc'),
4044
require('./candlestick')
4145
]);

lib/scattercarpet.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
'use strict';
10+
11+
module.exports = require('../src/traces/scattercarpet');

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"dependencies": {
5656
"3d-view": "^2.0.0",
5757
"alpha-shape": "^1.0.0",
58-
"arraytools": "^1.0.0",
5958
"color-rgba": "^1.0.4",
6059
"convex-hull": "^1.0.3",
6160
"country-regex": "^1.1.0",

src/components/drawing/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,13 @@ drawing.setPointGroupScale = function(selection, x, y) {
678678

679679
return scale;
680680
};
681+
682+
drawing.measureText = function(tester, text, font) {
683+
var dummyText = tester.append('text')
684+
.text(text)
685+
.call(drawing.font, font);
686+
687+
var bbox = drawing.bBox(dummyText.node());
688+
dummyText.remove();
689+
return bbox;
690+
};

src/components/legend/draw.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ function handleClick(g, gd, numClicks) {
512512

513513
for(i = 0; i < fullData.length; i++) {
514514
allTraces.push(i);
515+
// Allow the legendonly state through for *all* trace types (including
516+
// carpet for which it's overridden with true/false in supplyDefaults)
515517
traceVisibility.push('legendonly');
516518
}
517519

@@ -542,7 +544,11 @@ function handleClick(g, gd, numClicks) {
542544
if(sameAsLast) {
543545
traceVisibility = true;
544546
}
545-
Plotly.restyle(gd, 'visible', traceVisibility, allTraces);
547+
var visibilityUpdates = [];
548+
for(i = 0; i < fullData.length; i++) {
549+
visibilityUpdates.push(allTraces[i]);
550+
}
551+
Plotly.restyle(gd, 'visible', traceVisibility, visibilityUpdates);
546552
}
547553
}
548554
}

src/components/legend/style.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function styleLines(d) {
6565
showFill = trace.visible && trace.fill && trace.fill !== 'none',
6666
showLine = subTypes.hasLines(trace);
6767

68+
if(trace && trace._module && trace._module.name === 'contourcarpet') {
69+
showLine = trace.contours.showlines;
70+
showFill = trace.contours.coloring === 'fill';
71+
}
72+
6873
var fill = d3.select(this).select('.legendfill').selectAll('path')
6974
.data(showFill ? [d] : []);
7075
fill.enter().append('path').classed('js-fill', true);

src/lib/ensure_array.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
'use strict';
10+
11+
/*
12+
* Ensures an array has the right amount of storage space. If it doesn't
13+
* exist, it creates an array. If it does exist, it returns it if too
14+
* short or truncates it in-place.
15+
*
16+
* The goal is to just reuse memory to avoid a bit of excessive garbage
17+
* collection.
18+
*/
19+
module.exports = function ensureArray(out, n) {
20+
if(!Array.isArray(out)) out = [];
21+
22+
// If too long, truncate. (If too short, it will grow
23+
// automatically so we don't care about that case)
24+
out.length = n;
25+
26+
return out;
27+
};

src/lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ lib.isArray = require('./is_array');
1919
lib.mod = require('./mod');
2020
lib.toLogRange = require('./to_log_range');
2121
lib.relinkPrivateKeys = require('./relink_private');
22+
lib.ensureArray = require('./ensure_array');
2223

2324
var coerceModule = require('./coerce');
2425
lib.valObjects = coerceModule.valObjects;

0 commit comments

Comments
 (0)