-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bar chart X axis autorange not working as expected ? #5200
Comments
Thanks for the report @LoganWlv - this is indeed a bug, the problem is that the range of a category axis is normally expressed in units of the category serial numbers, and as you have 8 categories (0 to 7) and you want to see the whole of each bar (±0.5) the autorange value is [-0.5, 7.5]. The bug is that apparently when we then re-interpret that range to draw the graph, because you have a category of the same name we take 7.5 to mean "the serial number of category 7.5." I imagine we're trying to be flexible and allow you to specify like |
@alexcjohnson Thanks for the details. So you confirm that it should be fixed ? |
The issue is in converting from "range values" to "calcdata" or "linearized" values, ie the functions plotly.js/src/plots/cartesian/set_convert.js Lines 318 to 324 in 8b76d46
both of which call out to plotly.js/src/plots/cartesian/set_convert.js Lines 180 to 186 in 8b76d46
I don't think we want to muck with function getRangePosition(v) {
return isNumeric(v) ? +v : getCategoryIndex(v);
} In order to complete the fix, in addition to ensuring this doesn't break any existing tests we'll need a few new ones:
plotly.js/test/jasmine/tests/axes_test.js Line 1658 in 8b76d46
plotly.js/test/jasmine/tests/annotations_test.js Line 1000 in 8b76d46
But that's in the context of testing |
Thanks a lot. I'll try to make the fix |
@alexcjohnson I created a PR. Though in local when running jasmine tests it breaks on multiple tests (with and without the fix). So I am wondering if there is something wrong in my local configuration and if I could mimic the circleCI test pipeline with docker. Some tests which are broken in local (without the fix)
|
Great, I'll take a look at your PR! Don't worry about the local test failures - some of those interaction tests are tricky to get working right, and the |
…q-category Fix autorange computation when a category match a range extreme
I have a bart chart with X axis autorange enabled.
X is of type "category" with numbers and a single string to represent not known values.
Somehow the chart is not fully displayed.
Here a minimal example with the issue :
https://codepen.io/loganwlv/pen/mdEdYLW
EDIT: Some extra information can be found there -> stack_overflow
It seems with
7.5
instead of7.5
on X the graph is displayed as expectedThe text was updated successfully, but these errors were encountered: