import { Component, EventEmitter, Input, Output, } from '@angular/core'; import Gauge from 'svg-gauge'; import * as i0 from "@angular/core"; import * as i1 from "./gauge-defaults.service"; class GaugeComponent { constructor(elm, defaults) { this.elm = elm; this.defaults = defaults; /** * Called when the gauge is created */ this.gaugeCreated = new EventEmitter(); } ngAfterViewInit() { const options = { dialStartAngle: this.dialStartAngle, dialEndAngle: this.dialEndAngle, dialRadius: this.dialRadius, min: this.min, max: this.max, label: this.label, showValue: this.showValue, gaugeClass: this.gaugeClass, dialClass: this.dialClass, valueDialClass: this.valueDialClass, valueClass: this.valueClass, value: this.value, color: this.color, }; Object.keys(this.defaults).forEach((optionKey) => { const key = optionKey; if (options[key] == null) { options[key] = this.defaults[key]; } }); Object.keys(options).forEach((optionKey) => { const key = optionKey; if (options[key] == null) { delete options[key]; } }); this.gauge = Gauge(this.elm.nativeElement, options); this.gaugeCreated.emit({ gauge: this.gauge }); this.updateValue(); } ngOnChanges(changes) { if (changes['value']) { this.updateValue(); } } updateValue() { if (this.gauge) { if (this.animated) { this.gauge.setValueAnimated(this.value, this.animationDuration); } else { this.gauge.setValue(this.value); } } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: GaugeComponent, deps: [{ token: i0.ElementRef }, { token: i1.GaugeDefaults }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: GaugeComponent, selector: "mwl-gauge", inputs: { dialStartAngle: "dialStartAngle", dialEndAngle: "dialEndAngle", dialRadius: "dialRadius", min: "min", max: "max", label: "label", color: "color", showValue: "showValue", gaugeClass: "gaugeClass", dialClass: "dialClass", valueDialClass: "valueDialClass", valueClass: "valueClass", value: "value", animated: "animated", animationDuration: "animationDuration" }, outputs: { gaugeCreated: "gaugeCreated" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true }); } } export { GaugeComponent }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: GaugeComponent, decorators: [{ type: Component, args: [{ selector: 'mwl-gauge', template: '', }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.GaugeDefaults }]; }, propDecorators: { dialStartAngle: [{ type: Input }], dialEndAngle: [{ type: Input }], dialRadius: [{ type: Input }], min: [{ type: Input }], max: [{ type: Input }], label: [{ type: Input }], color: [{ type: Input }], showValue: [{ type: Input }], gaugeClass: [{ type: Input }], dialClass: [{ type: Input }], valueDialClass: [{ type: Input }], valueClass: [{ type: Input }], value: [{ type: Input }], animated: [{ type: Input }], animationDuration: [{ type: Input }], gaugeCreated: [{ type: Output }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2F1Z2UuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvYW5ndWxhci1nYXVnZS9zcmMvbGliL2dhdWdlLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBRUwsU0FBUyxFQUVULFlBQVksRUFDWixLQUFLLEVBRUwsTUFBTSxHQUVQLE1BQU0sZUFBZSxDQUFDO0FBRXZCLE9BQU8sS0FBSyxNQUFNLFdBQVcsQ0FBQzs7O0FBRTlCLE1BSWEsY0FBYztJQW1GekIsWUFBb0IsR0FBZSxFQUFVLFFBQXVCO1FBQWhELFFBQUcsR0FBSCxHQUFHLENBQVk7UUFBVSxhQUFRLEdBQVIsUUFBUSxDQUFlO1FBUHBFOztXQUVHO1FBQ08saUJBQVksR0FBaUMsSUFBSSxZQUFZLEVBQUUsQ0FBQztJQUlILENBQUM7SUFFeEUsZUFBZTtRQUNiLE1BQU0sT0FBTyxHQUFpQjtZQUM1QixjQUFjLEVBQUUsSUFBSSxDQUFDLGNBQWM7WUFDbkMsWUFBWSxFQUFFLElBQUksQ0FBQyxZQUFZ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