chartjs / chartjs/Chart.js

`getLabelForValue` returns the wrong format in time scale

Open
#12,128 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

Calling `timeScale.getLabelForValue(value)` should return a value formatted with the format in `options.displayFormats` for the current time unit.

### Current behavior

Calling `timeScale.getLabelForValue(value)` returns a value in the `datetime` format, instead of the format defined in `options.displayFormats` for the current time unit.

### Reproducible sample

https://codepen.io/Adrien-Minne/pen/jEWrqRK

### Optional extra steps/info to reproduce

_No response_

### Possible solution

Probably a simple change in [time scale](
https://github.com/chartjs/Chart.js/blob/e27526986d9951ca2fc9f8abf4108dff0db061a8/src/scales/scale.time.js#L502) is needed

### Context

_No response_

### chart.js version

v4.5.0

### Browser name and version

Google chrome Version 140.0.7339.185

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.