FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow specifying labels in time scale options by kurkle · Pull Request #6257 · chartjs/Chart.js · GitHub

Allow specifying labels in time scale options - #6257

Merged
simonbrunel merged 5 commits into
chartjs:masterfrom
kurkle:time-labels-from-scale
May 21, 2019
Merged

Allow specifying labels in time scale options#6257
simonbrunel merged 5 commits into
chartjs:masterfrom
kurkle:time-labels-from-scale

Conversation

kurkle commented May 8, 2019

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor

@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?

kurkle commented May 8, 2019

Copy link
Copy Markdown
Member Author

@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 😄

Copy link
Copy Markdown
Contributor

Haha. Sorry

This change looks fine to me, but I'm curious why ticks.source: 'data' wouldn't allow you to accomplish the same thing?

The other thing I wonder is if any other scales would need this same functionality

etimberg commented May 8, 2019

Copy link
Copy Markdown
Member

I wonder if we can extend the same pattern to the category scale and close out #3193 too

etimberg previously approved these changes May 8, 2019

kurkle commented May 9, 2019

Copy link
Copy Markdown
Member Author

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:

getLabels: function() {
var data = this.chart.data;
return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
},

Not quite sure how this would solve #3193?

kurkle commented May 9, 2019

Copy link
Copy Markdown
Member Author

I'm curious why ticks.source: 'data' wouldn't allow you to accomplish the same thing?

Can't find the chart right now , but for example if there is no data for all desired labels.

benmccann previously approved these changes May 10, 2019
Comment thread src/scales/scale.time.js Outdated
kurkle dismissed stale reviews from benmccann and etimberg via 8d21f50 May 11, 2019 12:49
kurkle force-pushed the time-labels-from-scale branch from dc4f183 to 8d21f50 Compare May 11, 2019 12:49
etimberg previously approved these changes May 11, 2019
Comment thread src/core/core.scale.js Outdated
benmccann previously approved these changes May 11, 2019
simonbrunel added this to the Version 2.9 milestone May 12, 2019

nagix commented May 13, 2019

Copy link
Copy Markdown
Contributor

@kurkle You might want to update the time scale document?

etimberg previously approved these changes May 13, 2019
simonbrunel previously approved these changes May 15, 2019

simonbrunel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good! I'm curious why linear scales don't need any change to support labels in the scale options?

kurkle commented May 15, 2019

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

I thought linear scales was using labels to determine the position the x position of each data:

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}
]

kurkle commented May 15, 2019

Copy link
Copy Markdown
Member Author

@simonbrunel It does not work: Pen
'line' chart type defaults to category as x-axis, could that be why you thought linear scales support labels?.

xAxes: [{
type: 'category',
id: 'x-axis-0'

Copy link
Copy Markdown
Member

@kurkle can we also add unit tests?

exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL