UNPKG

perfrunner-reporters

Version:

Home of the perfrunner reporters

69 lines (68 loc) 2.66 kB
import { IPerformanceResult } from '../types'; import Chart, { ChartTooltipItem, ChartData } from 'chart.js'; declare type RunParams = { download: number; upload: number; latency: number; useCache: boolean; throttling: number; }; export interface IViewData<T> { data: T; labels: string[]; runParams: RunParams[]; timeStamp: number[]; } export declare abstract class AbstractChart<TData> { abstract readonly type: 'chart'; abstract readonly name: string; protected abstract readonly title: string; protected readonly FONT_FAMILIY = "'monospace', 'Verdana', 'sans-serif'"; protected readonly DEFAULT_LINE_WIDTH = 2; protected abstract getViewData: (data: IPerformanceResult) => IViewData<TData>; protected abstract getDatasetEntries: (viewData: TData) => Array<any>; protected abstract yAxesLabelCalback(value: string | number): string; render(container: Element, rawData: IPerformanceResult): void; protected animation: { duration: number; }; protected hover: { animationDuration: number; }; protected responsiveAnimationDuration: number; protected elements: { line: { tension: number; }; }; protected yAxes: () => Chart.ChartYAxe[]; protected xAxes: () => Chart.ChartXAxe[]; protected legend: () => { labels: { fontFamily: string; }; }; protected chartTitle: () => { text: string; display: boolean; fontFamily: string; }; protected getLabel: (index: number, comment: string | undefined) => string; protected runParams: (rawData: IPerformanceResult) => RunParams[]; protected withDefaults: (label: string, data: number[], color: string) => { label: string; data: number[]; borderColor: string; backgroundColor: string; borderWidth: number; }; protected tooltipLabel: (_: IViewData<TData>) => TooltipLabelCallback; protected tooltipFooter: ({ runParams, timeStamp }: IViewData<TData>) => (t: ChartTooltipItem[]) => string[] | ""; protected getCanvasContext: (container: HTMLElement | undefined) => CanvasRenderingContext2D; protected isVisible: (viewData: IViewData<TData>) => boolean; } declare type TooltipLabelCallback = (t: ChartTooltipItem, d: ChartData) => string; export declare const diffLabel: (formatter: (v: number) => string) => TooltipLabelCallback; export declare const msLabel: (value: string | number) => string; export declare const kbLabel: (value: string | number) => string; export {};