tick lines sometimes dissapear
See original GitHub issuehi, I am using tick lines to display a grid in the background of my simple vertical bars chart, but sometimes some of the vertical lines are not rendered. Inspecting the SVG, I can see the markup for the invisible lines there, and they look the same that the visible ones. Changing the value of the g transform x attribute (usually rounding to 1 decimal place) makes the hidden line visible. this happens both in firefox and chrome.
this is the markup for a good (visible) tick line:
<g class="tick" style="opacity: 1;" transform="translate(457.90990990990997,0)">
<line y2="-485" x2="0"></line>
<text dy=".71em" y="3" x="0" style="text-anchor: middle;">14</text></g>
this is the markup for an invisible line:
<g class="tick" style="opacity: 1;" transform="translate(527.8198198198198,0)">
<line y2="-485" x2="0"></line>
<text dy=".71em" y="3" x="0" style="text-anchor: middle;">16</text></g>
if I change “translate(527.8198198198198,0)” to “translate(527,0)” the line appears… is this a issue with the browser svg engine or something I can fix by changing some setup on my d3 chart?
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to restore the missing subtick lines and missing tick labels?
Unfortunately, sometimes the subtick lines and tick labels near the edges are missing even though I have precisely specified the paddings to ...
Read more >Excel - The very basics! Grey grid lines disappearing..
Could someone please let me know why they grey grid lines disappear when you edit the contents? One or two is fine, but...
Read more >Grid lines disappearing randomly while zooming in Illustrator ...
When zooming in an out the grid lines disappear with no identifiable logic. Sometimes the grid completly disappears, sometime only vertical or horizontal ......
Read more >How to keep ticks on xaxis without the xlabels disappearing ...
When I write the command for xticks, the xlabels disappear. Please help. Also I need the xaxis label to be formatted in two...
Read more >Axis tick mark disappeared when zoom to some point
The tick mark issue is actually a different (but similar) bug that has been around for a while. This is caused when the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is not something directly fixable in D3, since it is largely agnostic about the DOM that you create.
My guess is that you are using shape-rendering: crispEdges and a stroke-width that is less than 1px (or equivalently, have some sort of viewBox or transform that is causing the stroke to be less than 1px wide), and the browser is deciding to not show the lines at all rather than implicitly widening the stroke to be 1px. Unfortunately, many browsers don’t do a very good job of implementing crispEdges; Safari, for example, occasionally rounds a 1px line up to 2px (or even 3px!).
You can control the behavior more precisely by turning off crispEdges and instead positioning the ticks exactly on half-pixel boundaries, say by using scale.rangeRound and then offsetting the tick position by a half-pixel. However, note that in Firefox the SVG element itself can be positioned on a sub-pixel boundary, which then requires further offsetting to get the tick back on a whole-pixel. :\
Hi @mbostock, great thanks man for the explanation. You saved my time.