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

Right margin #8

Open
ghost opened this issue Mar 3, 2013 · 1 comment
Open

Right margin #8

ghost opened this issue Mar 3, 2013 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 3, 2013

Hello.
In a diagram with only two stacks, I've noticed that the 'x' position of the right boxes is being wrongly calculated.

I have a 800x400 area, with the default 100 margin on each side. I'm using stack 0 and stack 1 for my boxes.
Thus, the result of the function 'Sankey.calculateXStep' would be (800 - 100 - 100) / 1 = 600.
For the boxes in stack 1 to respect the right margin, their 'x' should be exactly the result above, as both margins have been accounted for in the calculation.
However, they're being positioned on box.x = 100 + (1 * 600) = 700, as per 'Sankey.position_boxes_and_lines'.
This should probably be changed to 'box.x = this.left_margin + (x > 0 ? (x * x_step) - this.box_width : 0);', or some equivalent expression, assuming no negative stack indexes are used (not sure if this expression would work for more than two stacks).

Following is a screenshot of the issue, where you can see the left margin being respected, as opposed to the right margin.

Kind regards.

Untitled

@ghost
Copy link
Author

ghost commented Mar 3, 2013

Actually, I think I've figured out how to deal with more than two stacks.
The following seems to work for me.

// this.maximum_stack_x is saved when calculating x_step
box.x = this.left_margin + (x * x_step);
// just add the following (assuming the minimum stack.x is zero):
if (x === this.maximum_stack_x) { box.x -= this.box_width; }
else if (x > 0) { box.x -= this.box_width / 2; }

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

No branches or pull requests

0 participants