UNPKG

2.5 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var base_1 = require("../base");
5var constant_1 = require("../constant");
6var get_style_1 = require("../util/get-style");
7var util_1 = require("./util");
8/** Interval 的 shape 工厂 */
9var IntervalShapeFactory = (0, base_1.registerShapeFactory)('interval', {
10 defaultShapeType: 'rect',
11 getDefaultPoints: function (pointInfo) {
12 return (0, util_1.getRectPoints)(pointInfo);
13 },
14});
15/** Inerval 默认 shape,填充的矩形 */
16(0, base_1.registerShape)('interval', 'rect', {
17 draw: function (cfg, container) {
18 var style = (0, get_style_1.getStyle)(cfg, false, true);
19 var group = container;
20 var backgroundCfg = cfg === null || cfg === void 0 ? void 0 : cfg.background;
21 if (backgroundCfg) {
22 group = container.addGroup({
23 name: 'interval-group',
24 });
25 var backgroundStyle = (0, get_style_1.getBackgroundRectStyle)(cfg);
26 var backgroundPath = (0, util_1.getBackgroundRectPath)(cfg, this.parsePoints(cfg.points), this.coordinate);
27 group.addShape('path', {
28 attrs: tslib_1.__assign(tslib_1.__assign({}, backgroundStyle), { path: backgroundPath }),
29 zIndex: -1,
30 name: constant_1.BACKGROUND_SHAPE,
31 });
32 }
33 var path;
34 if (style.radius && this.coordinate.isRect) {
35 path = (0, util_1.getRectWithCornerRadius)(this.parsePoints(cfg.points), this.coordinate, style.radius);
36 }
37 else {
38 path = this.parsePath((0, util_1.getIntervalRectPath)(cfg.points, style.lineCap, this.coordinate));
39 }
40 var shape = group.addShape('path', {
41 attrs: tslib_1.__assign(tslib_1.__assign({}, style), { path: path }),
42 name: 'interval',
43 });
44 return backgroundCfg ? group : shape;
45 },
46 getMarker: function (markerCfg) {
47 var color = markerCfg.color, isInPolar = markerCfg.isInPolar;
48 if (isInPolar) {
49 return {
50 symbol: 'circle',
51 style: {
52 r: 4.5,
53 fill: color,
54 },
55 };
56 }
57 return {
58 symbol: 'square',
59 style: {
60 r: 4,
61 fill: color,
62 },
63 };
64 },
65});
66exports.default = IntervalShapeFactory;
67//# sourceMappingURL=index.js.map
\No newline at end of file