-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Allow specifying labels in time scale options #6257
Conversation
@kurkle this only updates the docs, but from the PR description I would expect code to have changed as well. Did you accidentally leave some changes off of the PR? |
Its so small change, you missed it. Had any ☕️ yet 😄 |
Haha. Sorry This change looks fine to me, but I'm curious why The other thing I wonder is if any other scales would need this same functionality |
I wonder if we can extend the same pattern to the category scale and close out #3193 too |
category scale already supports this, and additionally xLabes/yLabels: Chart.js/src/scales/scale.category.js Lines 15 to 18 in 2a96d83
Not quite sure how this would solve #3193? |
Can't find the chart right now , but for example if there is no data for all desired labels. |
dc4f183
to
8d21f50
Compare
@kurkle You might want to update the time scale document? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'm curious why linear scales don't need any change to support labels in the scale options?
linear scales just don't support labels in any way (yet). I'd leave that for another PR. |
I thought linear scales was using labels to determine the position the data: {
labels: [0, 2, 6, 8],
datasets: [{
data: [1, 4, 8, 2]
}]
}
// e.q.
data: [
{x: 0, y: 1},
{x: 2, y: 4},
{x: 6, y: 8},
{x: 8, y: 2}
] |
@simonbrunel It does not work: Pen Chart.js/src/controllers/controller.line.js Lines 21 to 23 in e5c68e2
|
@kurkle can we also add unit tests? |
Currently time scale only reads labels from
data.labels
.If both axes are time scales, this is not sufficient.
So this PR allows specifying labels under scale options also.