Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Common interface to interpret and execute API methods#1016
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f2d268d65f618d7ef0404edb6773f50fcaa60dd6344bc838793b825343dc3d465d24f3d2696e77db7f0357fcf967db5f1f26ad1ff986b4dc20ac69ff993ed799d7c8ef8c00946abec155df94a7d35ee35a554cade5a80ee45717b152de9e40c40b02df2d5bbFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,7 +11,6 @@ | ||
| var d3 = require('d3'); | ||
| var Plotly = require('../../plotly'); | ||
| var Plots = require('../../plots/plots'); | ||
| var Lib = require('../../lib'); | ||
| var Color = require('../color'); | ||
| @@ -21,7 +20,6 @@ var anchorUtils = require('../legend/anchor_utils'); | ||
| var constants = require('./constants'); | ||
| module.exports = function draw(gd) { | ||
| var fullLayout = gd._fullLayout, | ||
| menuData = makeMenuData(fullLayout); | ||
| @@ -115,6 +113,11 @@ module.exports = function draw(gd) { | ||
| headerGroups.each(function(menuOpts) { | ||
| var gHeader = d3.select(this); | ||
| var _gButton = menuOpts.type === 'dropdown' ? gButton : null; | ||
| Plots.manageCommandObserver(gd, menuOpts, menuOpts.buttons, function(data) { | ||
| setActive(gd, menuOpts, menuOpts.buttons[data.index], gHeader, _gButton, data.index, true); | ||
| }); | ||
| if(menuOpts.type === 'dropdown') { | ||
| drawHeader(gd, gHeader, gButton, menuOpts); | ||
| @@ -293,21 +296,9 @@ function drawButtons(gd, gHeader, gButton, menuOpts) { | ||
| .call(setItemPosition, menuOpts, posOpts); | ||
| button.on('click', function() { | ||
| // update 'active' attribute in menuOpts | ||
| menuOpts._input.active = menuOpts.active = buttonIndex; | ||
| // fold up buttons and redraw header | ||
| gButton.attr(constants.menuIndexAttrName, '-1'); | ||
| setActive(gd, menuOpts, buttonOpts, gHeader, gButton, buttonIndex); | ||
| if(menuOpts.type === 'dropdown') { | ||
| drawHeader(gd, gHeader, gButton, menuOpts); | ||
| } | ||
| drawButtons(gd, gHeader, gButton, menuOpts); | ||
| // call button method | ||
| var args = buttonOpts.args; | ||
| Plotly[buttonOpts.method](gd, args[0], args[1], args[2]); | ||
| Plots.executeAPICommand(gd, buttonOpts.method, buttonOpts.args); | ||
| }); | ||
| button.on('mouseover', function() { | ||
| @@ -326,6 +317,22 @@ function drawButtons(gd, gHeader, gButton, menuOpts) { | ||
| Lib.setTranslate(gButton, menuOpts.lx, menuOpts.ly); | ||
| } | ||
| function setActive(gd, menuOpts, buttonOpts, gHeader, gButton, buttonIndex, isSilentUpdate) { | ||
Contributor 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. nice abstraction | ||
| // update 'active' attribute in menuOpts | ||
| menuOpts._input.active = menuOpts.active = buttonIndex; | ||
| if(menuOpts.type === 'dropdown') { | ||
| // fold up buttons and redraw header | ||
| gButton.attr(constants.menuIndexAttrName, '-1'); | ||
| drawHeader(gd, gHeader, gButton, menuOpts); | ||
| } | ||
| if(!isSilentUpdate || menuOpts.type === 'buttons') { | ||
| drawButtons(gd, gHeader, gButton, menuOpts); | ||
| } | ||
| } | ||
| function drawItem(item, menuOpts, itemOpts) { | ||
| item.call(drawItemRect, menuOpts) | ||
| .call(drawItemText, menuOpts, itemOpts); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2302,14 +2302,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) { | ||
| var newFrame = trans._currentFrame = trans._frameQueue.shift(); | ||
| if(newFrame) { | ||
| gd.emit('plotly_animatingframe', { | ||
| name: newFrame.name, | ||
| frame: newFrame.frame, | ||
| animation: { | ||
| frame: newFrame.frameOpts, | ||
| transition: newFrame.transitionOpts, | ||
| } | ||
| }); | ||
| gd._fullLayout._currentFrame = newFrame.name; | ||
Contributor 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. Very nice. I'll use that for | ||
| trans._lastFrameAt = Date.now(); | ||
| trans._timeToNext = newFrame.frameOpts.duration; | ||
| @@ -2324,6 +2317,15 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) { | ||
| newFrame.frameOpts, | ||
| newFrame.transitionOpts | ||
| ); | ||
| gd.emit('plotly_animatingframe', { | ||
Contributor 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 can you share some info about why the
| ||
| name: newFrame.name, | ||
| frame: newFrame.frame, | ||
| animation: { | ||
| frame: newFrame.frameOpts, | ||
| transition: newFrame.transitionOpts, | ||
| } | ||
| }); | ||
| } else { | ||
| // If there are no more frames, then stop the RAF loop: | ||
| stopAnimationLoop(); | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
much cleaner 🎉