You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When providing data for the time scale, Chart.js uses timestamps defined as milliseconds since the epoch (midnight January 1, 1970, UTC) internally. However, Chart.js also supports all of the formats that your chosen date adapter accepts.
Expected behavior
I expected TypeScript to accept
options: { scales: { x: { type: "time", min: "2021-01-01", max: "2021-12-01" } } }
.Current behavior
Compiler errors:
Type
'"time"'
is not assignable to type'"timeseries" | undefined'
.Type
'string'
is not assignable to type'number | undefined'
.Reproducible sample
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUKJFuZTPQLToAJujAwAplD7DxfPADsGLVmwA2Y+GRgAPOAF44giGQCuIMXJhUA5uoCiasxYBCATwCSggBQAiEC7SYMN4AlHDodHAAEgAqALIAMsjocgBu4fZijjBKavB+AVj6cmIA7ig8nppaADSIbHBwMC5gYgBccN4qwMXe1fUG6DDo7Qj9DdLh6nTtANpjDXWsC8twKugARmIq7d4ACsBivfPLE7PHK0haOwBMAAzXAIx8t08vvXAu7QDMOH1LK8tLjd7q9rs8Hu9PnAHr9zoC4FcOndHs8vuDIe0ACyw-4AhpApEg56Y9G1KEw7B-PELAneZGvACspI+7QZOOp+IRwJRtwAbMyoQBOdkc2n054AdgF7WuIupYqJtwAHNK4Ly5XiFTzBaq2ZS4TSuYSUQ9bqqfvrcZqjXSiQ9XhCyayNQCtU8HmC3k64EqcAaALpUvHraCCCTICAqaA7ADEt3jCaOVuW63QZAA1lZCMY5III1GoLH4wAxYvx7znbDzf39S0NCCiYAQBQjeZ0MjoNTTRYAxGjZMLJotHYwUCHIMAkDdbkO0kGkDoRG2k2eiGVicLKH96lDtodLrFTBJ6lTuTtW4b5YLxGmyvzKv-B-YYJKIA
Optional extra steps/info to reproduce
Here's a codepen demonstrating that this works at runtime: https://codepen.io/StephanTLavavej/pen/RwjooGY
The Time Cartesian Axis > Date Formats documentation explains how string values are adapted:
And then it lists
min
andmax
asnumber | string
.Possible solution
No response
Context
I'm converting the microsoft/STL Status Chart, powered by Chart.js, to use TypeScript. 😸
chart.js version
v3.7.0
Browser name and version
Chrome 98.0.4758.81
Link to your project
No response
The text was updated successfully, but these errors were encountered: