UNPKG

2.35 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var util_1 = require("@antv/util");
5var constant_1 = require("../constant");
6var coordinate_1 = require("../util/coordinate");
7var shape_size_1 = require("./util/shape-size");
8var base_1 = tslib_1.__importDefault(require("./base"));
9/** 引入 Path 对应的 ShapeFactory */
10require("./shape/violin");
11/**
12 * Violin 几何标记。
13 * 用于绘制小提琴图。
14 */
15var Violin = /** @class */ (function (_super) {
16 tslib_1.__extends(Violin, _super);
17 function Violin() {
18 var _this = _super !== null && _super.apply(this, arguments) || this;
19 _this.type = 'violin';
20 _this.shapeType = 'violin';
21 _this.generatePoints = true;
22 return _this;
23 }
24 /**
25 * 获取 Shape 的关键点数据。
26 * @param record
27 * @returns
28 */
29 Violin.prototype.createShapePointsCfg = function (record) {
30 var cfg = _super.prototype.createShapePointsCfg.call(this, record);
31 // 计算每个 shape 的 size
32 var size;
33 var sizeAttr = this.getAttribute('size');
34 if (sizeAttr) {
35 size = this.getAttributeValues(sizeAttr, record)[0];
36 // 归一化
37 var coordinate = this.coordinate;
38 var coordinateWidth = (0, coordinate_1.getXDimensionLength)(coordinate);
39 size = size / coordinateWidth;
40 }
41 else {
42 if (!this.defaultSize) {
43 this.defaultSize = (0, shape_size_1.getDefaultSize)(this);
44 }
45 size = this.defaultSize;
46 }
47 cfg.size = size;
48 cfg._size = (0, util_1.get)(record[constant_1.FIELD_ORIGIN], [this._sizeField]);
49 return cfg;
50 };
51 /**
52 * @override
53 */
54 Violin.prototype.initAttributes = function () {
55 var attributeOption = this.attributeOption;
56 var sizeField = attributeOption.size
57 ? attributeOption.size.fields[0]
58 : this._sizeField
59 ? this._sizeField
60 : 'size';
61 this._sizeField = sizeField;
62 // fixme 干啥要删掉
63 delete attributeOption.size;
64 _super.prototype.initAttributes.call(this);
65 };
66 return Violin;
67}(base_1.default));
68exports.default = Violin;
69//# sourceMappingURL=violin.js.map
\No newline at end of file