Calculate hidden minor ticks if ticklabelindex is set.#7735
Calculate hidden minor ticks if ticklabelindex is set.#7735my-tien wants to merge 13 commits intoplotly:masterfrom
Conversation
|
Thanks for the PR, @my-tien! Sorry for the delay, I'll review ASAP. Have you looked into the failing image tests yet? |
|
Hi @emilykl, not yet! I'll try to do it next week. |
This additional minor tick was added for ticklabel placement via ticklabelindex only. It should never be rendered.
…xes_period2_ticklabelindex
…dden-minor-ticks Undoes update of date_axes_period_ticklabelindex.png and date_axes_period2_ticklabelindex.png because they changed in the main branch. Have to do the update with the output of the next CI run.
…xes_period2_ticklabelindex. This time after having merged master into this branch.
|
Failing baseline image tests are resolved. I also updated date_axe_period_ticklabelindex.png and date_axe_period2_ticklabelindex.png. |
|
@my-tien Great! I'm taking a look. |
|
|
||
| // check if ticklabelIndex makes sense, otherwise ignore it | ||
| if(!minorTickVals || minorTickVals.length < 2) { | ||
| if(!minorTickVals || minorTickVals.length < 3) { |
There was a problem hiding this comment.
@my-tien From the comments I understand you've modified the logic to add an additional minor tick before tick0, hence these changes, but could you explain the reason for adding that additional tick?
| if (ticklabelIndex) { | ||
| if (allTicklabelVals.indexOf(tickVals[i]) === -1) { | ||
| hideLabel(t); | ||
| } | ||
| } else { | ||
| if (tickVals[i].skipLabel) { | ||
| hideLabel(t); | ||
| } | ||
| } |
There was a problem hiding this comment.
This is just a style change, correct? The code is logically equivalent before and after the change, right?
IMO it would be clearer to leave as-is, but add extra parentheses around the && clause to clarify it's evaluated first.
i.e. if(a || (b && c))
Or, otherwise, maybe
| if (ticklabelIndex) { | |
| if (allTicklabelVals.indexOf(tickVals[i]) === -1) { | |
| hideLabel(t); | |
| } | |
| } else { | |
| if (tickVals[i].skipLabel) { | |
| hideLabel(t); | |
| } | |
| } | |
| if (ticklabelIndex && allTicklabelVals.indexOf(tickVals[i]) === -1) { | |
| hideLabel(t); | |
| } else if (tickVals[i].skipLabel) { | |
| hideLabel(t); | |
| } |
There was a problem hiding this comment.
I reverted the code. No strong opinion on my end 👍
There was a problem hiding this comment.
Actually, this does something different. Only if ticklabelindex is false should the tickVals[i].skipLabel check be done.
emilykl
left a comment
There was a problem hiding this comment.
@my-tien Thank you for the PR. This change looks good to me.
I have a few requests concerning the image tests:
-
Could you combine the 3 new image mocks into one single mock with 3 subplots? This will help keep the total number of image tests down and keep the CI faster.
-
Could you explicitly set
dtickandtick0for the minor ticks in each mock, to make the expected behavior clear? -
We are no longer following the convention of prefixing new mocks and baselines with
zz-, so you can remove that prefix from the filenames. If this causes any small changes in other baselines, you can simply commit those changed baselines as part of this PR.
I added a note to the PR description that this will close #7423; please let me know if you think that's not the case.
… into a single one.
…to how it was before." The previous change wasn't actually cosmetic. If ticklabelindex is set, the skipLabel flag should not be tested here. This reverts commit 5861fc5.
Closes #7423
This PR ensures that the
ticklabelindexaxis property has an effect even if minor ticks are not visible. Labels are then drawn at possibly invisible minor tick labels n positions away from a major tick.This makes it possible to draw the label for a period to the left of a major tick which was previously not always possible. See this issue for two examples where it was previously not possible: #7423
Disclaimer
I am required to add that…the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.