Skip to content

Commit

Permalink
fix(types): Fix the type for options.data.names
Browse files Browse the repository at this point in the history
The code supports setting a name to null to hide it from the legend. But
type declarations were not allowing it.

Close #2677
  • Loading branch information
stof authored and netil committed May 17, 2022
1 parent c9c76e5 commit e64f6bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Chart/api/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ extend(data, {
* @function data鈥ames
* @instance
* @memberof Chart
* @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as
* @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as [data.names](./Options.html#.data%25E2%2580%25A4names).
* @returns {object} Corresponding names according its key value, if specified names values.
* @example
* // Get current names
Expand All @@ -110,7 +110,7 @@ extend(data, {
* data2: "New Name 2"
*});
*/
names: function(names?: Array<{ [key: string]: string; }>): {[key: string]: string} {
names: function(names?: Array<{ [key: string]: string|null; }>): {[key: string]: string|null} {
const $$ = this.internal;

return $$.updateDataAttributes("names", names);
Expand Down
3 changes: 2 additions & 1 deletion src/config/Options/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {

/**
* Set custom data name.
* If a name is set to `null`, the series is omitted from the legend.
* @name data鈥ames
* @memberof Options
* @type {object}
Expand All @@ -58,7 +59,7 @@ export default {
* }
* }
*/
data_names: <{[key: string]: string}> {},
data_names: <{[key: string]: string|null}> {},

/**
* Set custom data class.<br><br>
Expand Down
2 changes: 1 addition & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ export interface Data {
/**
* Set custom data name.
*/
names?: { [key: string]: string };
names?: { [key: string]: string|null };
/**
* Set custom data class.
* If this option is specified, the element g for the data has an additional class that has the prefix billboard-target- (e.g. billboard-target-additional-data1-class).
Expand Down

0 comments on commit e64f6bd

Please sign in to comment.