1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _default = exports.default = function _default(cfg) {
|
9 | var values = cfg.values,
|
10 | tickCount = cfg.tickCount;
|
11 | if (!tickCount) {
|
12 | return values;
|
13 | }
|
14 | if (values.length <= 1) {
|
15 | return values;
|
16 | }
|
17 |
|
18 | var step = Math.floor(values.length / (tickCount - 1)) || 1;
|
19 | var ticks = [];
|
20 |
|
21 | for (var index = 0; index < values.length; index = index + step) {
|
22 | ticks.push(values[index]);
|
23 | }
|
24 | var last = values[values.length - 1];
|
25 |
|
26 | if (ticks[ticks.length - 1] !== last) {
|
27 | if (ticks.length >= tickCount) {
|
28 |
|
29 | ticks[ticks.length - 1] = last;
|
30 | } else {
|
31 |
|
32 | ticks.push(last);
|
33 | }
|
34 | }
|
35 | return ticks;
|
36 | }; |
\ | No newline at end of file |