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

[BUG] 2.7.0 hides/clips part of chart #4790

Closed
knod opened this issue Sep 24, 2017 · 10 comments
Closed

[BUG] 2.7.0 hides/clips part of chart #4790

knod opened this issue Sep 24, 2017 · 10 comments
Milestone

Comments

@knod
Copy link

knod commented Sep 24, 2017

Note: I think it's a different problem than #4759. That problem might have to do with total chart padding and this doesn't (I've tested). Here, specifically the top of a <Line> chart is getting clipped/cut off early.

Expected Behavior

Should be able to see items on all sides of the chart, as it was working in v2.6:
v2_6

Current Behavior

Once updating to v2.7, the top of the chart gets cut off:
v2_7

Possible Solution

Edit: So far, the padding I've been able to add is to the outside of the whole chart, not to just an axis itself. I'll keep looking for a way to do that.
I think you can add extra padding to make it work, but is this the indended behavior to start with? Is that the intended solution? Is the chart being created incorrectly (see below)? If so, it's not a bug, but then a note about padding could be added to the docs because it seems non-obvious. To be fair, maybe it's there and I didn't see it.

Steps to Reproduce (for bugs)

A link to the gh-pages live example would be useless because that code is going to change, but here's a pastebin of the current code:

https://pastebin.com/yeBLmXiU

Context

I'm not sure if it's relevant, but it's meant to be a graph showing effects of income on various other factors.

Environment

  • Chart.js version: 2.7
  • Browser name and version: Chrome 61.0.3163.100
  • Link to your project: Again, the project code is not going to stay the same
@knod
Copy link
Author

knod commented Sep 24, 2017

I've managed to create a sort-of solution. The tops of the lines of the chart still get cut off, but I at least get my own whole line to appear (code here: https://pastebin.com/Q7C7gas8):
sort-of-top-of-chart

It's a bit more space than I want above my top line, though.

@swinterberger
Copy link

I am having the same issue on a line chart that is percentage based therefore I often have data points at 100%. Setting max to >100% makes it look quite odd so another fix I have found is to disable the title in the canvas and provide my own title above the canvas.

@minusf
Copy link
Contributor

minusf commented Sep 29, 2017

not a solution but the clipping also goes away if positioning the title to bottom

@pumanitro
Copy link

Someone have solution for that ? Or how long have we wait for fixing it ?

@jcopperfield
Copy link
Contributor

jcopperfield commented Oct 30, 2017

The bug is caused by the introduction of the lineHeight (defaults=1.2) parameter for the title. This causes the title box to have a decimal height (default: 34.4px), which due to not rounding values clips the top line of the graph.

Workaround
Set title lineHeight option to 1.

Proposed fix
fix_#4790_BUG_2-7-0_hides_clips_part_of_chart.patch.txt

@etimberg
Copy link
Member

@jcopperfield I'm surprised that the lineheight is the cause of the problem directly but the comment about decimal heights made me go and look at the code in detail. It looks like we round line values but chart.chartArea is not rounded. Rounding that in the layout system does improve things but it's still not perfect.

@chdsbd
Copy link

chdsbd commented Dec 2, 2017

I think this may be related to #4202

@tenznhok
Copy link

Does this bug fixed now? And how to fix it...

@sunweiyang
Copy link

@tenznhok Looks like the bug still isn't fixed. I still have to use @jcopperfield's lineHeight: 1 workaround to avoid this problem.

@simonbrunel simonbrunel removed this from the Version 2.7.3 milestone Oct 15, 2018
@nagix
Copy link
Contributor

nagix commented Oct 25, 2018

This is not directly caused by the lineHeight of the title box. In fact, hiding a title, changing lineHeightor adding padding may fix the problem, but not always. I believe the root cause is decimal round-off errors when checking if points are in the chart.chartArea. This explains why those changes can sometimes ‘hide’ the problem.

I created a new PR #5790 to fix it.

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

No branches or pull requests