question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offset ignored when min and max axis values are set

See original GitHub issue

Bar charts with a date x-axis does ignores offset: true when time.min and time.max are set.

Expected Behavior

Offset should work even if time.min and time.max are set.

Current Behavior

If I let Chart.js auto scale the graph, it works just fine. However, my project involves using a date range picker which sets time.min and time.max to restrict the range of the graph, which causes half of the first and last bars to be cut off as there is no offset.

Auto scaling screen shot 2018-07-06 at 12 29 14 pm

With time.min and time.max screen shot 2018-07-06 at 12 29 31 pm

Environment

  • Chart.js version: 2.7.2
  • Browser name and version: Chrome 67.0.3396.99

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ikbenpindacommented, Jan 23, 2019

@simonbrunel https://codepen.io/anon/pen/EGBEBq Does this work as a repro? Uncommenting time.min/max on lines 31/32 should reproduce the issue.

I’m having the same issue. Elsewhere this was fixed by removing the timezone suffix, but for me these are simple ‘YYYY-MM-DD’ formats, so that doesn’t work for me.(edit: this refers to a slightly different issue related to offset)

Update: One workaround of sorts is to set the time to 12:00(pm), e.g. min: '2018-05-06 12:00:00'. This will align the bars similar to how offset usually works. However, hovering at the sides of the Y-axes shows the partial bars are still there, just not visible. ticks.mirror does not change this either.

It looks like the X-axis is overlapped by the Y-axis? I don’t know. I’ve updated my repro.

0reactions
nwkeeleycommented, Dec 26, 2018

My implementation is a bit complex but let me see what I can put together to demonstrate the issue - might not be until tomorrow

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set max and min value for Y axis - chart.js
As you can see max value (130) and min value (60) for Y axis are chosen automatically , I want max value =...
Read more >
yAxis.offset | highcharts API Reference
When the axis' min option is set or a max extreme is set using axis.setExtremes() , the maxPadding will be ignored. Also the...
Read more >
Axis | Vega-Lite
This determines a maximum offset value for axis titles. Default value: undefined . The minimum extent in pixels that axis ticks and labels...
Read more >
Controlling Axis Features - SAS Help Center
The OFFSETMIN= and OFFSETMAX= axis options can be used to reserve an area at the minimum end of an axis, the maximum end,...
Read more >
Axes | Chart.js
Each dataset is mapped to a scale for each axis (x, y or r) it requires. ... the min and max settings set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found