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

Ensure that min/max of TimeScaleOptions can be a string #10137

Merged
merged 1 commit into from Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}
}
}
});