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

Errorbar: not aligned perfectly - sometimes has 1 pixel offset #5334

Closed
KacperMadej opened this issue May 23, 2016 · 19 comments · Fixed by #20941
Closed

Errorbar: not aligned perfectly - sometimes has 1 pixel offset #5334

KacperMadej opened this issue May 23, 2016 · 19 comments · Fixed by #20941

Comments

@KacperMadej
Copy link

KacperMadej commented May 23, 2016

Behaviour

Miss-aligned lines e.g. are not placed in center of linkedTo scatter markers.

Live demo with steps to reproduce

http://jsfiddle.net/zkenuwu2/
Plot lines added for reference, but also very much visible in compare to scatter markers.

Affected browser(s)

More visible in Chrome (at least for this demo).

@TorsteinHonsi
Copy link
Collaborator

@jon-a-nygaard Check the rounding used for the error bar stem. Error bar inherits certain features, check that the issue is fixed as high up in the inheritance chain as possible.

@jon-a-nygaard
Copy link
Contributor

It also seems that the markers for the scatter series is a little bit skewed towards left.

@TorsteinHonsi
Copy link
Collaborator

If you remove the error bars, the scatter series markers seem to be quite well aligned to the grid lines. The grid lines are rounded to the nearest full pixel. The error bars are also rounded, but seem to be consequently 1px more to the right, so it may be that we are running Math.ceil in one place and Math.floor in another place, or Math. round/Math.ceil. Look for "crisp" in the error bar/box plot code.

@jon-a-nygaard
Copy link
Contributor

@TorsteinHonsi Thanks, looking at it right now.

The scatter markers are not centered on the grid line, but starts drawing on the beginning of the grid line, which can be seen from this image. But I guess there is a logical reason for it.
marker

@jon-a-nygaard
Copy link
Contributor

Internal Note: The shapeArgs values have already been corrected for crispness, and are therefore not so good for use in calculations.
Tried to subtract the crispCorr in BoxPlotSeries.drawPoints instead of adding it. In this case it looked better, but in cases with the same chart but a different width it could look equally bad. Therefore not a solution to the issue.

@jon-a-nygaard jon-a-nygaard removed their assignment May 27, 2016
@TorsteinHonsi
Copy link
Collaborator

Problably the crisping logic of the grid lines is also buggy, so that they are not always crisped to the closest full pixel. So a fix for this issue would require that the grid lines are fixed, which will create a lot of diffs in the visual pixel-by-pixel tests.

@KacperMadej
Copy link
Author

+1
The issue is the same with column type series: http://jsfiddle.net/m4nwwsfo/
Pixel alignment is not the same as for gridLines of xAxis.

@ucare-wuh
Copy link

Any progress on this? I recently get the same problem.

@BrianBos
Copy link

Hey there. I've also come across this issue lately. Any progress on updating the crisping logic to fix this?

@paulo-raca
Copy link
Contributor

+1, pretty annoying

@Andriy-Kulak
Copy link

If you add a pointRange: 0 and desired pointWidth to errorbar series, this seems to fix the issue per fiddle: http://jsfiddle.net/da1mpchj/1/

The workaround solution was actually provided by @paulo-raca in this ticket: #8558

@paulo-raca
Copy link
Contributor

@Andriy-Kulak -- Thanks for looking into it, but that was a workaround to a different problem (The weird spacing and extra passing applied to x-axis when there is a errorbar series).

Looking at your example, it continues a little bit off-center.
E.g., examining the SVG, the first point is centered at x=5 and the first error bar is centered at x=5.5

@Andriy-Kulak
Copy link

Andriy-Kulak commented Jul 16, 2018

@paulo-raca in any case this solution made my the issue much less noticeable in my chart. I attached before and after images
BEFORE:
before
AFTER:
after

@paulo-raca
Copy link
Contributor

Wow, I'm puzzled.
Do you have a jsfiddle with this chart?
Thanks!

@stale
Copy link

stale bot commented Jan 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. label Jan 14, 2020
@stale stale bot closed this as completed Jan 21, 2020
@jedrzejruta
Copy link
Contributor

unstale

@jedrzejruta jedrzejruta reopened this Feb 12, 2024
@tnafele
Copy link

tnafele commented Feb 12, 2024

Other example of the issue with latest Highcharts and errorbars overlays with scatter (zoomed in):
Screenshot from 2024-02-12 09-47-05
You find the Fiddle here.

Please can you fix this bug, this issue seem to be known for a very long time.

@karolkolodziej
Copy link
Contributor

Recreated with the boxplot series- demo.
Looks like the drawPoints round it quite aggressively:

width = Math.round(shapeArgs.width);
left = Math.floor(shapeArgs.x);
right = left + width;
halfWidth = Math.round(width / 2);
q1Plot = Math.floor(doQuartiles ? point.q1Plot : point.lowPlot);
q3Plot = Math.floor(doQuartiles ? point.q3Plot : point.lowPlot);
highPlot = Math.floor(point.highPlot);
lowPlot = Math.floor(point.lowPlot);

@karolkolodziej karolkolodziej removed the Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. label Feb 13, 2024
@TorsteinHonsi
Copy link
Collaborator

I set up a systematic test with gridlines, scatter, error bars and column: https://jsfiddle.net/highcharts/w7gpLsu1/ . See the console for results. The takeaways:

  • Gridlines, columns and error bars in this case are 1px wide, therefore their center positions are on a half pixel.
  • They should be centered on the half pixel that is closest to the raw pixel x.
  • It looks like the columns are currently the only elements with a perfect position. Grid lines and error bars do not always hit the closest half.
  • The scatter points are (sometimes incorrectly) rounded to the nearest full pixel. We could consider not rounding them for some shapes, or enable the crisp option. But we don't know whether we want it to be aligned to a 1px or 2px sharp object below. Under any circumstance, by fixing the incorrect rounding, it will never be more than 0.5px off.

The conclusion is that ticks/gridlines, scatter points and error bars must all be fixed, each one independently, in order to fix this bug.

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

Successfully merging a pull request may close this issue.

10 participants