UNPKG

ng2-charts

Version:

Reactive, responsive, beautiful charts for Angular based on Chart.js

89 lines (83 loc) 4.3 kB
import * as i0 from '@angular/core'; import { InjectionToken, OnDestroy, OnChanges, EventEmitter, SimpleChanges } from '@angular/core'; import { ChartComponentLike, Defaults, ChartType, DefaultDataPoint, ChartConfiguration, Plugin, ChartEvent, Chart, UpdateMode, ChartOptions } from 'chart.js'; import { BehaviorSubject } from 'rxjs'; type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? _DeepPartialArray<U> : T extends object ? _DeepPartialObject<T> : T | undefined; type _DeepPartialArray<T> = Array<DeepPartial<T>>; type _DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]>; }; declare const NG_CHARTS_CONFIGURATION: InjectionToken<NgChartsConfiguration>; type NgChartsConfiguration = { /** * Any registerable that can be used with `Chart.register()`, such as plugins, controllers, scales, and elements. */ registerables?: readonly ChartComponentLike[]; /** * Default configuration that can be used with `defaults.set()`. */ defaults?: DeepPartial<Defaults>; }; /** * Provide all the default registerable as defined by Chart.js */ declare function withDefaultRegisterables(...registerables: ChartComponentLike[]): NgChartsConfiguration; /** * Provide configuration for ngCharts. In most cases, you have to pass it some registerables. So either * `withDefaultRegisterables()`, or a custom list of registerables tailored to your needs to reduce bundle size. */ declare function provideCharts(...configurations: readonly NgChartsConfiguration[]): { provide: InjectionToken<NgChartsConfiguration>; useValue: NgChartsConfiguration; }; declare class BaseChartDirective<TType extends ChartType = ChartType, TData = DefaultDataPoint<TType>, TLabel = unknown> implements OnDestroy, OnChanges { type: ChartConfiguration<TType, TData, TLabel>['type']; legend?: boolean; data?: ChartConfiguration<TType, TData, TLabel>['data']; options: ChartConfiguration<TType, TData, TLabel>['options']; plugins: Plugin<TType>[]; labels?: ChartConfiguration<TType, TData, TLabel>['data']['labels']; datasets?: ChartConfiguration<TType, TData, TLabel>['data']['datasets']; chartClick: EventEmitter<{ event?: ChartEvent; active?: object[]; }>; chartHover: EventEmitter<{ event: ChartEvent; active: object[]; }>; ctx: CanvasRenderingContext2D | null; chart?: Chart<TType, TData, TLabel>; private subs; private themeOverrides; private element; private zone; private themeService; private config; private platformId; private isBrowser; constructor(); ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; render(): Chart<TType, TData, TLabel> | undefined; update(mode?: UpdateMode): void; hideDataset(index: number, hidden: boolean): void; isDatasetHidden(index: number): boolean | undefined; toBase64Image(): string | undefined; private themeChanged; private getChartOptions; private getChartConfiguration; private getChartData; static ɵfac: i0.ɵɵFactoryDeclaration<BaseChartDirective<any, any, any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<BaseChartDirective<any, any, any>, "canvas[baseChart]", ["base-chart"], { "type": { "alias": "type"; "required": false; }; "legend": { "alias": "legend"; "required": false; }; "data": { "alias": "data"; "required": false; }; "options": { "alias": "options"; "required": false; }; "plugins": { "alias": "plugins"; "required": false; }; "labels": { "alias": "labels"; "required": false; }; "datasets": { "alias": "datasets"; "required": false; }; }, { "chartClick": "chartClick"; "chartHover": "chartHover"; }, never, never, true, never>; } declare class ThemeService { private pColorschemesOptions?; colorschemesOptions: BehaviorSubject<ChartOptions | undefined>; setColorschemesOptions(options: ChartConfiguration['options']): void; getColorschemesOptions(): ChartConfiguration['options']; static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>; } export { BaseChartDirective, NG_CHARTS_CONFIGURATION, ThemeService, provideCharts, withDefaultRegisterables }; export type { DeepPartial, NgChartsConfiguration };