Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LegendOptions is not update in Typescript (missing maxHeight and maxWidth like so) #9223

Closed
ace-han opened this issue Jun 3, 2021 · 0 comments · Fixed by #9226
Closed

LegendOptions is not update in Typescript (missing maxHeight and maxWidth like so) #9223

ace-han opened this issue Jun 3, 2021 · 0 comments · Fixed by #9226

Comments

@ace-han
Copy link

ace-han commented Jun 3, 2021

Expected Behavior

LegendOptions in the doc has maxHeight and maxWidth

# Legend
The chart legend displays data about the datasets that are appearing on the chart.
## Configuration options
Namespace: `options.plugins.legend`, the global options for the chart legend is defined in `Chart.defaults.plugins.legend`.
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `display` | `boolean` | `true` | Is the legend shown?
| `position` | `string` | `'top'` | Position of the legend. [more...](#position)
| `align` | `string` | `'center'` | Alignment of the legend. [more...](#align)
| `maxHeight` | `number` | | Maximum height of the legend, in pixels
| `maxWidth` | `number` | | Maximum width of the legend, in pixels
| `fullSize` | `boolean` | `true` | Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use.
| `onClick` | `function` | | A callback that is called when a click event is registered on a label item. Arguments: `[event, legendItem, legend]`.
| `onHover` | `function` | | A callback that is called when a 'mousemove' event is registered on top of a label item. Arguments: `[event, legendItem, legend]`.
| `onLeave` | `function` | | A callback that is called when a 'mousemove' event is registered outside of a previously hovered label item. Arguments: `[event, legendItem, legend]`.
| `reverse` | `boolean` | `false` | Legend will show datasets in reverse order.
| `labels` | `object` | | See the [Legend Label Configuration](#legend-label-configuration) section below.
| `rtl` | `boolean` | | `true` for rendering the legends from right to left.
| `textDirection` | `string` | canvas' default | This will force the text direction `'rtl'` or `'ltr'` on the canvas for rendering the legend, regardless of the css specified on the canvas
| `title` | `object` | | See the [Legend Title Configuration](#legend-title-configuration) section below.
## Position

Current Behavior

LegendOptions in index.esm.d.ts has no maxHeight and maxWidth, which causes eslint errors when developing in TypeScript

Chart.js/types/index.esm.d.ts

Lines 2106 to 2227 in 26f8d7b

export interface LegendOptions {
/**
* Is the legend shown?
* @default true
*/
display: boolean;
/**
* Position of the legend.
* @default 'top'
*/
position: LayoutPosition;
/**
* Alignment of the legend.
* @default 'center'
*/
align: 'start' | 'center' | 'end';
/**
* Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use.
* @default true
*/
fullSize: boolean;
/**
* Legend will show datasets in reverse order.
* @default false
*/
reverse: boolean;
/**
* A callback that is called when a click event is registered on a label item.
*/
onClick(this: LegendElement, e: ChartEvent, legendItem: LegendItem, legend: LegendElement): void;
/**
* A callback that is called when a 'mousemove' event is registered on top of a label item
*/
onHover(this: LegendElement, e: ChartEvent, legendItem: LegendItem, legend: LegendElement): void;
/**
* A callback that is called when a 'mousemove' event is registered outside of a previously hovered label item.
*/
onLeave(this: LegendElement, e: ChartEvent, legendItem: LegendItem, legend: LegendElement): void;
labels: {
/**
* Width of colored box.
* @default 40
*/
boxWidth: number;
/**
* Height of the coloured box.
* @default fontSize
*/
boxHeight: number;
/**
* Color of label
* @see Defaults.color
*/
color: Color;
/**
* Font of label
* @see Defaults.font
*/
font: FontSpec;
/**
* Padding between rows of colored boxes.
* @default 10
*/
padding: number;
/**
* Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See Legend Item for details.
*/
generateLabels(chart: Chart): LegendItem[];
/**
* Filters legend items out of the legend. Receives 2 parameters, a Legend Item and the chart data
*/
filter(item: LegendItem, data: ChartData): boolean;
/**
* Sorts the legend items
*/
sort(a: LegendItem, b: LegendItem, data: ChartData): number;
/**
* Override point style for the legend. Only applies if usePointStyle is true
*/
pointStyle: PointStyle;
/**
* Text alignment
*/
textAlign?: TextAlign;
/**
* Label style will match corresponding point style (size is based on the minimum value between boxWidth and font.size).
* @default false
*/
usePointStyle: boolean;
};
title: {
/**
* Is the legend title displayed.
* @default false
*/
display: boolean;
/**
* Color of title
* @see Defaults.color
*/
color: Color;
/**
* see Fonts
*/
font: FontSpec;
position: 'center' | 'start' | 'end';
padding?: number | ChartArea;
/**
* The string title.
*/
text: string;
};
}

Possible Solution

Add those missing props to index.esm.d.ts.

Steps to Reproduce

Please refer to the code snippets above.

Context

Please refer to the code snippets above.

Environment

  • Chart.js version: 3.3.2
  • Browser name and version: N/A
  • Link to your project: N/A
@etimberg etimberg added this to the Version 3.4.0 milestone Jun 3, 2021
@etimberg etimberg linked a pull request Jun 3, 2021 that will close this issue
@etimberg etimberg closed this as completed Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants