Visual artifacts when clipping gaps
See original GitHub issueHello! Thanks for the great library!
While making a line plot, I’ve noticed visual artifacts between two line segments when separated by a null/missing value. These issues become more noticeable when there is more data in the figure.
I attached an example figure and jsfiddle example. In the example I have alternating horizontal line segments at +1 and -1, separated by null
. There should be no line segments connecting the +1 and -1 segments. My guess is that it is due to some rounding issue when it does the clipping?
https://jsfiddle.net/murphycj/s2c5hbkt/13/
Do you think there is an easy fix for this? Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Illustrator - Clipping mask has untidy edges
I am seeing artifacts of the white diagonal (with red outline) appearing outside the shield outline. Zooming in does show that the clipping ......
Read more >Weird artifacts on Safari when using -webkit-background-clip
My fix was to use a png for the background, instead of a jpg, with transparent pixels around the edge of the image....
Read more >Graphics | Near Clipping Planes of 0.01 cause visual artifacts ...
Hi, Near Clipping Planes of 0.01 cause visual artifacts if the cam is placed in any light range. > 0.01 did not. It's...
Read more >Render Artifacts Every Time, Same Spot - Blackmagic Forum
I have found a solution to this problem. Put a seconds gap between, image or video in the timeline. The artifact was created...
Read more >Clipping | Unreal Engine 4.27 Documentation
An overview of using the Clipping properties within the UMG UI Designer. ... Elements in different clipping spaces cannot be batched together, ...
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
@murphycj thanks, i’ve added a demo with your data here for further discussion/iteration:
https://leeoniya.github.io/uPlot/demos/sparse.html
a few things stand out to me:
10
spike in1,1,1,null,10,null,1,1,1
. the orange trendline in the points demo tries to address this by force-rendering single points surrounded bynull
values that would necessarily get clipped by adjacent gaps - https://leeoniya.github.io/uPlot/demos/points.htmlyou can see pretty significant differences in the highlighted region if the attached image.
i’m interested to see your modified
moveTo()
pathBuilder that does not suffer from this phenomenon at any zoom level. i did a few simple moveTo() prototypes and in each case spikes would randomly appear/disappear at different chart sizes, zoom levels and scale ranges. can you post your modified pathBuilder code (or make a PR against thesparse.html
demo for easier dissecting)?when there are so many gaps, i think the better strategy would be to modify the gaps array in a way that is aware of the scale range, so if you have 16k points in view, it removes gaps that are < 2px wide, which effectively makes it act as a conditional
spanGaps
. another demo that does custom gap insertion is the bottom chart here: https://leeoniya.github.io/uPlot/demos/missing-data.htmlfirst, thanks for the clear and terse bug report with reduced repro code 👍 ❤️
that’s a pretty good guess 😃. it’s because the linear pathbuilder’s gap construction does not expand the gap width to include the line width in order to avoid accidentally also clipping out additional data at the gap edges.
for your type of dataset it may be more appropriate to switch to the stepped pathbuilder (via
series.paths
) which does account for line width during gap building by default (via{ascDec: false}
[1])https://jsfiddle.net/pk4mtyza/
alternatively, you can mutate the gaps array to expand each gap manually by a pixel amount if you consider this to be safe for your dataset:
https://jsfiddle.net/pk4mtyza/2/
[1] https://github.com/leeoniya/uPlot/blob/5680d8b81aefc8cc7035eb51ff99b3d1dfc733f6/dist/uPlot.d.ts#L640-L641