@opendatasoft/visualizations
Version:
Opendatasoft's components to easily build dashboards and visualizations.
62 lines (61 loc) • 1.93 kB
TypeScript
import type { Color } from 'types';
export declare const LEGEND_POSITIONS: {
readonly bottom: "bottom";
readonly left: "left";
readonly right: "right";
};
export type LegendPositions = typeof LEGEND_POSITIONS[keyof typeof LEGEND_POSITIONS];
export interface LegendLabelsConfiguration {
text?: (legendIndex: number) => string;
}
export interface LegendConfiguration {
display?: boolean;
position?: LegendPositions;
align?: 'start' | 'center' | 'end';
labels?: LegendLabelsConfiguration;
boxStyle?: 'rect' | 'line' | 'dash';
/** Wether to use ChartJS legend or homemade one
NOTE: temporary API for backward compatibility
*/
custom?: boolean;
}
export type LegendVariant = 'fluid' | 'fixed';
export declare const CATEGORY_ITEM_VARIANT: {
readonly Circle: "circle";
readonly Line: "line";
readonly Box: "box";
readonly Image: "image";
};
type BaseCategoryItem = {
label: LegendLabelsConfiguration | string | undefined;
onClick?: (index: number) => void;
onHover?(index: number, isVisible: boolean): void;
onLeave?(): void;
};
export type CircleCategoryItem = BaseCategoryItem & {
variant: typeof CATEGORY_ITEM_VARIANT.Circle;
color: Color;
borderColor?: Color;
};
export type BoxCategoryItem = BaseCategoryItem & {
variant: typeof CATEGORY_ITEM_VARIANT.Box;
color: Color;
borderColor?: Color;
};
export type LineCategoryItem = BaseCategoryItem & {
variant: typeof CATEGORY_ITEM_VARIANT.Line;
borderColor: Color;
dashed?: boolean;
};
export type ImageCategoryItem = BaseCategoryItem & {
variant: typeof CATEGORY_ITEM_VARIANT.Image;
src: string;
};
export type CategoryItem = CircleCategoryItem | BoxCategoryItem | LineCategoryItem | ImageCategoryItem;
export type CategoryLegend = {
type: 'category';
items: CategoryItem[];
title?: string;
align?: 'start' | 'center' | 'end';
};
export {};