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

Xaxis time range does not start and end according to time data #3654

Closed
levekf opened this issue Nov 29, 2016 · 3 comments · Fixed by #4556
Closed

Xaxis time range does not start and end according to time data #3654

levekf opened this issue Nov 29, 2016 · 3 comments · Fixed by #4556

Comments

@levekf
Copy link

levekf commented Nov 29, 2016

Hello all,

I don't know if it is a bug or just a limitation but I have unwanted gap in my line graph.

Expected Behavior

My data must fill the xaxis range all the time.

Current Behavior

In some cases, my data does not fill the xaxis range.

Steps to Reproduce (for bugs)

https://jsfiddle.net/3w5bke8f/2/

Environment

  • Chart.js version: 2.4.0
    It depends on the size of my screen :
    graph
    biggraph
@360disrupt
Copy link

I think it is adding +-1 value of your current measuring unit to the chart. I have currently the work around to round my dates to my scale:

backend

self.currentValue = {x: moment().startOf('minute').toDate(), y:newValue}

frontend chart options

        xAxes: [
          {
            scaleLabel: {labelString:'Time', display: true},
            id: 'x-axis-1',
            type: 'time',
            display: true,
            position: 'bottom',
            time: {
              unit:'minute',
              displayFormats: {
                'minute': 'hh:mm a'
              }
            }

          }
        ]

But I would also expect it to not add this two extra points on the x-axis.

@ghost
Copy link

ghost commented Jan 20, 2017

I am also experiencing this problem. If my charts were static I'd just use a smaller unit, but since they are generated automatically on user input, I can't use this workaround. Is there any way to fix this?

@aaronbc
Copy link

aaronbc commented Feb 9, 2017

I think this is a rounding issue. In your first image your unit scale is in hours so the min and max are on an hour boundary which is outside of your data. Your data starts at "2016-11-29T01:44:04.695Z" but the x-axis min is rounded to "2016-11-29T01:00:00.000Z". It'd be nice to be able to keep the hour unit but round to the nearest minute so that the min/max ticks don't have to start at the beginning of the hour.
When you increase the screen size your unit size changes to minutes and the graph displays properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants