UNPKG

@nova-ui/charts

Version:

Nova Charts is a library created to provide potential consumers with solutions for various data visualizations that conform with the Nova Design Language. It's designed to solve common patterns identified by UX designers, but also be very flexible so that

111 lines (110 loc) 5.24 kB
import { Selection } from "d3-selection"; import { ValueMap } from "d3-selection-multi"; import { Subject } from "rxjs"; import { IScale, Scales } from "./scales/types"; import { D3Selection, IAccessors, IDataPoint, IDataSeries, ILasagnaLayer, IPosition, IRenderContainers, IRendererConfig, IRendererEventPayload } from "./types"; import { IRenderSeries, RenderState } from "../../renderers/types"; /** * The abstract base class for chart renderers with some limited default functionality */ export declare abstract class Renderer<TA extends IAccessors> { config: IRendererConfig; static readonly DEFAULT_CONFIG: IRendererConfig; constructor(config?: IRendererConfig); interaction: Record<string, any>; /** * Draw the visual representation of the provided data series * * @param {IRenderSeries} renderSeries The series to render * @param {Subject<IRendererEventPayload>} rendererSubject A subject to optionally invoke for emitting events regarding a data point */ abstract draw(renderSeries: IRenderSeries<TA>, rendererSubject: Subject<IRendererEventPayload>): void; /** * Return position of a specified datapoint * * @param {IDataSeries} dataSeries * @param {number} index * @param {Scales} scales * @returns {IPosition} */ abstract getDataPointPosition(dataSeries: IDataSeries<TA>, index: number, scales: Scales): IPosition | undefined; /** * Based on provided values, return the nearest data point that the given coordinates represent. This is used for mouse hover behavior * * @param {IDataSeries} series series from which to determine the index corresponding to the specified values * @param {{ [axis: string]: any }} values the values from which a data point index can be determined * @param {Scales} scales the scales to be used in the index calculation * * @returns {number} negative value means that index is not found */ getDataPointIndex(series: IDataSeries<TA>, values: { [axis: string]: any; }, scales: Scales): number; /** * Highlight the data point corresponding to the specified data point index * * @param {IRenderSeries} renderSeries The series on which to render the data point highlight * @param {number} dataPointIndex index of the highlighted point within the data series (pass -1 to remove the highlight marker) * @param {Subject<IRendererEventPayload>} rendererSubject A subject to optionally invoke for emitting events regarding a data point */ highlightDataPoint(renderSeries: IRenderSeries<TA>, dataPointIndex: number, rendererSubject: Subject<IRendererEventPayload>): void; /** * Get the style attributes for the specified state that we need to apply to a series container * * @param {RenderState} state the state for which to retrieve container styles * * @returns {ValueMap<any, any>} the container styles for the specified state */ getContainerStateStyles: (state: RenderState) => ValueMap<any, any>; /** * Set the RenderState of the target data series * * @param {IRenderContainers} renderContainers the render containers of the series * @param {RenderState} state The new state for the target series */ setSeriesState(renderContainers: IRenderContainers, state: RenderState): void; /** * Set the RenderState of the target data point * * @param {D3Selection} target the target data point * @param {RenderState} state The new state for the target data point */ setDataPointState(target: D3Selection, state: RenderState): void; /** * Calculate domain for data filtered by given filterScales * * @param dataSeries * @param filterScales * @param scaleKey * @param scale * @returns array of datapoints from <code>dataSeries</code> filtered by domains of given <code>filterScale</code>s */ getDomainOfFilteredData(dataSeries: IDataSeries<TA>, filterScales: Record<string, IScale<any>>, scaleKey: string, scale: IScale<any>): any[]; /** * Calculate the domain using the data of a series * * @param {any[]} data source data, can be filtered * @param dataSeries related data series * @param {string} scaleName name of the scale for which domain calculation is needed * @param scale * * @returns {[any, any]} min and max values as an array */ getDomain(data: any[], dataSeries: IDataSeries<TA>, scaleName: string, scale: IScale<any>): any[]; /** * Filters given dataset by domain of provided scale * * @param data * @param dataSeries * @param scaleName * @param domain */ filterDataByDomain(data: any[], dataSeries: IDataSeries<TA>, scaleName: string, domain: any[]): any[]; /** * Get the definitions of lasagna layers required for visualizing data * * @returns {ILasagnaLayer[]} lasagna layer definitions */ getRequiredLayers(): ILasagnaLayer[]; protected setupInteraction(path: string[], nativeEvent: string, target: Selection<any, any, any, any>, dataPointSubject: Subject<IRendererEventPayload>, dataPoint: Partial<IDataPoint>): void; }