maneric-charts
Version:
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.0.
87 lines (80 loc) • 3.67 kB
TypeScript
import * as chart_js from 'chart.js';
import { ChartType, ChartDataset, ChartOptions, Chart, Plugin } from 'chart.js';
import * as i0 from '@angular/core';
import { AfterViewInit, OnChanges, OnDestroy, ElementRef, EventEmitter, SimpleChanges } from '@angular/core';
type ColorScheme = 'material' | 'category10' | 'pastel' | 'custom';
declare class ChartColorService {
private category10;
private pastel;
getForegroundColor(): string;
/**
* Returns an array of colors for charts based on scheme and theme
*/
getColors(scheme: ColorScheme, count: number, customColors?: string[]): string[];
/**
* Expand Angular Material theme colors into multiple shades
*/
private expandMaterialColors;
/**
* Generate lighter/darker shades of a base color
*/
private generateShades;
/**
* Adjust lightness of hex color
*/
private adjustLightness;
/**
* Repeat palette until count is satisfied
*/
private repeatPalette;
static ɵfac: i0.ɵɵFactoryDeclaration<ChartColorService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ChartColorService>;
}
declare abstract class BaseChartComponent<TType extends ChartType> implements AfterViewInit, OnChanges, OnDestroy {
private colorService;
canvas: ElementRef<HTMLCanvasElement>;
labels: string[];
datasets: ChartDataset<TType>[];
title?: string;
options?: ChartOptions<TType>;
colorScheme: ColorScheme;
colors?: string[];
pointClick: EventEmitter<{
label: string;
value: number;
}>;
chartInit: EventEmitter<Chart<keyof chart_js.ChartTypeRegistry, (number | chart_js.Point | [number, number] | chart_js.BubbleDataPoint | null)[], unknown>>;
chart?: Chart;
protected readonly target: HTMLDivElement;
constructor(colorService: ChartColorService);
ngAfterViewInit(): void;
ngOnChanges(changes: SimpleChanges): void;
private renderChart;
private buildConfig;
private updateChart;
ngOnDestroy(): void;
/** Must be implemented by each chart type */
protected abstract getChartType(): TType;
static ɵfac: i0.ɵɵFactoryDeclaration<BaseChartComponent<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<BaseChartComponent<any>, "ng-component", never, { "labels": { "alias": "labels"; "required": false; }; "datasets": { "alias": "datasets"; "required": false; }; "title": { "alias": "title"; "required": false; }; "options": { "alias": "options"; "required": false; }; "colorScheme": { "alias": "colorScheme"; "required": false; }; "colors": { "alias": "colors"; "required": false; }; }, { "pointClick": "pointClick"; "chartInit": "chartInit"; }, never, never, true, never>;
}
declare class BarChartComponent extends BaseChartComponent<'bar'> {
protected getChartType(): 'bar';
static ɵfac: i0.ɵɵFactoryDeclaration<BarChartComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<BarChartComponent, "bar-chart", never, {}, {}, never, never, true, never>;
}
declare class DonutChartComponent extends BaseChartComponent<'doughnut'> {
protected getChartType(): 'doughnut';
static ɵfac: i0.ɵɵFactoryDeclaration<DonutChartComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<DonutChartComponent, "donut-chart", never, {}, {}, never, never, true, never>;
}
interface CenterTextPluginOptions {
fontSize?: number;
fontColor?: string;
subTitle?: string;
text?: string;
prefix?: string;
}
declare const centerTextPlugin: Plugin<any>;
export { BarChartComponent, BaseChartComponent, DonutChartComponent, centerTextPlugin };
export type { CenterTextPluginOptions };