Skip to content

Commit 2d0bc5b

Browse files
committed
feat(plugin.legend): add legend navigation type definitions
1 parent ff0d9fd commit 2d0bc5b

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

src/types/index.d.ts

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,10 +2339,18 @@ export interface LegendItem {
23392339
textAlign?: TextAlign;
23402340
}
23412341

2342+
export interface LegendNavigation {
2343+
active: boolean;
2344+
page: number;
2345+
totalPages: number;
2346+
legendItems?: LegendItem[];
2347+
}
2348+
23422349
export interface LegendElement<TType extends ChartType> extends Element<AnyObject, LegendOptions<TType>>, LayoutItem {
23432350
chart: Chart<TType>;
23442351
ctx: CanvasRenderingContext2D;
23452352
legendItems?: LegendItem[];
2353+
navigation: LegendNavigation;
23462354
options: LegendOptions<TType>;
23472355
fit(): void;
23482356
}
@@ -2499,6 +2507,71 @@ export interface LegendOptions<TType extends ChartType> {
24992507
*/
25002508
text: string;
25012509
};
2510+
2511+
navigation: {
2512+
/**
2513+
* Show/hide legend navigation.
2514+
*
2515+
* If `auto` is used, the navigation will be shown only if the legend overflows.
2516+
* @default false
2517+
*/
2518+
display: 'auto' | boolean;
2519+
/**
2520+
* Color of the navigation page count label.
2521+
* @see Defaults.color
2522+
*/
2523+
color: Color;
2524+
/**
2525+
* Color of active navigation arrows.
2526+
* @see Defaults.color
2527+
*/
2528+
activeColor: Color;
2529+
/**
2530+
* Color of inactive navigation arrows.
2531+
*
2532+
* Defaults to 40% opacity of the active color.
2533+
*/
2534+
inactiveColor: Color;
2535+
/**
2536+
* Size of navigation arrows.
2537+
* @default 12
2538+
*/
2539+
arrowSize: number;
2540+
/**
2541+
* Maximum number of columns, in vertical legends, for navigation to be activated.
2542+
* @default 1
2543+
*/
2544+
maxCols: number;
2545+
/**
2546+
* Maximum number of rows, in horizontal legends, for navigation to be activated.
2547+
* @default 3
2548+
*/
2549+
maxRows: number;
2550+
/**
2551+
* Navigation buttons padding.
2552+
* @default
2553+
* { x: 10, y: 10, top: 0 }
2554+
*/
2555+
padding: number | ChartArea;
2556+
/**
2557+
* Alignment of navigation buttons.
2558+
* @default 'start'
2559+
*/
2560+
align: 'start' | 'center' | 'end';
2561+
/**
2562+
* Align legends horizontally and vertically.
2563+
*
2564+
* Fixes the width/height of all legends according to the widest/tallest legend, to form a grid and keep legends aligned when changing pages.
2565+
* @default true
2566+
*/
2567+
grid: boolean | { x?: boolean; y?: boolean; },
2568+
/**
2569+
* Font style of the navigation page count label.
2570+
* @default
2571+
* { weight: 'bold', size: 14 }
2572+
*/
2573+
font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableChartContext>;
2574+
}
25022575
}
25032576

25042577
export declare const SubTitle: Plugin;
@@ -3725,7 +3798,7 @@ export type ChartType = keyof ChartTypeRegistry;
37253798

37263799
export type ScaleOptionsByType<TScale extends ScaleType = ScaleType> =
37273800
{ [key in ScaleType]: { type: key } & ScaleTypeRegistry[key]['options'] }[TScale]
3728-
;
3801+
;
37293802

37303803
// Convenience alias for creating and manipulating scale options in user code
37313804
export type ScaleOptions<TScale extends ScaleType = ScaleType> = DeepPartial<ScaleOptionsByType<TScale>>;

0 commit comments

Comments
 (0)