Skip to content

Commit 3c4a72c

Browse files
committed
feat(plugin.legend): add legend navigation type definitions
1 parent a05c405 commit 3c4a72c

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
}
@@ -2504,6 +2512,71 @@ export interface LegendOptions<TType extends ChartType> {
25042512
*/
25052513
text: string;
25062514
};
2515+
2516+
navigation: {
2517+
/**
2518+
* Show/hide legend navigation.
2519+
*
2520+
* If `auto` is used, the navigation will be shown only if the legend overflows.
2521+
* @default false
2522+
*/
2523+
display: 'auto' | boolean;
2524+
/**
2525+
* Color of the navigation page count label.
2526+
* @see Defaults.color
2527+
*/
2528+
color: Color;
2529+
/**
2530+
* Color of active navigation arrows.
2531+
* @see Defaults.color
2532+
*/
2533+
activeColor: Color;
2534+
/**
2535+
* Color of inactive navigation arrows.
2536+
*
2537+
* Defaults to 40% opacity of the active color.
2538+
*/
2539+
inactiveColor: Color;
2540+
/**
2541+
* Size of navigation arrows.
2542+
* @default 12
2543+
*/
2544+
arrowSize: number;
2545+
/**
2546+
* Maximum number of columns, in vertical legends, for navigation to be activated.
2547+
* @default 1
2548+
*/
2549+
maxCols: number;
2550+
/**
2551+
* Maximum number of rows, in horizontal legends, for navigation to be activated.
2552+
* @default 3
2553+
*/
2554+
maxRows: number;
2555+
/**
2556+
* Navigation buttons padding.
2557+
* @default
2558+
* { x: 10, y: 10, top: 0 }
2559+
*/
2560+
padding: number | ChartArea;
2561+
/**
2562+
* Alignment of navigation buttons.
2563+
* @default 'start'
2564+
*/
2565+
align: 'start' | 'center' | 'end';
2566+
/**
2567+
* Align legends horizontally and vertically.
2568+
*
2569+
* Fixes the width/height of all legends according to the widest/tallest legend, to form a grid and keep legends aligned when changing pages.
2570+
* @default true
2571+
*/
2572+
grid: boolean | { x?: boolean; y?: boolean; },
2573+
/**
2574+
* Font style of the navigation page count label.
2575+
* @default
2576+
* { weight: 'bold', size: 14 }
2577+
*/
2578+
font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableChartContext>;
2579+
}
25072580
}
25082581

25092582
export declare const SubTitle: Plugin;
@@ -3728,7 +3801,7 @@ export type ChartType = keyof ChartTypeRegistry;
37283801

37293802
export type ScaleOptionsByType<TScale extends ScaleType = ScaleType> =
37303803
{ [key in ScaleType]: { type: key } & ScaleTypeRegistry[key]['options'] }[TScale]
3731-
;
3804+
;
37323805

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

0 commit comments

Comments
 (0)