]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Ensure that min/max of TimeScaleOptions can be a string (#10137)
authorEvert Timberg <evert.timberg@gmail.com>
Sun, 6 Feb 2022 18:53:03 +0000 (13:53 -0500)
committerGitHub <noreply@github.com>
Sun, 6 Feb 2022 18:53:03 +0000 (13:53 -0500)
types/index.esm.d.ts
types/tests/scales/time_string_max.ts [new file with mode: 0644]

index 10ac49f4ef56ccb14618f752c6f74277396dae7c..14a26d596677cf88b78f245d8c514e2d28afacb0 100644 (file)
@@ -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[][];
@@ -3107,7 +3107,6 @@ export type LinearScaleOptions = CartesianScaleOptions & {
    * @default true
    */
   beginAtZero: boolean;
-
   /**
    * Adjustment used when calculating the maximum data value.
    */
@@ -3151,7 +3150,6 @@ export const LinearScale: ChartComponent & {
 };
 
 export type LogarithmicScaleOptions = CartesianScaleOptions & {
-
   /**
    * Adjustment used when calculating the maximum data value.
    */
@@ -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;
   /**
diff --git a/types/tests/scales/time_string_max.ts b/types/tests/scales/time_string_max.ts
new file mode 100644 (file)
index 0000000..530b1c5
--- /dev/null
@@ -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
+      }
+    }
+  }
+});