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

Problems with isInverted when sorted in reverse order and dynamic Area #25

Closed
Jackpohare opened this issue Aug 24, 2015 · 4 comments
Closed
Labels
Milestone

Comments

@Jackpohare
Copy link

This excellent d3 addon seems perfect for a need I have to do a simple pyramid. However, I need the biggest at bottom and going up in decreasing order with dynamic area such that the top is a triangle.
When I do that it seems to miscalculate areas and ends up with NaN in the path (from the calculation of bottomBase for last (now highest) data point.
I tried to understand why but could.
This is the options and the sort I add to the basic example on usage page:
var options = { bottomWidth: 0, isInverted:true, dynamicArea:true };

    data.sort(function (a, b) { return a[1] - b[1]; });
@jakezatecky
Copy link
Owner

Good find. There are several problems going on in here.

  • The NaN issues occurs because it was not expected that bottomWidth would fall outside of the open range (0, 1). That is mostly easily remedied by using some low factor (such as 1 / 1000): http://jsfiddle.net/6eLayjoc/1/
    • The code base should probably be made to try to account for the situations where bottomWidth === 0 || bottomWidth === 1. I probably should create a separate ticket for this.
  • The dynamicArea, isInverted, and bottomWidth appear to play very badly together. Remove any of the three options and you get expected results: http://jsfiddle.net/n0tmr3pf/1/
  • If you reserve the order of the data, things really get out of hand: http://jsfiddle.net/2xxLbqzL/

I will have to look into this more deeply to figure out what is going on. I'll attempt to get to it this coming weekend, but no guarantees.

@jakezatecky jakezatecky added this to the Release 0.6.12 milestone Aug 25, 2015
@Jackpohare
Copy link
Author

Thanks for response. I wouldn't mind trying to help if I could, but I don't understand the bottomBase calculation.
I can see when dynamicArea is true you work out what the area should be and use that and topBase to calculate bottomBase, but I don't understand that calculation. Also, not sure if it is right. e.g. I took your last fiddle and change the data to just be:
['Applicants', 12000],
['Pre-screened', 12000]
But the result does not show equal areas.

@jakezatecky
Copy link
Owner

I clearly have not worked on this. With the changes slated for v0.7, I am going to switch to height-based calculations, which should help resolve the behaviors being experienced here.

@jakezatecky
Copy link
Owner

@Jackpohare This should be resolved now. Here is an example:

http://jsfiddle.net/2xxLbqzL/2/

Note that if the bottomWidth is zero, it will chop off the label. The ability have the labels off to the side will be a separate, albeit extremely non-trivial, feature (#10).

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

No branches or pull requests

2 participants