Skip to content

Sankey feature branch #1591

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 26 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1656c5b
squashed Sankey feature branch for 1st look
monfera Feb 22, 2017
e7892fe
PR feedback and other updates to Sankey
monfera Apr 13, 2017
65b2d57
fix up bundle files
monfera Apr 28, 2017
aa41f28
removed colorbar leftover
monfera Apr 28, 2017
dec701a
unit shown in attribute doc
monfera Apr 28, 2017
1fb7cbd
removed vestigial attribs
monfera May 1, 2017
426b50d
flipping attrib representation to columnar
monfera May 1, 2017
dab87ae
circularity detection
monfera May 1, 2017
fdf9849
Revert "removed colorbar leftover"
monfera May 1, 2017
62257b4
restore dist to what was before
monfera May 1, 2017
4ea240f
mock update
monfera May 1, 2017
4e98b12
working around image gen sensitivity
monfera May 1, 2017
747eb23
Alex's suggestion for checking self-links too
monfera May 1, 2017
1cbc2f2
attribute work:
monfera May 1, 2017
e69e3a2
attribute work:
monfera May 1, 2017
90c003a
having published our d3-sankey fork under the @plotly scope
monfera May 2, 2017
3d10714
using traceOut in defaults for downstream default generation
monfera May 2, 2017
a2a416e
jasmine tests for Sankey
monfera May 2, 2017
3e2a455
jasmine tests for Sankey - warning / error test (and defaults.js improv)
monfera May 2, 2017
b91aa25
default empty arrays in attributes.js
monfera May 2, 2017
223421e
warning message update (PR feedback, thanks Alex!)
monfera May 2, 2017
4c3521a
removed unused colorbar
monfera May 2, 2017
af1c43b
PR feedback: noOpacity; no need to add toSVG; no empty line after fun…
monfera May 9, 2017
9214c92
PR feedback: moved circularity check into calc.js
monfera May 9, 2017
aa83612
PR feedback: testing lifecycle methods and visible; file rename
monfera May 9, 2017
7427284
PR feedback: hover tooltip tests; switching to addTraces
monfera May 9, 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
File renamed without changes.
65 changes: 64 additions & 1 deletion test/jasmine/tests/sankey_test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
var Plotly = require('@lib/index');
var attributes = require('@src/traces/sankey/attributes');
var Lib = require('@src/lib');
var mock = require('@mocks/energy.json');
var d3 = require('d3');
var mock = require('@mocks/sankey_energy.json');
var mockDark = require('@mocks/sankey_energy_dark.json');
var Plots = require('@src/plots/plots');
var Sankey = require('@src/traces/sankey');

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');

describe('sankey tests', function() {

'use strict';
Expand Down Expand Up @@ -248,4 +254,61 @@ describe('sankey tests', function() {
});
});
});

describe('lifecycle methods', function() {

afterEach(destroyGraphDiv);

it('Plotly.deleteTraces with two traces removes the deleted plot', function(done) {

var gd = createGraphDiv();
var mockCopy = Lib.extendDeep({}, mock);
var mockCopy2 = Lib.extendDeep({}, mockDark);

Plotly.plot(gd, mockCopy)
.then(function() {
expect(gd.data.length).toEqual(1);
expect(d3.selectAll('.sankey').size()).toEqual(1);
return Plotly.plot(gd, mockCopy2);
Copy link
Contributor

@etpinard etpinard May 9, 2017

Choose a reason for hiding this comment

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

Testing addTraces would be better. Sequential Plotly.plot calls is a deprecated pattern.

})
.then(function() {
expect(gd.data.length).toEqual(2);
expect(d3.selectAll('.sankey').size()).toEqual(2);
return Plotly.deleteTraces(gd, [0]);
})
.then(function() {
expect(gd.data.length).toEqual(1);
expect(d3.selectAll('.sankey').size()).toEqual(1);
return Plotly.deleteTraces(gd, 0);
})
.then(function() {
expect(gd.data.length).toEqual(0);
expect(d3.selectAll('.sankey').size()).toEqual(0);
done();
});
});

it('Plotly.plot does not show Sankey if \'visible\' is false', function(done) {

var gd = createGraphDiv();
var mockCopy = Lib.extendDeep({}, mock);

Plotly.plot(gd, mockCopy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good!

.then(function() {
expect(gd.data.length).toEqual(1);
expect(d3.selectAll('.sankey').size()).toEqual(1);
return Plotly.restyle(gd, 'visible', false);
})
.then(function() {
expect(gd.data.length).toEqual(1);
expect(d3.selectAll('.sankey').size()).toEqual(0);
return Plotly.restyle(gd, 'visible', true);
})
.then(function() {
expect(gd.data.length).toEqual(1);
expect(d3.selectAll('.sankey').size()).toEqual(1);
done();
});
});
});
});