-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Y Axes alignment option #985
Conversation
I agree this is a good feature. However, I find the implementation excessively complicated.
Also, this definitely needs tests in spec/composite-chart-spec.js, showing that the axes are not aligned with |
Conflicts: dc.js dc.js.map dc.min.js dc.min.js.map src/composite-chart.js
as per review comment from gordonwoodhull
@gordonwoodhull sorry about that. I'd been using the composite chart in an application we're developing. Originally this axes alignment feature was developed outside I haven't added tests in spec/composite-chart-spec.js yet. Before that, please let me know if the refactor is ok. |
if (leftYAxisChildren().length !== 0) { prepareLeftYAxis(); } | ||
if (rightYAxisChildren().length !== 0) { prepareRightYAxis(); } | ||
var left = (leftYAxisChildren().length !== 0), right = (rightYAxisChildren().length !== 0), | ||
ranges = calculateYAxesRanges(left, right); |
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.
Needs var
otherwise ranges
will end up in the global scope.
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.
@gordonwoodhull looks like I mislead you with the indentation. I'll just change the multivar declare for better readability.
Ah, this looks much more clear! And now I understand why you took the prior approach, modifying these classes from outside is indeed tricky. I like that the new approach doesn't change existing interfaces. This can go into the 2.0 branch, once you add tests. Thanks! |
Conflicts: dc.js.map dc.min.js dc.min.js.map web/js/dc.js.map web/js/dc.min.js web/js/dc.min.js.map
Duh, right, fooled by the indent. Thanks! |
Hi @gazal-k. Thanks again! I'm currently merging this. The design and code structure is very good, but I'm not sure about the actual calculation. It can cause one of the axes actually to flip over, in the simple Jasmine test case I built where one of the charts is all negative. Could you explain the rationale behind taking the ratio of minimum and maximum on one axis, and then applying this ratio to the other axis? It seems like it does cause the zero lines to match up, but might not always keep both plots with the chart boundaries or properly oriented. |
add tests force resize when changing alignYAxes rename calculateYAxisRanges add author
Merged in 2.0.0 beta 20 |
@gordonwoodhull sorry for the delayed reply. I don't remember exactly how I applied the math for it. Let me try the test you mentioned. |
@gordonwoodhull thanks for that. I had totally missed that case. And sorry that I made you write the tests 😢 |
Note: I think it was implied that In other words, you can't manually apply the Y domains and use this feature, because this feature expects to set the Y domains for you. |
@gordonwoodhull sorry about that. so alignYAxes should have no effect when elasticY is false, correct? Shall make the change here: #1033 |
You agree this is correct, right? I think I have fixed it in the commit referenced above. It may have been me who broke this in the first place, since I made some additional changes after testing your code. Please review the fix and then document this requirement in #1033. Thanks! |
Hadn't noticed 3d13e68. And yes, I do agree that alignYAxes need only be applied when elasticY is true. |
Whoops I linked one commit but not the other. Here is the fix: d1c087d |
When there are two y axes and at least one of them has values in the negative range, the 0 level on both axes don't line up.
Having an option to line them up seemed like a nice to have in my opinion.
Example:
Without Setting alignAxes option:
Setting alignAxes option:
Pending