{"version":3,"file":"ajf-core-echarts.mjs","sources":["../../../projects/core/echarts/src/echarts-config.ts","../../../projects/core/echarts/src/echarts-directive.ts","../../../projects/core/echarts/src/echarts-module.ts","../../../projects/core/echarts/src/public_api.ts","../../../projects/core/echarts/src/ajf-core-echarts.ts"],"sourcesContent":["/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {InjectionToken} from '@angular/core';\n\nexport type EchartsModule = any;\n\nexport type AjfEchartsProvider = () => Promise<EchartsModule>;\n\nexport interface AjfEchartsConfig {\n  echarts: EchartsModule | AjfEchartsProvider;\n}\n\nexport const AJF_ECHARTS_PROVIDER = new InjectionToken<AjfEchartsProvider>('AJF_ECHARTS_PROVIDER');\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\n/// <reference types=\"resize-observer-browser\" />\n\nimport {\n  Directive,\n  ElementRef,\n  EventEmitter,\n  Inject,\n  Input,\n  NgZone,\n  OnChanges,\n  OnDestroy,\n  OnInit,\n  Output,\n  SimpleChanges,\n} from '@angular/core';\nimport {Subscription} from 'rxjs';\nimport {debounceTime} from 'rxjs/operators';\n\nimport {AjfEchartsProvider, AJF_ECHARTS_PROVIDER} from './echarts-config';\n\nexport type EChartsRenderer = 'canvas' | 'svg';\n\nexport interface AjfEchartsInitEvent {\n  echarts: any;\n  chart: echarts.ECharts;\n}\n\n@Directive({selector: '[ajfEcharts]', exportAs: 'ajfEcharts'})\nexport class AjfEchartsDirective implements OnChanges, OnDestroy, OnInit {\n  @Input()\n  set theme(theme: string | object | undefined) {\n    this._theme = theme;\n  }\n  private _theme?: string | object;\n\n  @Input()\n  set renderer(renderer: EChartsRenderer) {\n    this._renderer = renderer;\n  }\n  private _renderer: EChartsRenderer = 'canvas';\n\n  @Input()\n  set options(options: echarts.EChartsOption | undefined) {\n    this._options = options;\n  }\n  private _options?: echarts.EChartsOption;\n\n  @Output()\n  readonly chartInit = new EventEmitter<AjfEchartsInitEvent>();\n\n  private _echarts?: any;\n  private _container: HTMLElement;\n  private _chart?: echarts.ECharts;\n  private _resizeObserver?: ResizeObserver;\n  private _resizeEvent = new EventEmitter<void>();\n  private _resizeSub = Subscription.EMPTY;\n\n  constructor(\n    @Inject(AJF_ECHARTS_PROVIDER) private _echartsProvider: AjfEchartsProvider,\n    el: ElementRef<HTMLElement>,\n    private _ngZone: NgZone,\n  ) {\n    this._container = el.nativeElement;\n    if (typeof ResizeObserver !== 'undefined') {\n      this._resizeObserver = new ResizeObserver(() => this._onResize());\n    }\n  }\n\n  ngOnChanges(changes: SimpleChanges): void {\n    if (changes['theme'] != null || changes['renderer'] != null) {\n      this._destroyChart();\n      this._initChart();\n    } else if (changes['options'] != null) {\n      if (this._options) {\n        if (this._chart != null) {\n          this._chart.setOption(this._options);\n        } else {\n          this._initChart();\n        }\n      } else {\n        this._destroyChart();\n      }\n    }\n  }\n\n  ngOnDestroy(): void {\n    if (this._resizeObserver != null) {\n      this._resizeObserver.unobserve(this._container);\n      this._resizeObserver.disconnect();\n    }\n    this._resizeEvent.complete();\n    this._resizeSub.unsubscribe();\n    this._destroyChart();\n  }\n\n  ngOnInit(): void {\n    if (this._resizeObserver != null) {\n      this._resizeObserver.observe(this._container);\n      this._resizeSub = this._resizeEvent\n        .pipe(debounceTime(200))\n        .subscribe(() => this._resizeChart());\n    }\n    this._ngZone.runOutsideAngular(() => {\n      this._echartsProvider().then(echarts => {\n        this._echarts = echarts;\n        this._initChart();\n      });\n    });\n  }\n\n  private _destroyChart(): void {\n    if (this._chart != null && !this._chart.isDisposed()) {\n      this._chart.dispose();\n      this._chart = undefined;\n    }\n  }\n\n  private _initChart(): void {\n    if (this._echarts == null) {\n      return;\n    }\n    this._chart = this._echarts.init(this._container, this._theme, {renderer: this._renderer});\n    if (this._chart == null) {\n      return;\n    }\n    if (this._options) {\n      this._chart.setOption(this._options);\n    }\n    this.chartInit.emit({echarts: this._echarts, chart: this._chart});\n  }\n\n  private _onResize(): void {\n    this._resizeEvent.emit();\n  }\n\n  private _resizeChart(): void {\n    if (this._chart != null) {\n      this._chart.resize();\n    }\n  }\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {ModuleWithProviders, NgModule} from '@angular/core';\n\nimport {AjfEchartsConfig, AjfEchartsProvider, AJF_ECHARTS_PROVIDER} from './echarts-config';\nimport {AjfEchartsDirective} from './echarts-directive';\n\n@NgModule({\n  declarations: [AjfEchartsDirective],\n  exports: [AjfEchartsDirective],\n})\nexport class AjfEchartsModule {\n  static forRoot(config: AjfEchartsConfig): ModuleWithProviders<AjfEchartsModule> {\n    let echarts: any | AjfEchartsProvider = config.echarts;\n    if (typeof echarts !== 'function') {\n      echarts = (async () => echarts) as AjfEchartsProvider;\n    }\n    return {\n      ngModule: AjfEchartsModule,\n      providers: [{provide: AJF_ECHARTS_PROVIDER, useValue: echarts}],\n    };\n  }\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nexport * from './echarts-config';\nexport * from './echarts-directive';\nexport * from './echarts-module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;MAYU,oBAAoB,GAAG,IAAI,cAAc,CAAqB,sBAAsB;;AChCjG;;;;;;;;;;;;;;;;;;;;AAoBG;AAEH;MA4Ba,mBAAmB,CAAA;IAC9B,IACI,KAAK,CAAC,KAAkC,EAAA;AAC1C,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;IAIrB,IACI,QAAQ,CAAC,QAAyB,EAAA;AACpC,QAAA,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