-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Modify Plotly.plot to accept frames #1014 #1054
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ var subroutines = require('@src/plot_api/subroutines'); | |
var d3 = require('d3'); | ||
var createGraphDiv = require('../assets/create_graph_div'); | ||
var destroyGraphDiv = require('../assets/destroy_graph_div'); | ||
var fail = require('../assets/fail_test'); | ||
|
||
|
||
describe('Test plot api', function() { | ||
|
@@ -22,6 +23,69 @@ describe('Test plot api', function() { | |
}); | ||
}); | ||
|
||
describe('Plotly.plot', function() { | ||
var gd; | ||
|
||
beforeEach(function() { | ||
gd = createGraphDiv(); | ||
}); | ||
|
||
afterEach(destroyGraphDiv); | ||
|
||
it('accepts gd, data, layout, and config as args', function(done) { | ||
Plotly.plot(gd, | ||
[{x: [1, 2, 3], y: [1, 2, 3]}], | ||
{width: 500, height: 500}, | ||
{editable: true} | ||
).then(function() { | ||
expect(gd.layout.width).toEqual(500); | ||
expect(gd.layout.height).toEqual(500); | ||
expect(gd.data.length).toEqual(1); | ||
expect(gd._context.editable).toBe(true); | ||
}).catch(fail).then(done); | ||
}); | ||
|
||
it('accepts gd and an object as args', function(done) { | ||
Plotly.plot(gd, { | ||
data: [{x: [1, 2, 3], y: [1, 2, 3]}], | ||
layout: {width: 500, height: 500}, | ||
config: {editable: true}, | ||
frames: [{y: [2, 1, 0], name: 'frame1'}] | ||
}).then(function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rreusser does Plotly.plot(gd, {
data: [],
frames: [ /* some initial list of frames */ ]
})
.then((gd) => {
// add more frames!!
Plotly.addFrames(gd), [ /* more frames !! */ ]);
}) work as expected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup!
But srsly, added this test and just pushed. |
||
expect(gd.layout.width).toEqual(500); | ||
expect(gd.layout.height).toEqual(500); | ||
expect(gd.data.length).toEqual(1); | ||
expect(gd._transitionData._frames.length).toEqual(1); | ||
expect(gd._context.editable).toBe(true); | ||
}).catch(fail).then(done); | ||
}); | ||
|
||
it('allows adding more frames to the initial set', function(done) { | ||
Plotly.plot(gd, { | ||
data: [{x: [1, 2, 3], y: [1, 2, 3]}], | ||
layout: {width: 500, height: 500}, | ||
config: {editable: true}, | ||
frames: [{y: [7, 7, 7], name: 'frame1'}] | ||
}).then(function() { | ||
expect(gd.layout.width).toEqual(500); | ||
expect(gd.layout.height).toEqual(500); | ||
expect(gd.data.length).toEqual(1); | ||
expect(gd._transitionData._frames.length).toEqual(1); | ||
expect(gd._context.editable).toBe(true); | ||
|
||
return Plotly.addFrames(gd, [ | ||
{y: [8, 8, 8], name: 'frame2'}, | ||
{y: [9, 9, 9], name: 'frame3'} | ||
]); | ||
}).then(function() { | ||
expect(gd._transitionData._frames.length).toEqual(3); | ||
expect(gd._transitionData._frames[0].name).toEqual('frame1'); | ||
expect(gd._transitionData._frames[1].name).toEqual('frame2'); | ||
expect(gd._transitionData._frames[2].name).toEqual('frame3'); | ||
}).catch(fail).then(done); | ||
}); | ||
}); | ||
|
||
describe('Plotly.relayout', function() { | ||
var gd; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why after
drawFramework
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it.
Plots.supplyDefaults(gd);
is called synchronously in the above function body so yeah, switching those two should be fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Of course you could now ask the opposite question, but I think loading data first is nicer.)