Skip to content

Commit fc39f57

Browse files
committed
jsDoc for animate, addFrames, and deleteFrames
1 parent 69d1487 commit fc39f57

File tree

2 files changed

+43
-16
lines changed

2 files changed

+43
-16
lines changed

src/plot_api/plot_api.js

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,12 +2457,31 @@ Plotly.relayout = function relayout(gd, astr, val) {
24572457
};
24582458

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

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

27322745
/**
2733-
* Create new keyframes
2746+
* Register new frames
2747+
*
2748+
* @param {string id or DOM element} gd
2749+
* the id or DOM element of the graph container div
27342750
*
27352751
* @param {array of objects} frameList
27362752
* list of frame definitions, in which each object includes any of:
2737-
* - name: {string} name of keyframe to add
2753+
* - name: {string} name of frame to add
27382754
* - data: {array of objects} trace data
27392755
* - layout {object} layout definition
27402756
* - traces {array} trace indices
2741-
* - baseframe {string} name of keyframe from which this keyframe gets defaults
2757+
* - baseframe {string} name of frame from which this frame gets defaults
2758+
*
2759+
* @param {array of integers) indices
2760+
* an array of integer indices matching the respective frames in `frameList`. If not
2761+
* provided, an index will be provided in serial order. If already used, the frame
2762+
* will be overwritten.
27422763
*/
27432764
Plotly.addFrames = function(gd, frameList, indices) {
27442765
gd = getGraphDiv(gd);
@@ -2816,7 +2837,10 @@ Plotly.addFrames = function(gd, frameList, indices) {
28162837
};
28172838

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

src/plots/animation_attributes.js

Lines changed: 4 additions & 1 deletion
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)