Skip to content

Commit

Permalink
Ensure that min/max of TimeScaleOptions can be a string
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Feb 6, 2022
1 parent aebbb5a commit 38144c3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 2 additions & 5 deletions types/index.esm.d.ts
Expand Up @@ -3088,7 +3088,7 @@ export interface CartesianScaleOptions extends CoreScaleOptions {
};
}

export type CategoryScaleOptions = CartesianScaleOptions & {
export type CategoryScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> & {
min: string | number;
max: string | number;
labels: string[] | string[][];
Expand All @@ -3107,7 +3107,6 @@ export type LinearScaleOptions = CartesianScaleOptions & {
* @default true
*/
beginAtZero: boolean;

/**
* Adjustment used when calculating the maximum data value.
*/
Expand Down Expand Up @@ -3151,7 +3150,6 @@ export const LinearScale: ChartComponent & {
};

export type LogarithmicScaleOptions = CartesianScaleOptions & {

/**
* Adjustment used when calculating the maximum data value.
*/
Expand All @@ -3175,10 +3173,9 @@ export const LogarithmicScale: ChartComponent & {
new <O extends LogarithmicScaleOptions = LogarithmicScaleOptions>(cfg: AnyObject): LogarithmicScale<O>;
};

export type TimeScaleOptions = CartesianScaleOptions & {
export type TimeScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> & {
min: string | number;
max: string | number;

suggestedMin: string | number;
suggestedMax: string | number;
/**
Expand Down
30 changes: 30 additions & 0 deletions types/tests/scales/time_string_max.ts
@@ -0,0 +1,30 @@
import { Chart } from '../../index.esm';

const chart = new Chart('id', {
type: 'line',
data: {
datasets: [
{
label: 'Pie',
data: [
],
borderColor: '#000000',
backgroundColor: '#00FF00'
}
]
},
options: {
scales: {
x: {
type: 'time',
min: '2021-01-01',
max: '2021-12-01'
},
y: {
type: 'linear',
min: 0,
max: 10
}
}
}
});

0 comments on commit 38144c3

Please sign in to comment.