1 | import { __extends } from "tslib";
|
2 | import { Category as CategoryScale } from '../deps/f2-scale/src';
|
3 | import Base from './base';
|
4 | var Category = function (_super) {
|
5 | __extends(Category, _super);
|
6 | function Category() {
|
7 | return _super !== null && _super.apply(this, arguments) || this;
|
8 | }
|
9 | Category.prototype.createScale = function (scaleConfig) {
|
10 | return new CategoryScale(scaleConfig);
|
11 | };
|
12 | Category.prototype._mapping = function (value) {
|
13 | var _a = this,
|
14 | scale = _a.scale,
|
15 | range = _a.range;
|
16 | if (scale.type === 'cat') {
|
17 | var index_1 = scale.translate(value);
|
18 | return range[index_1 % range.length];
|
19 | }
|
20 | var normalizeValue = scale.scale(value);
|
21 | var index = Math.round(normalizeValue * (range.length - 1));
|
22 | return range[index];
|
23 | };
|
24 | return Category;
|
25 | }(Base);
|
26 | export default Category; |
\ | No newline at end of file |