@antv/g2plot
Version:
G2 Plot, a market of plots built with the Grammar of Graphics'
52 lines • 1.93 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var _ = tslib_1.__importStar(require("@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: tslib_1.__assign({ path: [
['M', 0, y0],
['L', 0, y1],
] }, style),
name: 'progress-marker',
});
this.shape.move(x, 0);
this.canvas.draw();
};
return Marker;
}());
exports.default = Marker;
//# sourceMappingURL=marker.js.map