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

162 lines (161 loc) 7.96 kB
import { GaugeMode } from "./constants"; import { IGaugeConfig, IGaugeThresholdDatum, IGaugeThresholdsData, IGaugeThresholdsConfig } from "./types"; import { ChartAssist } from "../core/chart-assists/chart-assist"; import { Renderer } from "../core/common/renderer"; import { IRadialScales, Scales } from "../core/common/scales/types"; import { IAccessors, IChartAssistSeries, IDataSeries } from "../core/common/types"; import { IAllAround } from "../core/grid/types"; import { DonutGaugeLabelsPlugin } from "../core/plugins/gauge/donut-gauge-labels-plugin"; import { LinearGaugeLabelsPlugin } from "../core/plugins/gauge/linear-gauge-labels-plugin"; /** * @ignore * Attributes needed by a gauge */ export interface IGaugeRenderingAttributes { /** Accessors for the gauge quantity segment */ quantityAccessors: IAccessors; /** Accessors for the gauge remainder segment */ remainderAccessors: IAccessors; /** Scales for the gauge */ scales: Scales; /** Renderer for the primary gauge visualization */ mainRenderer: Renderer<IAccessors>; /** Renderer for the gauge threshold visualization */ thresholdsRenderer: Renderer<IAccessors>; } /** * @ignore * Interface for an object that can be used to create the rendering attributes needed by a gauge */ export interface IGaugeRenderingTools { /** Function for creating quantity accessors */ quantityAccessorFunction: () => IAccessors; /** Function for creating remainder accessors */ remainderAccessorFunction: () => IAccessors; /** Function for creating scales */ scaleFunction: () => Scales | IRadialScales; /** Function for creating a main renderer */ mainRendererFunction: () => Renderer<IAccessors>; /** Function for creating a thresholds renderer */ thresholdsRendererFunction: () => Renderer<IAccessors>; } /** * Convenience utility for simplifying gauge usage */ export declare class GaugeUtil { /** Value used for unifying the linear-style gauge visualization into a single bar stack */ static readonly DATA_CATEGORY = "gauge"; /** * Creates a ChartAssist pre-configured based on the provided IGaugeConfig and GaugeMode * * @param gaugeConfig The gauge configuration * @param mode The gauge mode * @param labelsPlugin Optional labels plugin for direct control of label configuration. If not provided, a plugin will * be generated automatically. * * @returns {ChartAssist} A pre-configured chart assist */ static createChartAssist(gaugeConfig: IGaugeConfig, mode: GaugeMode, labelsPlugin?: DonutGaugeLabelsPlugin | LinearGaugeLabelsPlugin): ChartAssist; /** * Assembles a gauge series set with all of the standard scales, renderers, accessors, etc. needed for creating a gauge visualization * * @param gaugeConfig The configuration for the gauge * @param mode The mode of the gauge (Donut, Horizontal, or Vertical) * * @returns {IChartAssistSeries<IAccessors>[]} The assembled series set */ static assembleSeriesSet(gaugeConfig: IGaugeConfig, mode: GaugeMode): IChartAssistSeries<IAccessors>[]; /** * Updates the series set based on the provided configuration * * @param seriesSet The set of series to update * @param gaugeConfig The configuration for the gauge * * @returns {IChartAssistSeries<IAccessors>[]} The updated series set */ static update(seriesSet: IChartAssistSeries<IAccessors>[], gaugeConfig: IGaugeConfig): IChartAssistSeries<IAccessors>[]; /** * Convenience function for creating a standard standard set of threshold configs. Includes configurations for warning and error thresholds. * * @param warningVal Value for the warning threshold * @param criticalVal Value for the critical threshold * * @returns {IGaugeThresholdsConfig} The thresholds configuration */ static createStandardThresholdsConfig(warningVal: number, criticalVal: number): IGaugeThresholdsConfig; /** * Gets a new instance of the provided grid margin with updated values (if needed) to accommodate the label clearance specified * in the provided gauge configuration * * @param gaugeConfig The gauge's configuration * @param mode The mode of the gauge * @param margin The margin to update * * @returns {IAllAround<number>} The updated margin */ static getMarginForLabelClearance(gaugeConfig: IGaugeConfig, mode: GaugeMode, margin: IAllAround<number>): IAllAround<number>; /** * Generates a set of chart series used for visualizing the gauge's quantity and remainder data * * @param gaugeConfig The configuration for the gauge * @param renderingAttributes The attributes needed to visualized the thresholds * @param activeThreshold The currently active threshold * * @returns {IChartAssistSeries<IAccessors<any>>[]} A set of chart series representing the quantity and remainder data */ static generateQuantityAndRemainderSeriesSet(gaugeConfig: IGaugeConfig, renderingAttributes: IGaugeRenderingAttributes, activeThreshold?: IGaugeThresholdDatum): IChartAssistSeries<IAccessors<any>>[]; /** * Generates a series for visualizing the gauge's thresholds * * @param gaugeConfig The configuration for the gauge * @param renderingAttributes The attributes needed to visualized the thresholds * * @returns {IChartAssistSeries<IAccessors>} The threshold series */ static generateThresholdSeries(gaugeConfig: IGaugeConfig, renderingAttributes: IGaugeRenderingAttributes): IChartAssistSeries<IAccessors>; /** * Generates the attributes required to instantiate a standard gauge in the specified mode * * @param gaugeConfig The configuration for the gauge * @param mode The mode of the gauge (Donut, Horizontal, or Vertical) * * @returns {IGaugeRenderingAttributes} The attributes required to instantiate a gauge */ static generateRenderingAttributes(gaugeConfig: IGaugeConfig, mode: GaugeMode): IGaugeRenderingAttributes; /** * Generates rendering tools for standard gauge attributes * * @param gaugeConfig The configuration for the gauge * @param mode The mode of the gauge (Donut, Horizontal, or Vertical) * * @returns {IGaugeRenderingTools} The rendering tools for standard gauge attributes */ static generateRenderingTools(gaugeConfig: IGaugeConfig, mode: GaugeMode): IGaugeRenderingTools; /** * Generates quantity and remainder data in the format needed by the gauge visualization * * @param gaugeConfig The configuration for the gauge * * @returns {Partial<IDataSeries<IAccessors>>[]} Array of partial IDataSeries objects including the 'id' and 'data' properties of the quantity and remainder * series needed by the gauge visualization */ static generateQuantityAndRemainderData(gaugeConfig: IGaugeConfig): Partial<IDataSeries<IAccessors>>[]; /** * Generates threshold data in the form needed by the gauge's thresholds visualization * * @param gaugeConfig The configuration for the gauge * * @returns {Partial<IDataSeries<IAccessors, IGaugeThresholdDatum>>} A partial IDataSeries object including the 'id' and 'data' properties of the thresholds * series used for the the gauge's thresholds visualization */ static generateThresholdsData(gaugeConfig: IGaugeConfig): Partial<IDataSeries<IAccessors, IGaugeThresholdDatum>>; /** * Generates visualization-specific thresholds data based on the gauge's configuration * * @param gaugeConfig The gauge configuration * * @returns {IGaugeThresholdsData} Thresholds data modified for use by the gauge visualization */ static prepareThresholdsData(gaugeConfig: IGaugeConfig): IGaugeThresholdsData; private static clampConfigToRange; }