MCPcopy Create free account
hub / github.com/plotly/plotly.js / cleanRanges

Function cleanRanges

src/traces/parcoords/axisbrush.js:508–531  ·  view source on GitHub ↗
(ranges, dimension)

Source from the content-addressed store, hash-verified

506// for use by supplyDefaults, but it needed tons of pieces from here so
507// seemed to make more sense just to put the whole routine here
508function cleanRanges(ranges, dimension) {
509 if(Array.isArray(ranges[0])) {
510 ranges = ranges.map(function(ri) { return ri.sort(sortAsc); });
511
512 if(!dimension.multiselect) ranges = [ranges[0]];
513 else ranges = dedupeRealRanges(ranges.sort(startAsc));
514 } else ranges = [ranges.sort(sortAsc)];
515
516 // ordinal snapping
517 if(dimension.tickvals) {
518 var sortedTickVals = dimension.tickvals.slice().sort(sortAsc);
519 ranges = ranges.map(function(ri) {
520 var rSnapped = [
521 ordinalScaleSnap(0, sortedTickVals, ri[0], []),
522 ordinalScaleSnap(1, sortedTickVals, ri[1], [])
523 ];
524 if(rSnapped[1] > rSnapped[0]) return rSnapped;
525 })
526 .filter(function(ri) { return ri; });
527
528 if(!ranges.length) return;
529 }
530 return ranges.length > 1 ? ranges : ranges[0];
531}
532
533module.exports = {
534 makeBrush: makeBrush,

Callers

nothing calls this directly

Calls 2

dedupeRealRangesFunction · 0.85
ordinalScaleSnapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…