@devexperts/dxcharts-lite
Version:
39 lines (38 loc) • 1.42 kB
JavaScript
/*
* Copyright (C) 2019 - 2026 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
export class CrossToolDrawer {
constructor(model, config, crossToolCanvasModel, crossToolTypeDrawers) {
this.model = model;
this.config = config;
this.crossToolCanvasModel = crossToolCanvasModel;
this.crossToolTypeDrawers = crossToolTypeDrawers;
}
/**
* Draws the cross tool on the canvas.
* @function
* @name draw
* @memberof CrossToolCanvasView
* @instance
* @returns {void}
*/
draw() {
const drawer = this.crossToolTypeDrawers[this.config.components.crossTool.type];
if (drawer) {
this.model.currentHover && drawer.draw(this.crossToolCanvasModel.ctx, this.model.currentHover);
}
else {
console.error(`No cross tool drawer type registered for drawer type ${this.config.components.crossTool.type}`);
}
}
/**
* Returns an array of string containing the canvas ID of the crossToolCanvasModel.
*
* @returns {Array<string>} An array of string containing the canvas ID of the crossToolCanvasModel.
*/
getCanvasIds() {
return [this.crossToolCanvasModel.canvasId];
}
}