| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Geom = require('./base');
- var Util = require('../util/common');
- require('./shape/polygon');
- var Polygon =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Polygon, _Geom);
- function Polygon() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Polygon.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'polygon';
- cfg.shapeType = 'polygon';
- cfg.generatePoints = true;
- return cfg;
- };
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- var self = this;
- var x = cfg.x;
- var y = cfg.y;
- var temp;
- if (!(Util.isArray(x) && Util.isArray(y))) {
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
- var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
- var xOffset = 0.5 * 1 / xCount;
- var yOffset = 0.5 * 1 / yCount;
- if (xScale.isCategory && yScale.isCategory) {
- x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
- y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
- } else if (Util.isArray(x)) {
- temp = x;
- x = [temp[0], temp[0], temp[1], temp[1]];
- y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
- } else if (Util.isArray(y)) {
- temp = y;
- y = [temp[0], temp[1], temp[1], temp[0]];
- x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
- }
- cfg.x = x;
- cfg.y = y;
- }
- return cfg;
- };
- return Polygon;
- }(Geom);
- Geom.Polygon = Polygon;
- module.exports = Polygon;
|