Skip to content

Commit

Permalink
chore(types): Correct .data() APIs types
Browse files Browse the repository at this point in the history
Fix incorrect data return types for .data() APIs.

Fix #1248
  • Loading branch information
netil authored Feb 21, 2020
1 parent 395a604 commit 3f9bfa5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions types/chart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* billboard.js project is licensed under the MIT license
*/
import { Data } from "./options";
import { ArrayOrString, d3Selection, DataArray, PrimitiveArray, TargetIds } from "./types";
import { ArrayOrString, d3Selection, DataArray, DataItem, PrimitiveArray, TargetIds } from "./types";

export interface Chart {
$: {
Expand Down Expand Up @@ -118,19 +118,19 @@ export interface Chart {
* Get data loaded in the chart.
* @param targetIds If this argument is given, this API returns the specified target data. If this argument is not given, all of data will be returned.
*/
(targetIds?: ArrayOrString): Data;
(targetIds?: ArrayOrString): DataArray;

/**
* Get data shown in the chart.
* @param targetIds If this argument is given, this API filters the data with specified target ids. If this argument is not given, all shown data will be returned.
*/
shown(targetIds?: ArrayOrString): Data;
shown(targetIds?: ArrayOrString): DataArray;

/**
* Get values of the data loaded in the chart.
* @param targetIds This API returns the values of specified target. If this argument is not given, null will be retruned.
*/
values(targetIds?: ArrayOrString): any[];
values(targetIds?: ArrayOrString): number[];

/**
* Get and set names of the data loaded in the chart.
Expand All @@ -142,9 +142,7 @@ export interface Chart {
* Get and set colors of the data loaded in the chart.
* @param colors If this argument is given, the colors of data will be updated. If not given, the current colors will be returned. The format of this argument is the same as data.colors.
*/
colors(colors?: {
[key: string]: string;
}): { [key: string]: string };
colors(colors?: { [key: string]: string; }): { [key: string]: string };

/**
* Get and set axes of the data loaded in the chart.
Expand All @@ -155,12 +153,12 @@ export interface Chart {
/**
* Get the minimum data value bound to the chart.
*/
min(): [{ x: number, value: number, id: string, index: number }];
min(): DataItem[];

/**
* Get the maximum data value bound to the chart.
*/
max(): [{ x: number, value: number, id: string, index: number }];
max(): DataItem[];
};

axis: {
Expand Down

0 comments on commit 3f9bfa5

Please sign in to comment.