...
IChart Interface - Base Interface for Chart Components. <ReportType = Chart>
This is the interface that every chart component should implement.
config takes the required metadata to render a chart like label datasets/series, tooltips legend, title, axes detailes etc. Please refer to the below. image to know most commonly used chart parts . Interface also takes additional metadata if required.
labelExpr - refers to the column name or key in the JSON which can be used as x axis labels
dataExpr - refers to the key in the JSON to be used on y axis as dataset.
...
Code Block | ||
---|---|---|
| ||
interface IChart extends IBase { readonly _defaultConfig: IChartConfig; // default config for tooltips colors legend etc. config: IChartConfig; chartClick: EventEmitter<any>; chartHover: EventEmitter<any>; chartBuilder(config); // (prepares / converts) input chart config as per the underlying chart library used. refreshChart(); // refreshes and updates the chart either at specific interval or explicitly triggerd addData({ label, data, config }); //appends the label and data at the end; removeData(); //pops the last data and label removeData(label: string) // removes a specific label getTelemetry(); // mergeData(data1, data2, ...dataN): any[]; getCurrentSelection(); getDatasetAtIndex(index: number); } interface IChartConfig { type: IChartType; options?: IChartOptions; [key: string]: any; } type IChartType = "bar" | "line" | "pie" | "etc"; type IChartOptions = { labels? : string[], // if labels are passed explicitely labelExpr ? : string; // column name to use as x-axis labels; datasets: IDataset[]; // datasets - y axis data tooltip?: object; legend?: object animation?: object; colors?: object; title?: string; description: string; subtitle?: string; caption?: object; scales?: { axes: any; [key: string]: any; }; [key: string]: any; }; type IDataset = { label: string; dataExpr?: string; data: any[]; } |
...