{"version":3,"file":"angular-gauge.mjs","sources":["../../../projects/angular-gauge/src/lib/gauge-defaults.service.ts","../../../projects/angular-gauge/src/lib/gauge.component.ts","../../../projects/angular-gauge/src/lib/gauge.module.ts","../../../projects/angular-gauge/src/public-api.ts","../../../projects/angular-gauge/src/angular-gauge.ts"],"sourcesContent":["export interface GaugeOptions {\n /**\n * The angle in degrees to start the dial\n */\n dialStartAngle?: number;\n\n /**\n * The angle in degrees to end the dial. This MUST be less than dialStartAngle\n */\n dialEndAngle?: number;\n\n /**\n * The radius of the gauge\n */\n dialRadius?: number;\n\n /**\n * The minumum value for the gauge\n */\n min?: number;\n\n /**\n * The maximum value for the gauge\n */\n max?: number;\n\n /**\n * Function that returns a string label that will be rendered in the center. This function will be passed the current value\n */\n label?: (value: number) => string;\n\n /**\n * Function that returns a string color value for the gauge''s fill (value dial)\n */\n color?: (value: number) => string;\n\n /**\n * Whether to show the value at the center of the gauge\n */\n showValue?: boolean;\n\n /**\n * The CSS class of the gauge\n */\n gaugeClass?: string;\n\n /**\n * The CSS class of the gauge's dial\n */\n dialClass?: string;\n\n /**\n * The CSS class of the gauge's fill (value dial)\n */\n valueDialClass?: string;\n\n /**\n * \tThe CSS class of the gauge's text\n */\n valueClass?: string;\n\n /**\n * The value of the gauge\n */\n value?: number;\n\n /**\n * Whether to animate changing the gauge\n */\n animated?: boolean;\n\n /**\n * Animation duration in seconds\n */\n animationDuration?: number;\n}\n\nexport class GaugeDefaults implements GaugeOptions {\n /**\n * The angle in degrees to start the dial\n */\n dialStartAngle: number = 135;\n\n /**\n * The angle in degrees to end the dial. This MUST be less than dialStartAngle\n */\n dialEndAngle: number = 45;\n\n /**\n * The radius of the gauge\n */\n dialRadius: number = 40;\n\n /**\n * The minimum value for the gauge\n */\n min: number = 0;\n\n /**\n * The maximum value for the gauge\n */\n max: number = 100;\n\n /**\n * Function that returns a string label that will be rendered in the center. This function will be passed the current value\n */\n label?: (value: number) => string;\n\n /**\n * Function that returns a string color value for the gauge''s fill (value dial)\n */\n color?: (value: number) => string;\n\n /**\n * Whether to show the value at the center of the gauge\n */\n showValue: boolean = true;\n\n /**\n * The CSS class of the gauge\n */\n gaugeClass: string = 'gauge';\n\n /**\n * The CSS class of the gauge's dial\n */\n dialClass: string = 'dial';\n\n /**\n * The CSS class of the gauge's fill (value dial)\n */\n valueDialClass: string = 'value';\n\n /**\n * \tThe CSS class of the gauge's text\n */\n valueClass: string = 'value-text';\n\n /**\n * The value of the gauge\n */\n value?: number;\n\n /**\n * Whether to animate changing the gauge\n */\n animated: boolean = false;\n\n /**\n * Animation duration in seconds\n */\n animationDuration?: number;\n}\n","import {\n AfterViewInit,\n Component,\n ElementRef,\n EventEmitter,\n Input,\n OnChanges,\n Output,\n SimpleChanges,\n} from '@angular/core';\nimport { GaugeDefaults, GaugeOptions } from './gauge-defaults.service';\nimport Gauge from 'svg-gauge';\n\n@Component({\n selector: 'mwl-gauge',\n template: '',\n})\nexport class GaugeComponent implements AfterViewInit, OnChanges, GaugeOptions {\n /**\n * The angle in degrees to start the dial\n */\n @Input() dialStartAngle!: number;\n\n /**\n * The angle in degrees to end the dial. This MUST be less than dialStartAngle\n */\n @Input() dialEndAngle!: number;\n\n /**\n * The radius of the gauge\n */\n @Input() dialRadius!: number;\n\n /**\n * The minimum value for the gauge\n */\n @Input() min!: number;\n\n /**\n * The maximum value for the gauge\n */\n @Input() max!: number;\n\n /**\n * Function that returns a string label that will be rendered in the center. This function will be passed the current value\n */\n @Input() label!: (value: number) => string;\n\n /**\n * Function that returns a string color value for the gauge''s fill (value dial)\n */\n @Input() color!: (value: number) => string;\n\n /**\n * Whether to show the value at the center of the gauge\n */\n @Input() showValue!: boolean;\n\n /**\n * The CSS class of the gauge\n */\n @Input() gaugeClass!: string;\n\n /**\n * The CSS class of the gauge's dial\n */\n @Input() dialClass!: string;\n\n /**\n * The CSS class of the gauge's fill (value dial)\n */\n @Input() valueDialClass!: string;\n\n /**\n * \tThe CSS class of the gauge's text\n */\n @Input() valueClass!: string;\n\n /**\n * The value of the gauge\n */\n @Input() value!: number;\n\n /**\n * Whether to animate changing the gauge\n */\n @Input() animated!: boolean;\n\n /**\n * Animation duration in seconds\n */\n @Input() animationDuration!: number;\n\n /**\n * Called when the gauge is created\n */\n @Output() gaugeCreated: EventEmitter<{ gauge: any }> = new EventEmitter();\n\n private gauge: any;\n\n constructor(private elm: ElementRef, private defaults: GaugeDefaults) {}\n\n ngAfterViewInit(): void {\n const options: GaugeOptions = {\n dialStartAngle: this.dialStartAngle,\n dialEndAngle: this.dialEndAngle,\n dialRadius: this.dialRadius,\n min: this.min,\n max: this.max,\n label: this.label,\n showValue: this.showValue,\n gaugeClass: this.gaugeClass,\n dialClass: this.dialClass,\n valueDialClass: this.valueDialClass,\n valueClass: this.valueClass,\n value: this.value,\n color: this.color,\n };\n\n Object.keys(this.defaults).forEach((optionKey) => {\n const key = optionKey as keyof GaugeOptions;\n if (options[key] == null) {\n options[key] = this.defaults[key] as any;\n }\n });\n\n Object.keys(options).forEach((optionKey) => {\n const key = optionKey as keyof GaugeOptions;\n if (options[key] == null) {\n delete options[key];\n }\n });\n\n this.gauge = Gauge(this.elm.nativeElement, options);\n\n this.gaugeCreated.emit({ gauge: this.gauge });\n\n this.updateValue();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['value']) {\n this.updateValue();\n }\n }\n\n private updateValue(): void {\n if (this.gauge) {\n if (this.animated) {\n this.gauge.setValueAnimated(this.value, this.animationDuration);\n } else {\n this.gauge.setValue(this.value);\n }\n }\n }\n}\n","import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';\nimport { GaugeComponent } from './gauge.component';\nimport { GaugeDefaults, GaugeOptions } from './gauge-defaults.service';\n\nexport const USER_DEFAULTS: InjectionToken = new InjectionToken(\n 'gauge defaults'\n);\n\n@NgModule({\n declarations: [GaugeComponent],\n imports: [],\n exports: [GaugeComponent],\n})\nexport class GaugeModule {\n static forRoot(\n userDefaults: GaugeOptions = {}\n ): ModuleWithProviders {\n return {\n ngModule: GaugeModule,\n providers: [\n {\n provide: USER_DEFAULTS,\n useValue: userDefaults,\n },\n {\n provide: GaugeDefaults,\n useFactory: (options: GaugeOptions) => {\n const defaults: GaugeDefaults = new GaugeDefaults();\n Object.assign(defaults, options);\n return defaults;\n },\n deps: [USER_DEFAULTS],\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of angular-gauge\n */\n\nexport * from './lib/gauge.component';\nexport * from './lib/gauge.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.GaugeDefaults"],"mappings":";;;;MA6Ea,aAAa,CAAA;AAA1B,IAAA,WAAA,GAAA;AACE;;AAEG;QACH,IAAc,CAAA,cAAA,GAAW,GAAG,CAAC;AAE7B;;AAEG;QACH,IAAY,CAAA,YAAA,GAAW,EAAE,CAAC;AAE1B;;AAEG;QACH,IAAU,CAAA,UAAA,GAAW,EAAE,CAAC;AAExB;;AAEG;QACH,IAAG,CAAA,GAAA,GAAW,CAAC,CAAC;AAEhB;;AAEG;QACH,IAAG,CAAA,GAAA,GAAW,GAAG,CAAC;AAYlB;;AAEG;QACH,IAAS,CAAA,SAAA,GAAY,IAAI,CAAC;AAE1B;;AAEG;QACH,IAAU,CAAA,UAAA,GAAW,OAAO,CAAC;AAE7B;;AAEG;QACH,IAAS,CAAA,SAAA,GAAW,MAAM,CAAC;AAE3B;;AAEG;QACH,IAAc,CAAA,cAAA,GAAW,OAAO,CAAC;AAEjC;;AAEG;QACH,IAAU,CAAA,UAAA,GAAW,YAAY,CAAC;AAOlC;;AAEG;QACH,IAAQ,CAAA,QAAA,GAAY,KAAK,CAAC;KAM3B;AAAA;;AC3ID,MAIa,cAAc,CAAA;IAmFzB,WAAoB,CAAA,GAAe,EAAU,QAAuB,EAAA;QAAhD,IAAG,CAAA,GAAA,GAAH,GAAG,CAAY;QAAU,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAe;AAPpE;;AAEG;AACO,QAAA,IAAA,CAAA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