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

Multicategory axis type #3300

Merged
merged 55 commits into from Dec 11, 2018

Conversation

Projects
None yet
5 participants
@etpinard
Copy link
Member

commented Nov 30, 2018

(attempts to) resolves #2799 by adding a new axis type: 'multicategory' - which displays two (maybe more later) axis labels levels along with "dividers" in-between each category group.

N.B. This branch is up-to-date with the latest master that includes uirevision.


Things to TODO:

  • add support for type: 'multicategory' on y-axes
  • add support to heatmap and contours
  • add support in histogram* traces
  • [ ] add some way to configure ticks/dividers per category level - leave for later
  • improve axis.automargin test coverage, partly done in: 80f4701, more to come in #3305
  • test as many edge cases I can think of

Things skipped:

  • ticktext / tickvals are not coerced on type: 'multicategory' axes
  • support for transforms

cc @plotly/plotly_js @nicolaskruchten

etpinard added some commits Nov 26, 2018

rm useless `if(ax._mainLinePosition)` condition
- ax._mainLinePosition appears to be always defined for cartesian axes
generalize tick labels selection stash
- so that it can still be relevant for multi-category axes.
small fixup in axis drawTitle()
- no need to export it on Axes
- return Lib.syncOrAsync result
mv ax drawTitles() to end of Axes.drawOne
- this will allow us to use ax._boundingBox
  for multicategory axes
stash crispRound ax.gridwidth value on ax._gw
... similar to ax._lw for ax.linewidth.
2nd look at mutlicategory positioning
- compute and use tick-label height to position secondary labels
- disallow 30deg tick label rotation when fixing overlaps
- use ax._boundingBox to position axis title on multicategory
  axes.

etpinard added some commits Nov 30, 2018

generalize Lib.maxRowLength
- make it return z.length if z is 1D
- make it return 0 when not an array
add Lib.minRowLength and use it to find trace._length
- mea culpa: no need to keep track of max-row-length for
  multicategory coordinate array, min-row-length suffices.
improve multicategory ax.makeCalcdata
- make sure calc'ed arrays are sorted properly
- handle null and undefined item correctly
- handle non-2d-array input correctly
- test 2d-array input on non-multicategory axes
initial support for multicategory on y-axes
- improve secondary-label to axis title padding
- add horizontal violin mock
fix data-referenced shapes on multicategory axes
- lock down annotations in same mock.
@alexcjohnson

This comment has been minimized.

Copy link
Contributor

commented on src/plots/cartesian/set_convert.js in 3bc03e5 Dec 11, 2018

We still have d2r, d2l_noadd, and d2p below - do these have a meaning or should they be removed as well?

This comment has been minimized.

Copy link
Member Author

replied Dec 11, 2018

They still have a meaning.

function getCategoryName(v) {
return ax._categories[Math.round(v)];
}

and

function getCategoryIndex(v) {
// d2l/d2c variant that that won't add categories but will also
// allow numbers to be mapped to the linearized axis positions
if(ax._categoriesMap) {
var index = ax._categoriesMap[v];
if(index !== undefined) return index;
}
if(isNumeric(v)) return +v;
}

work just fine with multicategory axes - as they fill in ax._categories and ax._categoryMap just like type: 'category' axes.

alexcjohnson added some commits Dec 11, 2018

pre-collate counteraxes and subplot ids for each axis
this means Axes.getSubplots and Axes.findSubplotsWithAxis are
essentially unused internally, but we have some outside callers
using getSubplots

alexcjohnson and others added some commits Dec 11, 2018

Merge pull request #3323 from plotly/clean-defaults-mc
Clean up automargin pipeline a bit
@alexcjohnson

This comment has been minimized.

Copy link
Contributor

commented Dec 11, 2018

💃 love it.

@etpinard etpinard merged commit 07d73df into master Dec 11, 2018

8 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: publish Your tests passed on CircleCI!
Details
ci/circleci: test-image Your tests passed on CircleCI!
Details
ci/circleci: test-image2 Your tests passed on CircleCI!
Details
ci/circleci: test-jasmine Your tests passed on CircleCI!
Details
ci/circleci: test-jasmine2 Your tests passed on CircleCI!
Details
ci/circleci: test-syntax Your tests passed on CircleCI!
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details

@etpinard etpinard deleted the multicategory branch Dec 11, 2018

@Braintelligence

This comment has been minimized.

Copy link

commented Dec 20, 2018

Just to make 100% sure:
Is it somehow possible to combine this with xaxis.type = "date" or linear if you want your datapoint to be between two ticks (divider style) and still keep the advantages of these axis types? (scalability and so on)
As it stands now it seems that showdividers is not compatible with xaxis.type = "date" to me.

@etpinard

This comment has been minimized.

Copy link
Member Author

commented Dec 20, 2018

As it stands now it seems that showdividers is not compatible with xaxis.type = "date" to me.

That's correct. Dividers are only available for type: 'multicategory' axes.

@LJaschinski

This comment has been minimized.

Copy link

commented Mar 8, 2019

Hello, do you know when 'multicategory' type will displays more than two axis ? Is there a work in progress about it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.