|
1 | | -import {descending, quantile, range as rangei} from "d3"; |
| 1 | +import {quantile, range as rangei} from "d3"; |
2 | 2 | import {parse as isoParse} from "isoformat"; |
3 | 3 | import {defined} from "./defined.js"; |
4 | 4 | import {maybeTimeInterval, maybeUtcInterval} from "./time.js"; |
@@ -510,16 +510,6 @@ export function maybeFrameAnchor(value = "middle") { |
510 | 510 | return maybeAnchor(value, "frameAnchor"); |
511 | 511 | } |
512 | 512 |
|
513 | | -// Like a sort comparator, returns a positive value if the given array of values |
514 | | -// is in ascending order, a negative value if the values are in descending |
515 | | -// order. Assumes monotonicity; only tests the first and last values. |
516 | | -export function orderof(values) { |
517 | | - if (values == null) return; |
518 | | - const first = values[0]; |
519 | | - const last = values[values.length - 1]; |
520 | | - return descending(first, last); |
521 | | -} |
522 | | - |
523 | 513 | // Unlike {...defaults, ...options}, this ensures that any undefined (but |
524 | 514 | // present) properties in options inherit the given default value. |
525 | 515 | export function inherit(options = {}, ...rest) { |
@@ -557,3 +547,12 @@ export function named(things) { |
557 | 547 | export function maybeNamed(things) { |
558 | 548 | return isIterable(things) ? named(things) : things; |
559 | 549 | } |
| 550 | + |
| 551 | +// TODO Accept other types of clips (paths, urls, x, y, other marks…)? |
| 552 | +// https://github.com/observablehq/plot/issues/181 |
| 553 | +export function maybeClip(clip) { |
| 554 | + if (clip === true) clip = "frame"; |
| 555 | + else if (clip === false) clip = null; |
| 556 | + else if (clip != null) clip = keyword(clip, "clip", ["frame", "sphere"]); |
| 557 | + return clip; |
| 558 | +} |
0 commit comments