Skip to content

Commit 0f23eef

Browse files
committed
jsDoc for animate, addFrames, and deleteFrames
1 parent 2bc29b8 commit 0f23eef

File tree

2 files changed

+43
-16
lines changed

2 files changed

+43
-16
lines changed

src/plot_api/plot_api.js

+39-15
Original file line numberDiff line numberDiff line change
@@ -2456,12 +2456,31 @@ Plotly.relayout = function relayout(gd, astr, val) {
24562456
};
24572457

24582458
/**
2459-
* Animate to a keyframe
2459+
* Animate to a frame, sequence of frame, frame group, or frame definition
2460+
*
2461+
* @param {string id or DOM element} gd
2462+
* the id or DOM element of the graph container div
2463+
*
2464+
* @param {string or object or array of strings or array of objects} frameOrGroupNameOrFrameList
2465+
* a single frame, array of frames, or group to which to animate. The intent is
2466+
* inferred by the type of the input. Valid inputs are:
2467+
*
2468+
* - string, e.g. 'groupname': animate all frames of a given `group` in the order
2469+
* in which they are defined via `Plotly.addFrames`.
2470+
*
2471+
* - array of strings, e.g. ['frame1', frame2']: a list of frames by name to which
2472+
* to animate in sequence
2473+
*
2474+
* - object: {data: ...}: a frame definition to which to animate. The frame is not
2475+
* and does not need to be added via `Plotly.addFrames`. It may contain any of
2476+
* the properties of a frame, including `data`, `layout`, and `traces`. The
2477+
* frame is used as provided and does not use the `baseframe` property.
2478+
*
2479+
* - array of objects, e.g. [{data: ...}, {data: ...}]: a list of frame objects,
2480+
* each following the same rules as a single `object`.
24602481
*
2461-
* @param {string} name
2462-
* name of the keyframe to create
24632482
* @param {object} animationOpts
2464-
* configuration for animation
2483+
* configuration for the animation
24652484
*/
24662485
Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
24672486
gd = getGraphDiv(gd);
@@ -2664,13 +2683,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
26642683
return frame;
26652684
}
26662685

2667-
// Disambiguate what's been received. The possibilities are:
2668-
//
2669-
// - group: 'groupname': select frames by group name
2670-
// - frames ['frame1', frame2']: a list of frames
2671-
// - object: {data: ...}: a single frame itself
2672-
// - frames [{data: ...}, {data: ...}]: a list of frames
2673-
//
2686+
// Disambiguate what's sort of frames have been received
26742687
var i, frame;
26752688
var frameList = [];
26762689
var allFrames = frameOrGroupNameOrFrameList === undefined || frameOrGroupNameOrFrameList === null;
@@ -2729,15 +2742,23 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
27292742
};
27302743

27312744
/**
2732-
* Create new keyframes
2745+
* Register new frames
2746+
*
2747+
* @param {string id or DOM element} gd
2748+
* the id or DOM element of the graph container div
27332749
*
27342750
* @param {array of objects} frameList
27352751
* list of frame definitions, in which each object includes any of:
2736-
* - name: {string} name of keyframe to add
2752+
* - name: {string} name of frame to add
27372753
* - data: {array of objects} trace data
27382754
* - layout {object} layout definition
27392755
* - traces {array} trace indices
2740-
* - baseframe {string} name of keyframe from which this keyframe gets defaults
2756+
* - baseframe {string} name of frame from which this frame gets defaults
2757+
*
2758+
* @param {array of integers) indices
2759+
* an array of integer indices matching the respective frames in `frameList`. If not
2760+
* provided, an index will be provided in serial order. If already used, the frame
2761+
* will be overwritten.
27412762
*/
27422763
Plotly.addFrames = function(gd, frameList, indices) {
27432764
gd = getGraphDiv(gd);
@@ -2815,7 +2836,10 @@ Plotly.addFrames = function(gd, frameList, indices) {
28152836
};
28162837

28172838
/**
2818-
* Delete keyframes
2839+
* Delete frame
2840+
*
2841+
* @param {string id or DOM element} gd
2842+
* the id or DOM element of the graph container div
28192843
*
28202844
* @param {array of integers} frameList
28212845
* list of integer indices of frames to be deleted

src/plots/animation_attributes.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ module.exports = {
2828
role: 'info',
2929
min: 0,
3030
dflt: 500,
31-
description: 'The duration in milliseconds of each frame.'
31+
description: [
32+
'The duration in milliseconds of each frame. If greater than the frame',
33+
'duration, it will be limited to the frame duration.'
34+
].join(' ')
3235
},
3336
redraw: {
3437
valType: 'boolean',

0 commit comments

Comments
 (0)