plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

#2175 & #3723 - Multicategory Multilevel 2+ & Sorting Multicategory

Open richardnm-2 opened this issue 2 years ago • 5 comments

#2175 requests for a multicategory multilevel (2+). This is great for data visualization on, as mentioned, "Variability Charts".

In order to expand the capabilities of multicategory axis type, the list structure previously implemented has been changed at set_convert.js ax.setupMultiCategory(), adding a new file to src/lib -> sort_traces.js. Working with the traces as a list of objects instead, to try to provide the same data structure to setCategoryIndex() seemed easier. Sorting is performed reversed, in order to achieve a stable sorting. I don't know about the implementation, but the result is the same as if sorted backwards in pandas (Python), or an Excel table.

The capabilities upgrade was then achieved, and the other changes were to make tha axis draw the new data shape, as pushing multiple functions to seq, in a loop, to account for every level. Also, category indexes had to be updated to comply with the new data shape.

The categorical data on the axis was drawn accordingly, but the sorting issue, #3723 showed that this was a known problem. Testing showed that providing the data already sorted to the newPlot function outputed the desired result. So, as the trace levels were already beein looped inside ax.setupMultiCategory(), and the object list was easyly sortable, before transforming it to a matrix again, it made sense to also update gd._fullData with the sorted data. The place to do so may not be the best and some thought can be given to that.

richardnm-2 avatar Sep 27 '22 01:09 richardnm-2

@richardnm-2 thanks so much for opening this PR! Just a couple of structural comments while I'm reviewing the rest of the code:

  • Per the contributing guide please use node 16.x / npm 7.x - or at least don't commit the package-lock.json generated by an earlier version.
  • This PR shouldn't touch anything in the devtools/test_dashboard dir. Instead let's add one or more new figures in test/image/mocks, then you can load these in the regular dashboard, but they also become part of the test suite. If you can't get the baseline generation part to work we can help with that.

alexcjohnson avatar Oct 05 '22 17:10 alexcjohnson

@richardnm-2 Hello, great to see that someone is working on this and tries to provide a solution :) It is quite a pain with multicategory axis right now. Sorting breaks whenever an item is missing in one stack for example... Hope there will be a fix soon. fyi: We are using plotly in R

AndreasUntch avatar Mar 28 '23 07:03 AndreasUntch

@richardnm-2 It's fantastic to see your efforts to improve the current handling of multicategory axes. Currently, when a category lacks data points, it can significantly disrupt the visualization integrity. Also, having more than 2 levels is a must for most of modern data analysis. Is this feature still being worked on at the moment?

zupdaz avatar Jun 28 '23 06:06 zupdaz

Is this close to merging? Would be a great feature to have.

PhilippaTreacy avatar Jul 29 '23 20:07 PhilippaTreacy

@richardnm-2 May I inquire about the approach you used to resolve this issue in plotly.py?

DianYing123 avatar Jan 24 '24 09:01 DianYing123

Hi, is this PR still in progress? Looking forward for this functionality to be introduced in the library.

alon-aviv-ni avatar Mar 03 '24 17:03 alon-aviv-ni

I really hope this feature will be ok

wowoxiapqi avatar May 08 '24 01:05 wowoxiapqi