Skip to content
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

Option to use time scales #48

Closed
kepano opened this issue Mar 19, 2022 · 4 comments
Closed

Option to use time scales #48

kepano opened this issue Mar 19, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@kepano
Copy link

kepano commented Mar 19, 2022

Describe the feature

Allow axes to use the time scale to set relative distance between points in time

Does this fix a problem? If so, specify.

Currently this is possible using dataviewjs however the input is less user-friendly, and doesn't support new capabilities like table based charts introduced in 3.3.0

Did you consider other alternatives?

The following examples show the same input data with very different output visualization. The second one is much more useful, but less user friendly to create and keep up to date with new data.

Using table charts

  ```chart  
  type: line
  id: chart
  layout: colums
  beginAtZero: true```
  
  | Date       | Number |
  | ---------- | ------ |
  | 2022-02-21 | 1052   |
  | 2022-02-13 | 1020   |
  | 2022-02-05 | 945    |
  | 2022-01-20 | 847    |
  | 2022-01-11 | 801    |
  ^chart

Screen Shot 2022-03-19 at 8 28 13 AM

With dataviewjs

dataviewjs

const chartData = {
    type: 'line',
    data: {
        labels: ['2022-01-11','2022-01-20','2022-02-05','2022-02-13','2022-02-21'],
        datasets: [{
            label: 'Number',
            data: [801,847,945,1020,1052]
        }]
    },
    options: {
        scales: {
            x: {
				type: 'time',
                time: {
                    unit: 'day'
                }
            }
        }
    }
}

window.renderChart(chartData, this.container);

Screen Shot 2022-03-19 at 8 28 10 AM

@kepano kepano added the enhancement New feature or request label Mar 19, 2022
@phibr0 phibr0 closed this as completed in a30e5b5 Mar 20, 2022
@phibr0
Copy link
Owner

phibr0 commented Mar 20, 2022

@kepano
Copy link
Author

kepano commented Mar 20, 2022

Amazing! Works perfectly.

@claremacrae
Copy link

Amazing! Works perfectly.

Please could you say how exactly you used it? I've read that page and do not understand where to put the modifier...

@claremacrae
Copy link

Amazing! Works perfectly.

Please could you say how exactly you used it? I've read that page and do not understand where to put the modifier...

I figured it out... The answer for me was to insert:

time: "day"

Like this:

```chart
type: line
labels: [2022-06-15, 2022-06-22, 2022-06-23]
time: "day"
series:
  - title: Stuff
    data: [75818, 80000, 90000]
tension: 0.2
width: 80%
labelColors: false
fill: false
beginAtZero: false
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants