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

115 lines (114 loc) 7.36 kB
import { LoggerService } from "@nova-ui/bits"; import { ISimpleThresholdZone, ZoneBoundary } from "./types"; import { Scales } from "../core/common/scales/types"; import { DataAccessor, IChartAssistSeries, IDataSeries, IPosition, IRendererConfig, IValueProvider } from "../core/common/types"; import { IAreaAccessors } from "../renderers/area/area-accessors"; import { IStatusAccessors } from "../renderers/bar/accessors/status-accessors"; import { ILineAccessors } from "../renderers/line/line-accessors"; import { ISideIndicatorAccessors } from "../renderers/side-indicator-renderer"; import * as i0 from "@angular/core"; /** * This service provides functionality that facilitates the creation of thresholds related visual element on charts. */ export declare class ThresholdsService { private loggerService; static SERIES_ID_SUFFIX: string; constructor(loggerService: LoggerService); /** * Calculates the threshold "statuses" - from/to and what zone we're in. It is the first step that is required before the usage of other methods. Having * the threshold "statuses" assigned to each data point enables us to access the threshold information not only in other methods for threshold * calculation, but also in other places, like legend or tooltips. * * @param dataSeries source data series that will be enhanced with threshold metadata * @param zones zones defined as data series with IAreaAccessors */ injectThresholdsData(dataSeries: IDataSeries<ILineAccessors>, zones: IDataSeries<IAreaAccessors>[]): void; /** * This method creates a background series for TimeInterval or continuous (currently only works with time) scale. * If the series is continuous it detects intersection of source line data with given threshold zones and generates start / end for status periods. * Otherwise it will use the start and the end of the band. * * The default value of the rendererConfig parameter is {@link THRESHOLDS_MAIN_CHART_RENDERER_CONFIG}. For a summary chart, usually a smaller status * chart positioned below a main chart, use {@link THRESHOLDS_SUMMARY_RENDERER_CONFIG}. * * @param sourceSeries The data series from which to derive a background visualization * @param zones Zones defined as data series with IAreaAccessors * @param scales The scales to be used for the background visualization * @param colorProvider A value provider for the colors to be used for each status * @param thicknessMap Map of status to number specifying a custom height per status for the background visualization. * If a status is not specified in the map, the default thickness is the full height of the rendering area. * @param rendererConfig The renderer's configuration */ getBackgrounds(sourceSeries: IDataSeries<ILineAccessors>, zones: IDataSeries<IAreaAccessors>[], scales: Scales, colorProvider: IValueProvider<string>, thicknessMap?: Record<string, number>, rendererConfig?: IRendererConfig): IChartAssistSeries<IStatusAccessors>; /** * Calculates background data for continuous scale based on intersections between the source data and zone definitions. * * @param sourceSeries source data series from which to derive background data * @param zones zones defined as data series with IAreaAccessors */ private getBackgroundsDataForContinuousScale; /** * Calculate all "interesting" points along the data series that will be important to calculate the threshold status changes * * @param sourceSeries source data series from which to derive the break points * @param zones zones defined as data series with IAreaAccessors */ private getBreakPoints; /** * Generates threshold zone series from simplified zone definition. Simplified definition provides only two numbers to define the zone interval. * Creating these series manually is also possible for dynamic threshold limits. * * @param sourceSeries source data series from which to derive the zones * @param simpleZones a collection of zones that are each defined by a start value and/or an end value. (A missing start or end value indicates an infinite zone.) * @param colorProvider A value provider for the colors to be used for each status */ getThresholdZones(sourceSeries: IDataSeries<ILineAccessors>, simpleZones: ISimpleThresholdZone[], colorProvider: IValueProvider<string>): IDataSeries<IAreaAccessors>[]; /** * Creates data series representing threshold lines on the chart. Solves collision between zones, where multiple zones are using the same limit value. * * @param zones Zones defined as data series with IAreaAccessors */ getThresholdLines(zones: IDataSeries<IAreaAccessors>[]): IChartAssistSeries<ILineAccessors>[]; /** * Creates a IChartAssistSeries that represents a threshold zone limit defined by given valueAccessor * * @param zone A zone defined as a data series with IAreaAccessors * @param valueAccessor Accessor for the threshold limit * @param zoneBoundary The zone boundary represented by the line. Default is ZoneBoundary.Start. */ getThresholdLine(zone: IDataSeries<IAreaAccessors>, valueAccessor: DataAccessor, zoneBoundary?: ZoneBoundary): IChartAssistSeries<ILineAccessors>; /** * Calculates the point where the data series line will cross a threshold line using the two closest points for each * * @param {IPosition} dataFrom Data starting point * @param {IPosition} dataTo Data ending point * @param {IPosition} thresholdFrom Threshold starting point * @param {IPosition} thresholdTo Threshold ending point * @returns {IPosition} the position of the cross point or `null` if lines don't cross */ getCrossPoint(dataFrom: IPosition, dataTo: IPosition, thresholdFrom: IPosition, thresholdTo: IPosition): IPosition | undefined; /** * Find the zone that is relevant for current input data point defined by x, y coordinates. * Keep increasing the index while the next x value of threshold zone is still less than input x * * @param zones Zones defined as data series with IAreaAccessors * @param zoneIndexes provided indexes keep the last used value for searching for the given x coordinate, so it is expected that provided data points * are ordered by x in ascending order. * @param x The x value of the zone * @param y The y value of the zone */ private getZoneByXY; private moveZoneIndex; getCrossPointWithY(dataFrom: IPosition, dataTo: IPosition, y: number): IPosition | undefined; /** * Creates side indicator data series for given threshold zones * * @param zones Zones defined as data series with IAreaAccessors * @param scales The scales to be used for the side indicators * @param rendererConfig Configuration for the renderer. Default is the exported constant 'THRESHOLDS_MAIN_CHART_RENDERER_CONFIG' */ getSideIndicators(zones: IDataSeries<IAreaAccessors>[], scales: Scales, rendererConfig?: IRendererConfig): IChartAssistSeries<ISideIndicatorAccessors>[]; static ɵfac: i0.ɵɵFactoryDeclaration<ThresholdsService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ThresholdsService>; }