UNPKG

@devexperts/dxcharts-lite

Version:
52 lines (51 loc) 2.26 kB
/* * Copyright (C) 2019 - 2025 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/. */ import { HighlightsModel } from './highlights.model'; import { HighlightsDrawer } from './highlights.drawer'; import { ChartBaseElement } from '../../model/chart-base-element'; const HIGHLIGHTS_DRAWER_TYPE = 'HIGHLIGHTS_PLUGIN'; export class HighlightsComponent extends ChartBaseElement { constructor(eventBus, config, chartModel, canvasModel, canvasBoundsContainer, drawingManager) { super(); this.eventBus = eventBus; this.config = config; this.highlightsModel = new HighlightsModel(chartModel); this.addChildEntity(this.highlightsModel); this.highLightsDrawer = new HighlightsDrawer(this.highlightsModel, chartModel, canvasModel, canvasBoundsContainer, config); drawingManager.addDrawer(this.highLightsDrawer, HIGHLIGHTS_DRAWER_TYPE); } /** * Returns the highlights from the highlightsModel * @returns {Array} An array of highlights */ getHighlights() { return this.highlightsModel.getHighlights(); } /** * Sets the highlights of the highlights model. * @param {Highlight[]} highlights - An array of Highlight objects to be set as the highlights of the model. * @returns {void} */ setHighlights(highlights) { this.highlightsModel.setHighlights(highlights); } /** * Sets the visibility of the highlights component. * @param {boolean} visible - A boolean value indicating whether the highlights should be visible or not. Default value is true. * @returns {void} */ setHighlightsVisible(visible = true) { this.config.components.highlights.visible = visible; this.eventBus.fireDraw(this.highLightsDrawer.getCanvasIds()); } /** * Returns an observable that emits when the highlights are updated. * @returns {Observable} An observable that emits when the highlights are updated. */ observeHighlightsUpdated() { return this.highlightsModel.observeHighlightsUpdated(); } }