-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fixing BarSeries overlapped #944
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like what you have going here, but the algebra of these statements is really hard to read. Can you include some notes explaining why these changes are necessary in the code?
src/plot/series/bar-series-canvas.js
Outdated
const valuePos = Math.min(value0(row), value(row)); | ||
const x = valuePosAttr === 'x' ? valuePos : linePos; | ||
const y = valuePosAttr === 'y' ? valuePos : linePos; | ||
|
||
const lineSize = itemSize * 2 / sameTypeTotal; | ||
const lineSize = ((itemSize * 2 / sameTypeTotal) - (1 - (1 / sameTypeTotal))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe clearer as (itemSize * 2 - (sameTypeTotal - 1)) / sameTypeTotal ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@mcnuttandrew Sure, I'll add some comments. I think it would also help to add some variables for intermediate values (with appropriate descriptive names). Do you think that would be ok? |
@gsas2 that sounds like a great idea, value ease of reading here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow that's a lot of text! Sorry to give you the run around here, but would you mind reducing each of those comments to around 2-4 lines? Readability and brevity are closely related. I think your variable names do more work than you are expected of them at the moment
Sure. Sorry I didn't know where to stop 😳 |
996a5da
to
0498293
Compare
@mcnuttandrew I'd been trying to fix it by reducing the space (instead of adding 1 pixel, using some smaller values like 0.90), but while that might fix this new issue, it makes the original overlapping to appear back (but with less overlapping). |
Hi @mcnuttandrew, do you have any comments/thoughts around this? |
This seems fine? If you'll clean up the merge conflict i'll merge |
@mcnuttandrew Merge conflicts solved. Please, let me know if anything else is missing. Thanks! |
@gsas2 sorry about the delay i've been traveling. Thanks again for addressing this! |
This PR adjusts the calculation of bar width and starting position, to avoid bars "of same type" getting overlapped.
Reference: #936
Before
After