UNPKG

@adobe/react-spectrum-charts

Version:

Declarative library for composing Spectrum visualizations in React.

75 lines 4.31 kB
import { ReactNode } from 'react'; import { View } from 'vega'; import { Datum } from '@spectrum-charts/vega-spec-builder'; import { Area, Axis, Bar, ChartPopover, ChartTooltip, Legend, Line, Scatter } from '../components'; import { BigNumber, Donut } from '../rc'; import { AreaElement, AxisAnnotationChildElement, AxisChildElement, AxisElement, BarAnnotationElement, BarElement, BigNumberElement, BulletElement, ChartChildElement, ChartElement, ChartPopoverElement, ChartTooltipElement, ChildElement, ComboElement, DonutSummaryElement, LegendElement, LineElement, MetricRangeElement, ScatterElement, ScatterPathElement, SegmentLabelElement, TitleElement, TrendlineElement, VennElement } from '../types'; type MarkChildElement = BarAnnotationElement | ChartTooltipElement | ChartPopoverElement | ScatterPathElement | MetricRangeElement | DonutSummaryElement | SegmentLabelElement | TrendlineElement; type RscElement = MarkChildElement | AreaElement | AxisElement | BarElement | BigNumberElement | BulletElement | LegendElement | LineElement | ScatterElement | TitleElement | ComboElement | VennElement; type MappedElement = { name: string; element: ChartElement | RscElement; parent?: string; }; export declare function toArray<Child>(children: Child | Child[] | undefined): Child[]; export declare const getElementDisplayName: (element: unknown) => string; export declare const sanitizeChildren: (children: unknown) => (ChartChildElement | MarkChildElement)[]; export declare const sanitizeRscChartChildren: (children: unknown) => ChartChildElement[]; export declare const sanitizeBigNumberChildren: (children: unknown) => LineElement[]; export declare const getBigNumberElementsFromChildren: (children: unknown) => BigNumberElement[]; export declare const sanitizeMarkChildren: (children: unknown) => MarkChildElement[]; export declare const sanitizeAxisChildren: (children: unknown) => AxisChildElement[]; export declare const sanitizeAxisAnnotationChildren: (children: ReactNode) => AxisAnnotationChildElement[]; export declare const sanitizeTrendlineChildren: (children: unknown) => ChartTooltipElement[]; /** * IMMUTABLE * * Adds the value to the target array if it doesn't exist, otherwise removes it * @param target * @param value * @returns */ export declare const toggleStringArrayValue: (target: string[], value: string) => string[]; export declare function getElement(element: ReactNode | (() => void), type: typeof Axis | typeof Bar | typeof ChartPopover | typeof ChartTooltip | typeof Legend | typeof Line | typeof Scatter): ChartElement | RscElement | undefined; /** * Traverses the mark elements finding all elements of the provided type and get the correct name for the element it is associated with * @param element * @param type * @returns */ export declare const getAllMarkElements: (target: unknown, source: typeof Area | typeof Bar | typeof Donut | typeof Line | typeof Scatter, elements?: MappedElement[], name?: string, parent?: string) => MappedElement[]; /** * Traverses the child elements finding all elements of the provided type and get the correct name for the element it is associated with * @param element * @param type * @returns */ export declare const getAllElements: (target: unknown, source: typeof Axis | typeof Bar | typeof BigNumber | typeof ChartPopover | typeof ChartTooltip | typeof Legend | typeof Line | typeof Scatter, elements?: MappedElement[], name?: string, parent?: string) => MappedElement[]; export declare const getComponentName: (element: ChildElement<RscElement>, defaultName: string) => string; /** * log for debugging */ export declare function debugLog(debug: boolean | undefined, { title, contents }: { contents?: unknown; title?: string; }): void; /** * Sets the values of the selectedId and selectedSeries signals * @param param0 */ export declare const setSelectedSignals: ({ idKey, selectedData, view, }: { idKey: string; selectedData: Datum | null; view: View; }) => void; /** * Return true if chart has a child with the corresponding displayName * @param0 * @returns boolean */ export declare const chartHasChild: ({ children, displayName }: { children: ChartChildElement[]; displayName: string; }) => ChartChildElement | undefined; export {}; //# sourceMappingURL=utils.d.ts.map