Compute the correct number of pixels to shave off of bar width

This commit is contained in:
Michael Lange 2018-07-12 16:45:12 -07:00
parent 79725168b8
commit 72f4f213d9
1 changed files with 8 additions and 1 deletions

View File

@ -117,7 +117,14 @@ export default Component.extend(WindowResizable, {
this.set('slices', slices);
const setWidth = d => `${width * d.percent - (d.index === sliceCount - 1 || d.index === 0 ? 1 : 2)}px`;
const setWidth = d => {
// Remove a pixel from either side of the slice
let modifier = 2;
if (d.index === 0) modifier--; // But not the left side
if (d.index === sliceCount - 1) modifier--; // But not the right side
return `${width * d.percent - modifier}px`;
};
const setOffset = d => `${width * d.offset + (d.index === 0 ? 0 : 1)}px`;
let hoverTargets = slices.selectAll('.target').data(d => [d]);