UNPKG

@progress/kendo-angular-charts

Version:

Kendo UI Charts for Angular - A comprehensive package for creating beautiful and interactive data visualization. Every chart type, stock charts, and sparklines are included.

65 lines (64 loc) 2.49 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Injectable } from '@angular/core'; import { ConfigurationService } from './configuration.service'; import { chartBaseTheme, chartTheme, deepExtend } from '@progress/kendo-charts'; import { chartDefaultTheme } from './chart-default-theme'; import { isDocumentAvailable } from '@progress/kendo-angular-common'; import * as i0 from "@angular/core"; /** * @hidden */ export class ThemeService extends ConfigurationService { loaded = false; element; loadTheme() { if (this.loaded || !isDocumentAvailable()) { return; } this.createElement(); this.readTheme(); this.destroyElement(); this.loaded = true; this.next(); } reset() { this.store = {}; this.loaded = false; this.loadTheme(); } readTheme() { let theme = {}; try { theme = chartTheme(this.element); } catch { theme = {}; } const available = Boolean(theme.chartArea && theme.chartArea.background); const result = available ? deepExtend(chartBaseTheme(), theme) : chartDefaultTheme(); this.push(result); } createElement() { const container = this.element = document.createElement('div'); container.className = 'k-chart'; container.style.display = 'none'; document.body.appendChild(container); } destroyElement() { if (this.element) { document.body.removeChild(this.element); this.element = undefined; } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ThemeService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ThemeService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ThemeService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] });