devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
69 lines (67 loc) • 3.27 kB
JavaScript
/**
* DevExtreme (viz/axes/strip.js)
* Version: 18.2.18
* Build date: Tue Oct 18 2022
*
* Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createStrip;
var _type = require("../../core/utils/type");
var _utils = require("../core/utils");
var _extend = require("../../core/utils/extend");
function createStrip(axis, options) {
var storedCoord = void 0;
var labelOptions = options.label || {};
return {
options: options,
label: null,
rect: null,
_getCoord: function() {
var canvas = axis._getCanvasStartEnd();
var range = axis._translator.getBusinessRange();
return axis._getStripPos(options.startValue, options.endValue, canvas.start, canvas.end, range)
},
_drawLabel: function(coords) {
return axis._renderer.text(labelOptions.text, coords.x, coords.y).css((0, _utils.patchFontOptions)((0, _extend.extend)({}, axis.getOptions().label.font, labelOptions.font))).attr({
align: "center"
}).append(axis._axisStripLabelGroup)
},
draw: function() {
if (axis._translator.getBusinessRange().isEmpty()) {
return
}
if (((0, _type.isDefined)(options.startValue) || (0, _type.isDefined)(options.endValue)) && (0, _type.isDefined)(options.color)) {
var stripPos = this._getCoord();
this.labelCoords = labelOptions.text ? axis._getStripLabelCoords(stripPos.from, stripPos.to, labelOptions) : null;
if (stripPos.outOfCanvas || !(0, _type.isDefined)(stripPos.to) || !(0, _type.isDefined)(stripPos.from)) {
return
}
this.rect = axis._createStrip(axis._getStripGraphicAttributes(stripPos.from, stripPos.to)).attr({
fill: options.color
}).append(axis._axisStripGroup);
this.label = labelOptions.text ? this._drawLabel(this.labelCoords) : null
}
},
removeLabel: function() {},
updatePosition: function(animate) {
var stripPos = this._getCoord();
if (animate && storedCoord) {
this.label && this.label.attr(axis._getStripLabelCoords(storedCoord.from, storedCoord.to, options.label));
this.rect && this.rect.attr(axis._getStripGraphicAttributes(storedCoord.from, storedCoord.to));
this.label && this.label.animate(axis._getStripLabelCoords(stripPos.from, stripPos.to, options.label));
this.rect && this.rect.animate(axis._getStripGraphicAttributes(stripPos.from, stripPos.to))
} else {
this.label && this.label.attr(axis._getStripLabelCoords(stripPos.from, stripPos.to, options.label));
this.rect && this.rect.attr(axis._getStripGraphicAttributes(stripPos.from, stripPos.to))
}
},
saveCoords: function() {
storedCoord = this._getCoord()
}
}
}