Skip to content

Commit d6fad10

Browse files
committed
plotly#189 adding missing docs and reducing assumptions
1 parent 849978e commit d6fad10

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/plots/cartesian/ordered_categories.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ var d3 = require('d3');
1313

1414

1515
/**
16-
* TODO add documentation
16+
* This pure function returns the ordered categories for specified axisLetter, categorymode, categorylist and data.
17+
*
18+
* If categorymode is 'array', the result is a fresh copy of categorylist, or if unspecified, an empty array.
19+
*
20+
* If categorymode is 'category ascending' or 'category descending', the result is an array of ascending or descending
21+
* order of the unique categories encountered in the data for specified axisLetter.
22+
*
1723
*/
1824
module.exports = function orderedCategories(axisLetter, categorymode, categorylist, data) {
1925

2026
return categorymode === 'array' ?
2127

2228
// just return a copy of the specified array ...
23-
categorylist.slice() :
29+
(Array.isArray(categorylist) ? categorylist : []).slice() :
2430

2531
// ... or take the union of all encountered tick keys and sort them as specified
2632
// (could be simplified with lodash-fp or ramda)

0 commit comments

Comments
 (0)