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

64 lines (63 loc) 2.72 kB
import { ConnectedPosition } from "@angular/cdk/overlay"; import { Subject } from "rxjs"; import { ChartPlugin } from "../../common/chart-plugin"; import { IAccessors, IChartSeries, IDataPoint, IDataPointsPayload, IPosition } from "../../common/types"; /** Position with extended information for positioning a tooltip */ export interface ITooltipPosition extends IPosition { overlayPositions: ConnectedPosition[]; } /** How far away from the data point position will the tooltip be positioned */ export declare const TOOLTIP_POSITION_OFFSET = 10; /** @ignore * Used for charts where tooltips should be placed aside of some vertical line */ export declare const getVerticalSetup: (offset: number) => ConnectedPosition[]; /** @ignore * Used for charts where tooltips should be placed aligned to some horizontal line (as Horizontal Bar Charts) */ export declare const getHorizontalSetup: (offset: number) => ConnectedPosition[]; /** * This plugin listens to the INTERACTION_DATA_POINTS_EVENT and transforms received data into tooltips inputs. * The actual tooltips are handled by the ChartTooltipsComponent. */ export declare class ChartTooltipsPlugin extends ChartPlugin { readonly tooltipPositionOffset: number; orientation: "right" | "top"; /** Highlighted data points received from the chart */ dataPoints: IDataPointsPayload; /** Calculated positions for the data point tooltips */ dataPointPositions: { [stringId: string]: ITooltipPosition; }; /** * This publishes an event to show tooltips */ showSubject: Subject<void>; /** * This publishes an event to hide tooltips */ hideSubject: Subject<void>; protected overlaySetup: ConnectedPosition[]; private isChartInView; private readonly destroy$; private seriesVisibilityMap; /** * @param tooltipPositionOffset Offset of a tooltip from edge of a highlighted element * @param orientation */ constructor(tooltipPositionOffset?: number, orientation?: "right" | "top"); initialize(): void; destroy(): void; processHighlightedDataPoints(dataPoints: IDataPointsPayload): void; /** * Calculate tooltip position. Default implementation shows the tooltip on left / right with * @param dataPoint * @param chartSeries */ protected getTooltipPosition(dataPoint: IDataPoint, chartSeries: IChartSeries<IAccessors>): ITooltipPosition; /** * Converts the relative position within a chart into an absolute position on the screen * * @param relativePosition * @param chartPosition */ protected getAbsolutePosition(relativePosition: ITooltipPosition, chartPosition: IPosition): ITooltipPosition; }