1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.Quantile = void 0;
|
4 | const threshold_1 = require("./threshold");
|
5 | const wilkinson_extended_1 = require("../tick-methods/wilkinson-extended");
|
6 | const create_quartile_1 = require("../utils/create-quartile");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | class Quantile extends threshold_1.Threshold {
|
12 | getDefaultOptions() {
|
13 | return {
|
14 | domain: [],
|
15 | range: [],
|
16 | tickCount: 5,
|
17 | unknown: undefined,
|
18 | tickMethod: wilkinson_extended_1.wilkinsonExtended,
|
19 | };
|
20 | }
|
21 | constructor(options) {
|
22 | super(options);
|
23 | }
|
24 | rescale() {
|
25 | const { domain, range } = this.options;
|
26 | this.n = range.length - 1;
|
27 | this.thresholds = (0, create_quartile_1.createQuartile)(domain, this.n + 1, false);
|
28 | }
|
29 | |
30 |
|
31 |
|
32 | invert(y) {
|
33 | const [a, b] = super.invert(y);
|
34 | const { domain } = this.options;
|
35 | const dMin = domain[0];
|
36 | const dMax = domain[domain.length - 1];
|
37 | return a === undefined && b === undefined ? [a, b] : [a || dMin, b || dMax];
|
38 | }
|
39 | getThresholds() {
|
40 | return this.thresholds;
|
41 | }
|
42 | clone() {
|
43 | return new Quantile(this.options);
|
44 | }
|
45 | getTicks() {
|
46 | const { tickCount, domain, tickMethod } = this.options;
|
47 | const lastIndex = domain.length - 1;
|
48 | const min = domain[0];
|
49 | const max = domain[lastIndex];
|
50 | return tickMethod(min, max, tickCount);
|
51 | }
|
52 | }
|
53 | exports.Quantile = Quantile;
|
54 |
|
\ | No newline at end of file |