region.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { __assign, __extends } from "tslib";
  2. import GroupComponent from '../abstract/group-component';
  3. import Theme from '../util/theme';
  4. import { regionToBBox } from '../util/util';
  5. var RegionAnnotation = /** @class */ (function (_super) {
  6. __extends(RegionAnnotation, _super);
  7. function RegionAnnotation() {
  8. return _super !== null && _super.apply(this, arguments) || this;
  9. }
  10. /**
  11. * @protected
  12. * 默认的配置项
  13. * @returns {object} 默认的配置项
  14. */
  15. RegionAnnotation.prototype.getDefaultCfg = function () {
  16. var cfg = _super.prototype.getDefaultCfg.call(this);
  17. return __assign(__assign({}, cfg), { name: 'annotation', type: 'region', locationType: 'region', start: null, end: null, style: {}, defaultCfg: {
  18. style: {
  19. lineWidth: 0,
  20. fill: Theme.regionColor,
  21. opacity: 0.4,
  22. },
  23. } });
  24. };
  25. RegionAnnotation.prototype.renderInner = function (group) {
  26. this.renderRegion(group);
  27. };
  28. RegionAnnotation.prototype.renderRegion = function (group) {
  29. var start = this.get('start');
  30. var end = this.get('end');
  31. var style = this.get('style');
  32. var bbox = regionToBBox({ start: start, end: end });
  33. this.addShape(group, {
  34. type: 'rect',
  35. id: this.getElementId('region'),
  36. name: 'annotation-region',
  37. attrs: __assign({ x: bbox.x, y: bbox.y, width: bbox.width, height: bbox.height }, style),
  38. });
  39. };
  40. return RegionAnnotation;
  41. }(GroupComponent));
  42. export default RegionAnnotation;
  43. //# sourceMappingURL=region.js.map