Skip to content

Commit b2a072a

Browse files
committed
plot api: add proper jsDoc to restyle and relayout
1 parent 17e7e79 commit b2a072a

File tree

1 file changed

+48
-34
lines changed

1 file changed

+48
-34
lines changed

src/plot_api/plot_api.js

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,29 +1163,34 @@ Plotly.moveTraces = function moveTraces(gd, currentIndices, newIndices) {
11631163
return promise;
11641164
};
11651165

1166-
// -----------------------------------------------------
1167-
// restyle and relayout: these two control all redrawing
1168-
// for data (restyle) and everything else (relayout)
1169-
// -----------------------------------------------------
1170-
1171-
// restyle: change styling of an existing plot
1172-
// can be called two ways:
1173-
//
1174-
// restyle(gd, astr, val [,traces])
1175-
// gd - graph div (string id or dom element)
1176-
// astr - attribute string (like 'marker.symbol')
1177-
// val - value to give this attribute
1178-
// traces - integer or array of integers for the traces
1179-
// to alter (all if omitted)
1180-
//
1181-
// restyle(gd, aobj [,traces])
1182-
// aobj - {astr1:val1, astr2:val2...} allows setting
1183-
// multiple attributes simultaneously
1184-
//
1185-
// val (or val1, val2... in the object form) can be an array,
1186-
// to apply different values to each trace.
1187-
// If the array is too short, it will wrap around (useful for
1188-
// style files that want to specify cyclical default values).
1166+
/**
1167+
* restyle: update trace attributes of an existing plot
1168+
*
1169+
* Can be called two ways.
1170+
*
1171+
* Signature 1:
1172+
* @param {string id or DOM element} gd
1173+
* the id or DOM element of the graph container div
1174+
* @param {string} astr
1175+
* attribute string (like `'marker.symbol'`) to update
1176+
* @param {any} val
1177+
* value to give this attribute
1178+
* @param {number or array} traces (optional)
1179+
* integer or array of integers for the traces to alter (all if omitted)
1180+
*
1181+
* Signature 2:
1182+
* @param {string id or DOM element} gd (as in signature 1)
1183+
* @param {object} aobj
1184+
* attribute object `{astr1: val1, astr2: val2 ...}`
1185+
* allows setting multiple attributes simultaneously
1186+
* @param {number or array} traces (optional, as in signature 1)
1187+
*
1188+
* `val` (or `val1`, `val2` ... in the object form) can be an array,
1189+
* to apply different values to each trace.
1190+
*
1191+
* If the array is too short, it will wrap around (useful for
1192+
* style files that want to specify cyclical default values).
1193+
*/
11891194
Plotly.restyle = function restyle(gd, astr, val, traces) {
11901195
gd = helpers.getGraphDiv(gd);
11911196
helpers.clearPromiseQueue(gd);
@@ -1693,17 +1698,26 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
16931698
});
16941699
}
16951700

1696-
// relayout: change layout in an existing plot
1697-
// can be called two ways:
1698-
//
1699-
// relayout(gd, astr, val)
1700-
// gd - graph div (string id or dom element)
1701-
// astr - attribute string (like 'xaxis.range[0]')
1702-
// val - value to give this attribute
1703-
//
1704-
// relayout(gd,aobj)
1705-
// aobj - {astr1:val1, astr2:val2...}
1706-
// allows setting multiple attributes simultaneously
1701+
/**
1702+
* relayout: update layout attributes of an existing plot
1703+
*
1704+
* Can be called two ways:
1705+
*
1706+
* Signature 1:
1707+
* @param {string id or dom element} gd
1708+
* the id or dom element of the graph container div
1709+
* @param {string} astr
1710+
* attribute string (like `'xaxis.range[0]'`) to update
1711+
* @param {any} val
1712+
* value to give this attribute
1713+
*
1714+
* Signature 2:
1715+
* @param {string id or DOM element} gd (as in signature 1)
1716+
* the id or DOM element of the graph container div
1717+
* @param {object} aobj
1718+
* attribute object `{astr1: val1, astr2: val2 ...}`
1719+
* allows setting multiple attributes simultaneously
1720+
*/
17071721
Plotly.relayout = function relayout(gd, astr, val) {
17081722
gd = helpers.getGraphDiv(gd);
17091723
helpers.clearPromiseQueue(gd);

0 commit comments

Comments
 (0)