| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = require('../../util/common');
- var GuideBase = require('./base');
- var Text =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Text, _GuideBase);
- function Text() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Text.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'text';
- /**
- * the position of text
- * @type {Function | Array}
- */
- this.position = null;
- /**
- * the display content
- * @type {String}
- */
- this.content = null;
- /**
- * style configuration for text
- * @type {Object}
- */
- this.style = {
- fill: '#000'
- };
- /**
- * offset of horizontal direction
- * @type {Number}
- */
- this.offsetX = 0;
- /**
- * offset of vertical direction
- * @type {Number}
- */
- this.offsetY = 0;
- };
- _proto.render = function render(coord, container) {
- var position = this.position;
- var point = this.parsePoint(coord, position);
- if (!point) {
- return;
- }
- var content = this.content,
- style = this.style,
- offsetX = this.offsetX,
- offsetY = this.offsetY;
- if (offsetX) {
- point.x += offsetX;
- }
- if (offsetY) {
- point.y += offsetY;
- }
- var shape = container.addShape('text', {
- className: 'guide-text',
- attrs: Util.mix({
- x: point.x,
- y: point.y,
- text: content
- }, style)
- });
- this.element = shape;
- return shape;
- };
- return Text;
- }(GuideBase);
- GuideBase.Text = Text;
- module.exports = Text;
|