Skip to content

Commit

Permalink
fix(types): Fix the signature of the tick format callback for timeseries
Browse files Browse the repository at this point in the history
- Remove wrong number type from axis.x.tick.format
- Specify Date type for axis.[y|y2].tick.format

Close #2769
  • Loading branch information
stof authored and netil committed Jul 7, 2022
1 parent c8e1a92 commit fb246bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/axis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export interface XTickConfiguration {
* A function to format tick value. Format string is also available for timeseries data.
*/
format?: string
| ((this: Chart, x: number | Date) => string | number)
| ((this: Chart, x: Date) => string | number)
| ((this: Chart, index: number, categoryName: string) => string);

/**
Expand Down Expand Up @@ -337,7 +337,7 @@ export interface YTickConfiguration {
* Set formatter for y axis tick text.
* This option accepts d3.format object as well as a function you define.
*/
format?(this: Chart, x: number): string;
format?(this: Chart, x: number | Date): string | number;

This comment has been minimized.

Copy link
@stof

stof Jul 7, 2022

Author Contributor

This forces to specify a callback that supports both number and dates. This seems unexpected to me. Shouldn't it be a union type between 2 callback signatures instead if some configurations can have Date as y values ?


/**
* Setting for culling ticks.
Expand Down

0 comments on commit fb246bc

Please sign in to comment.