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

Lines not using crispEdges show up fuzzy on non-retina screens #656

Closed
kmiyashiro opened this issue Mar 22, 2020 · 7 comments
Closed

Lines not using crispEdges show up fuzzy on non-retina screens #656

kmiyashiro opened this issue Mar 22, 2020 · 7 comments

Comments

@kmiyashiro
Copy link
Contributor

I'm using a windows machine to develop and I noticed that the lines in vx were fuzzy. I found this explanation, which seems to be correct.

Expand images to see sharpness of bottom axis:

Current

current

With shape-rendering="crispEdges" on line or parent g

crisp-edges

Would you be open to adding shape-rendering="crispEdges" for lines? The only downside to using crispEdges is that it produces sharp edges even for rounded objects. The Line and Axis components currently don't make rounded shapes, so I think adding it to those will be safe at least.

@williaster
Copy link
Collaborator

This seems like a reasonable change to me, happy to review a PR!

@ArvinH
Copy link
Contributor

ArvinH commented Oct 4, 2020

Hi, may I work on this one? trying to get to know more about this tool :)

@kmiyashiro
Copy link
Contributor Author

kmiyashiro commented Oct 4, 2020

Hey @ArvinH (and @williaster) I actually just worked on this last night, you can review the PR here: #840

@kmiyashiro
Copy link
Contributor Author

Fixed in #840

@jbanulso
Copy link

jbanulso commented Oct 22, 2020

Hi, this change introduced in #840 is causing dotted lines not to be displayed. I achieve the dotted line effect with a rounded line cap (stroke-linecap: round), which is the CSS property that causes the problem. An example of how I'm implementing the lines:

import { Line as VxLine } from '@visx/shape';

const Line = styled(VxLine)`
  stroke: black;
  stroke-linecap: round;
  stroke-dasharray: 0, 2;
  stroke-dashoffset: 1;
`;

return <Line from={{ x: x1, y: y1 }} to={{ x: x2, y: y2 }} />

It seems like it is a browser rendering issue though - I've tested both in Chrome and Firefox and the lines are displayed when increasing/decreasing the zoom level, which leads me to think that there is some sort of bug on the implementation of the sharp-rendering attribute.

I can make the lines be displayed with stroke-linecap: square, but then the dotted effect is not the desired one. Would you consider reverting (or reworking) this change, as it introduces an unwanted behaviour?

EDIT: manually manipulating the decimals in x and y to "fit" the half-pixel position is not an option, since the coordinates (in my case) are dynamic.

@hshoff
Copy link
Member

hshoff commented Oct 22, 2020

Hi @jbanulso, for now the work around would be to set shape-rendering: auto; on the line. This resets shape-rendering to the default value by overriding the previous value.

<Line
  from={{ x: x1, y: y1 }}
  to={{ x: x2, y: y2 }}
+ shapeRendering="auto"
/>

@jbanulso
Copy link

Hi @hshoff, that will do it, thank you for the quick answer. And thank you for the great work with this library, it's great to see the progress over the last years 🚀

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

5 participants