Skip to content

Alignment of horizontal grid lines and tick text is off #1434

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

Closed
Kilian opened this issue Mar 2, 2017 · 9 comments
Closed

Alignment of horizontal grid lines and tick text is off #1434

Kilian opened this issue Mar 2, 2017 · 9 comments
Labels
bug something broken

Comments

@Kilian
Copy link

Kilian commented Mar 2, 2017

Visually, the tick text and the horizontal gridlines are not vertically centered, which makes the axis look slightly-off. This is already noticeable in the line chart demos:
selection_012

If you zoom in on this image, you can see it more clearly:

selection_013

What I would expect is vertical alignment of the tick text (regardless of font-size) with the grid lines. In the above example, the ticks would need to be moved 2px up to get the following alignment (left: new position, right: overlayed on current position):

selection_014 selection_015

@etpinard
Copy link
Contributor

etpinard commented Mar 2, 2017

I suspect that off-center offset is on purpose. Though it would be nice to add an axis attribute (e.g. yaxis.ticktextoffset) to make this configurable.

@alexcjohnson
Copy link
Collaborator

I don't think it's on purpose; I know that for log axes we fiddle with the positioning of individual labels (particularly to keep the small 9 from interfering with the bigger 10^n) but I suspect for linear it's just us making a poor approximation to avoid having to calculate bounding boxes individually for each tick label. I'd be happy to consider this a bug.

That said there are use cases for offsetting the labels - but perhaps this would be best handled as an anchor (top/middle/bottom, or left/center/right for x axes) rather than a pixel offset?

Like this Vox chart:
screen_shot_2015-01-14_at_11 34 49_am 0

@alexcjohnson
Copy link
Collaborator

Closed by #1854

@LazerJesus
Copy link

screen shot 2017-09-08 at 19 55 05

i have the same issue.

@alexcjohnson
Copy link
Collaborator

@FinnFrotscher this issue was about alignment of tick labels with their own gridlines - which to my eye looks good in the image you posted... perhaps you're concerned about the ranges of your two y axes being mismatched? Like #1962 perhaps? Can you clarify what you're interested in?

@LazerJesus
Copy link

LazerJesus commented Sep 8, 2017

I am refering to the horizontal alignment of the barchart and linechart.
the 0-line of the line is higher then the 0-line of the bars.

screen shot 2017-09-08 at 20 19 06

@etpinard
Copy link
Contributor

etpinard commented Sep 8, 2017

@FinnFrotscher see #1775 (comment) for explanations.

@alexcjohnson
Copy link
Collaborator

I am refering to the horizontal alignment of the barchart and linechart. the 0-line of the line is higher then the 0-line of the bars.

That's a separate issue. You have two autoranged axes, one with bars (so it doesn't pad the axis past zero unless you have negative bars) and one with a line (so it always pads the axis vertically). If you want the right-side axis to behave like the left, you can do something like yaxis2: {rangemode: 'tozero'} which forces the axis autorange to reach down to zero, but also won't go past it unless there's actually negative data.

@LazerJesus
Copy link

thank you, my issue is resolved. sorry for posting it in the wrong issue.

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

No branches or pull requests

4 participants