@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
121 lines (120 loc) • 6 kB
TypeScript
import { Observable, Subject } from "rxjs";
import { IChartAssist, IChartAssistEvent, IRenderStatesIndex } from "./types";
import { RenderState } from "../../renderers/types";
import { IAccessors, IChart, IChartAssistSeries, IChartEvent, IChartMarker, IChartPalette, IChartSeries, IDataPointsPayload, IRenderStateData, IValueProvider } from "../common/types";
/**
* Helper class that helps to bootstrap a chart with legend, using data pre-processor.
* It will use the most common settings.
*/
export declare class ChartAssist<T extends IAccessors = IAccessors> implements IChartAssist {
chart: IChart;
palette: IChartPalette;
markers: IValueProvider<IChartMarker>;
/**
* Retrieves the display value for a data point on the specified series
*
* @param chartSeries The series containing the data point to get a label for
* @param dataPoint The data point to get a label for
* @param scaleKey The key for the scale potentially containing a formatter that can be used to format the label
* @param formatterName The name of the formatter to use for formatting the label
* @param dataAccessorKey The accessor key to use for accessing the data value if the accessor key differs from the scale key
*
* @returns The display value for a data point
*/
static getLabel(chartSeries: IChartSeries<IAccessors>, dataPoint: any, scaleKey: string, formatterName?: string, dataAccessorKey?: string): any;
highlightedDataPoints: IDataPointsPayload;
isLegendActive: boolean;
inputSeriesSet: IChartAssistSeries<IAccessors>[];
legendSeriesSet: IChartAssistSeries<IAccessors>[];
/**
* Subject for subscribing to IChartAssistEvents such as
* ToggleSeries, EmphasizeSeries, and ResetVisibleSeries
*/
chartAssistSubject: Subject<IChartAssistEvent>;
private syncHandlerMap;
private getVisibleSeriesWithLegendBackup;
private syncSubscription;
private legendInteractionAssist;
onEvent: (event: IChartEvent) => void;
constructor(chart: IChart, seriesProcessor?: (series: IChartAssistSeries<T>[]) => IChartAssistSeries<T>[], palette?: IChartPalette, markers?: IValueProvider<IChartMarker>);
get renderStatesIndex(): IRenderStatesIndex;
/**
* Convenience stream of highlight events that can be used to populate legend.
* It will return highlighted value for the series (while hovering over datapoints) or the last value from series (while not hovering over and if possible),
* otherwise it'll return null
* @param chartSeries
*/
legendLabelData$(chartSeries: IChartSeries<IAccessors>): Observable<any>;
seriesProcessor(series: IChartAssistSeries<IAccessors>[]): IChartAssistSeries<IAccessors>[];
update(inputSeriesSet: IChartAssistSeries<IAccessors>[], updateLegend?: boolean): void;
toggleSeries: (seriesId: string, visible: boolean) => void;
/**
* Resets all visible series to default state
*/
resetVisibleSeries: () => void;
/**
* For series that are currently visible, emphasize the given series and deemphasizes all the other ones
*
* @param seriesId
*/
emphasizeSeries: (seriesId: string) => void;
isSeriesHidden(seriesId: string): boolean;
seriesTrackByFn(index: number, item: IChartAssistSeries<IAccessors>): string;
/**
* Retrieves the display value for the highlighted data point on the specified series
*
* @param chartSeries The series containing the highlighted data point to get a label for
* @param scaleKey The key for the scale potentially containing a formatter that can be used to format the label
* @param formatterName The name of the formatter to use for formatting the label
* @param dataAccessorKey The accessor key to use for accessing the data value if the accessor key differs from the scale key
*
* @returns The display value for the highlighted data point
*/
getHighlightedValue(chartSeries: IChartSeries<IAccessors>, scaleKey: string, formatterName?: string, dataAccessorKey?: string): string | number | undefined;
getVisibleSeriesWithLegend: () => IChartAssistSeries<IAccessors<any>>[];
/**
* Synchronize this chart assist's actions with IChartAssistEvents emitted by the specified
* chart assist, and override this chart assist's getVisibleSeriesWithLegend method with the
* specified chart assist's getVisibleSeriesWithLegend.
*
* Note: If the chart instance of the specified chart assist is replaced by a new chart,
* this method must be invoked again to resume synchronized behavior.
*
* @param {ChartAssist} chartAssist The chart assist to synchronize with
*/
syncWithChartAssist(chartAssist: ChartAssist): void;
/**
* Unsynchronize this chart assist's actions from those of the chart assist
* specified in a previous syncWithChartAssist call, and restore this chart
* assist's getVisibleSeriesWithLegend method with the instance used before
* syncWithChartAssist was called.
*/
unsyncChartAssist(): void;
private configureChartEventSubscriptions;
private publishRenderStates;
}
export declare class LegendInteractionAssist {
private chartAssist;
private seriesGroups;
private seriesIndex;
renderStatesIndex: IRenderStatesIndex;
constructor(chartAssist: ChartAssist);
update(seriesSet: IChartAssistSeries<IAccessors>[]): void;
getSeriesStates(): IRenderStateData[];
isSeriesHidden(seriesId: string): boolean;
private getSeriesGroups;
/**
* @param groupId id of the parent series
* @param renderState
*/
setGroupState(groupId: string, renderState: RenderState): void;
/**
* @param groupId id of the parent series
* @param visible
*/
setGroupVisibility(groupId: string, visible: boolean): void;
emphasizeSeries(seriesId: string): void;
resetSeries(): void;
private setRenderState;
private setVisibility;
}