UNPKG

848 BJavaScriptView Raw
1import { __extends } from "tslib";
2import { Category as CategoryScale } from '../deps/f2-scale/src';
3import Base from './base';
4var Category = /** @class */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);
26export default Category;
\No newline at end of file