in client/client/modules/render/heatmap/renderer/viewport-renderer/utilities/axis-label.js [119:242]
constructor(options = {}) {
const {
annotatedIndex,
labelsManager,
axis,
direction,
normal,
showAnnotations,
value = 0
} = options;
/**
*
* @type {LabelsManager}
*/
this.labelsManager = labelsManager;
/**
*
* @type {PIXI.Container}
*/
this.container = new PIXI.Container();
/**
* Label text
* @type {string}
*/
this.text = showAnnotations && annotatedIndex.annotation
? `${annotatedIndex.name || ''} - ${annotatedIndex.annotation}`
: (annotatedIndex.name || '');
/**
*
* @type {HeatmapAnnotatedIndex}
*/
this.annotatedIndex = annotatedIndex;
/**
* Label text lines
* @type {string[]}
*/
this.lines = labelsFormatter(this.text);
/**
* Label text with line breaks
* @type {string}
*/
this.formattedText = this.lines.join('\n');
/**
* Label text size
* @type {number}
*/
this.length = this.text.length;
/**
* Longest line size
* @type {number}
*/
this.formattedLength = Math.max(...this.lines.map(line => line.length), 0);
/**
*
* @type {HeatmapAxis}
*/
this.axis = axis;
/**
*
* @type {boolean}
*/
this.visible = false;
/**
*
* @type {boolean}
*/
this.hovered = false;
/**
* Axis direction vector
* @type {Vector}
*/
this.direction = direction;
/**
* Axis normal vector
* @type {Vector}
*/
this.normal = normal;
/**
* Direction angle (radians)
* @type {number}
*/
this.directionRadians = Math.atan2(this.direction.y, this.direction.x);
/**
* Normal angle (radians)
* @type {number}
*/
this.normalRadians = Math.atan2(this.normal.y, this.normal.x);
const {x: ax = 0} = this.normal;
const align = ax >= 0 ? Align.left : Align.right;
/**
* Label font styles
* @type {{label, hovered}}
*/
this.labelStyles = LabelStyles[align] || LabelStyles[Align.left];
/**
* Label graphics
* @type {PIXI.Text|PIXI.Sprite}
*/
this.label = labelsManager.getLabel(this.formattedText, this.labelStyles.label);
if (!LAZY_INITIALIZE_HOVERED_LABEL) {
this.updateHoveredLabel(true);
}
/**
* Label graphics size (width) respecting margin
*/
this.container.addChild(this.label);
if (
annotatedIndex &&
annotatedIndex.navigation !== HeatmapNavigationType.missing
) {
this.container.interactive = true;
this.container.buttonMode = true;
}
if (DEBUG) {
this.debugGraphics = new PIXI.Graphics();
this.container.addChild(this.debugGraphics);
}
this.value = value;
this.anchor = {x: ax >= 0 ? 0 : 1, y: 0.5};
this.start = 0;
this.end = 0;
this.built = false;
this.changed = true;
}