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

tickSizeOuter(0) not yielding straight line #32

Closed
curran opened this issue Mar 30, 2017 · 2 comments
Closed

tickSizeOuter(0) not yielding straight line #32

curran opened this issue Mar 30, 2017 · 2 comments

Comments

@curran
Copy link
Contributor

curran commented Mar 30, 2017

The README states

An outer tick size of 0 suppresses the square ends of the domain path, instead producing a straight line.

However, practically this is not exactly true. When setting a stroke on the .domain path, one can observe that the endpoints are not quite right, as in this example:

image

In this case, after setting tickSizeOuter(0), I would expect that the domain path ending would end up as a square end.

The path for the X axis domain is M0.5,0V0.5H867.5V0. When changing it manually to M0.5,0V0.5H867.5, the resulting rendered path is a straight line:

image

The solution would be to exclude the V0 part of the path when tickSizeOuter === 0 somewhere around axis.js#L92. The following bit of implementation would need to change:

    path
        .attr("d", orient === left || orient == right
            ? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + "H" + k * tickSizeOuter
            : "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + "V" + k * tickSizeOuter);

The change might look something like this:

    path
        .attr("d", orient === left || orient == right
            ? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + (tickSizeOuter ? "H" + k * tickSizeOuter : "")
            : "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + (tickSizeOuter? "V" + k * tickSizeOuter : ""));

Is this change something that would be desirable?

@jfouquat
Copy link

There is this issue on each axis ends.

For information : http://jsfiddle.net/7w2phbr6/87/
image

@curran : I thought to the same kind of fix (related to your previous pull request) 👍. Any new idea ?

axis.style('stroke-linecap', 'square');
// http://jsfiddle.net/7w2phbr6/91/
// Not perfect - Use CSS

image

axis.style('stroke-dasharray', '0 0.5 ' + range-size + ' 0.5')
// http://jsfiddle.net/7w2phbr6/108/
// Not perfect - Use CSS

image

No other idea :/

@mbostock
Copy link
Member

Fixed in 1.0.10.

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

No branches or pull requests

3 participants