Skip to content

Carpet plot rebase #1595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
eee837f
Add ensure array lib function to allocate/resize
rreusser Apr 13, 2017
5a0b788
Add axis cartesian axis visibility option
rreusser Apr 13, 2017
89e095e
Add measureText function to drawing
rreusser Apr 13, 2017
e1a0417
Tweak showscale to allow unset (instead of strictly false)
rreusser Apr 13, 2017
620cd43
Contour plot lines to use non-scaling stroke
rreusser Apr 13, 2017
728a6f4
Genericize heatmap xyz variable names
rreusser Apr 13, 2017
c2994e7
More carefully track legend trace isolation indices
rreusser Apr 13, 2017
fe9850c
Add optional overrides to contour handleStyleDefaults
rreusser Apr 13, 2017
d1f2258
Genericize tolerances in find_all_paths to make way for carpet
rreusser Apr 13, 2017
4bcf438
Add flag to disable scatter marker culling (needed for carpet)
rreusser Apr 13, 2017
6b896d8
Tweak contour colorscale logic since carpet may set infinities
rreusser Apr 13, 2017
b8c71e1
Add group to plot
rreusser Apr 13, 2017
e4971ef
Carpet plots
rreusser Apr 13, 2017
c98553a
make rreusser's carpet tests pass
etpinard Apr 13, 2017
71b96f3
add a few carpet interaction tests
etpinard Apr 13, 2017
bc1c5c8
:hocho: arraytools dep (sorry @bpostlethwaite)
etpinard Apr 14, 2017
9c76d7a
exit early in axis defaults when visible is false
etpinard Apr 14, 2017
85d6b8a
add axis `visible: false` mock
etpinard Apr 14, 2017
54f092d
implement axis visible in 3D
etpinard Apr 14, 2017
d9cb011
add 3d axis `visible: false` mock
etpinard Apr 14, 2017
f1e8aee
Merge pull request #1596 from plotly/carpet-test-etienne
etpinard Apr 17, 2017
bc0f890
extendFlat -> slice
etpinard Apr 17, 2017
c2a7092
Merge pull request #1599 from plotly/axis-visible-3d
etpinard Apr 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/lib/ensure_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

/*
* Ensures an array has the right amount of storage space. If it doesn't
* exist, it creates an array. If it does exist, it returns it if too
* short or truncates it in-place.
*
* The goal is to just reuse memory to avoid a bit of excessive garbage
* collection.
*/
module.exports = function ensureArray(out, n) {
if(!Array.isArray(out)) out = [];

// If too long, truncate. (If too short, it will grow
// automatically so we don't care about that case)
out.length = n;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, never knew you could resize this way!

Copy link
Contributor Author

@rreusser rreusser Apr 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best I can tell, it's actually robust and supported across platforms. It's possible it does weird things internally (like not actually de-allocating that memory. I saw a while ago some discussion of the various internal string apis and string data structures in js. Hint: it's not straightforward). The main goal was to just overwrite the carpet spline stuff rather than allocating everything from scratch every time since that adds up to lots of garbage collection.

Copy link
Contributor

@etpinard etpinard Apr 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/length

The array length property sets or returns the number of elements in an array.

That's right, [..] sets or returns [..].

It's not a read-only property like one might assume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(best-case scenario though is that it actually truncates in-place without actually copying. I mean maybe copies, but slice() definitely copies.)


return out;
};
1 change: 1 addition & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lib.isArray = require('./is_array');
lib.mod = require('./mod');
lib.toLogRange = require('./to_log_range');
lib.relinkPrivateKeys = require('./relink_private');
lib.ensureArray = require('./ensure_array');

var coerceModule = require('./coerce');
lib.valObjects = coerceModule.valObjects;
Expand Down