UNPKG

@antv/g2plot

Version:

G2 Plot, a market of plots built with the Grammar of Graphics'

50 lines 1.82 kB
import { __assign } from "tslib"; import * as _ from '@antv/util'; var Marker = /** @class */ (function () { function Marker(cfg) { _.assign(this, cfg); this.init(); } Marker.prototype.destroy = function () { if (this.shape) { this.shape.destroy(); } }; Marker.prototype.update = function (cfg, duration, easing) { var updateCfg = {}; _.assign(this, cfg); this.coord = this.view.get('coord'); if (cfg.value) { var x = this.coord.convert({ x: 0, y: this.value }).x; var matrix = [1, 0, 0, 0, 1, 0, x, 0, 1]; updateCfg.matrix = matrix; } if (cfg.style) { var origin_attr = this.shape.attrs; var attrs = _.deepMix({}, origin_attr, cfg.style); updateCfg = _.deepMix({}, attrs, updateCfg); } this.shape.stopAnimate(); this.shape.animate(updateCfg, duration, easing); }; Marker.prototype.init = function () { this.coord = this.view.get('coord'); this.container = this.view.get('container'); var x = this.coord.convert({ x: 0, y: this.value }).x; // progress坐标系是转置坐标系 var y0 = this.coord.center.y - this.progressSize / 2 - 2; var y1 = this.coord.center.y + this.progressSize / 2 + 2; var style = _.deepMix({}, { stroke: 'grey', lineWidth: 1 }, this.style); this.shape = this.container.addShape('path', { attrs: __assign({ path: [ ['M', 0, y0], ['L', 0, y1], ] }, style), name: 'progress-marker', }); this.shape.move(x, 0); this.canvas.draw(); }; return Marker; }()); export default Marker; //# sourceMappingURL=marker.js.map