facebookresearch / hiplot

HiPlot makes understanding high dimensional data easy
https://facebookresearch.github.io/hiplot/
MIT License
2.74k stars 138 forks source link

Order of axes in Parallel Plot not fixed although set [JS] #251

Closed MarStock closed 2 years ago

MarStock commented 2 years ago

Hi!

Thanks for HiPlot, its really cool how easy you can get started :)

It seems that there is an issue in the npm package (I know its not considered stable) that is similar to #247. I have a react HiPlot-Component that gets passed a continuously evolving experiment object.

On change of the experiment the axes get thrown out of order although I set the "order" via experiment.display_data[hip.DefaultPlugins.PARALLEL_PLOT] = {"order": ...}.

Is there a workaround you guys can think of to induce order?

Best Regards Martin

https://user-images.githubusercontent.com/69751483/177205986-2519b969-00cd-4d08-8c48-b763375833d3.mp4

danthe3rd commented 2 years ago

Hi @MarStock and thanks for opening this issue. From looking at the code, it looks like the order parameter (like many other parameters) is only read when creating the parallel plot for the first time. It's then copied to an internal state, where it can evolve as the user re-orders columns. I'm not exactly sure how to solve this properly (would need to "merge" the user-made reorderings with the changes in the order parameter somehow). A workaround could be to re-create the entire component when a new column is added - but with the drawback of losing the state if the user has sliced or made some modifications. I can try to look into that in the coming weeks.

MarStock commented 2 years ago

Hi @MarStock and thanks for opening this issue. From looking at the code, it looks like the order parameter (like many other parameters) is only read when creating the parallel plot for the first time. It's then copied to an internal state, where it can evolve as the user re-orders columns. I'm not exactly sure how to solve this properly (would need to "merge" the user-made reorderings with the changes in the order parameter somehow). A workaround could be to re-create the entire component when a new column is added - but with the drawback of losing the state if the user has sliced or made some modifications. I can try to look into that in the coming weeks.

Thanks @danthe3rd for your quick answer and some insight :) Of course I would be glad if you could manage to do so. If I find a solution, I will keep it posted here.

Appreciate the help!

MarStock commented 2 years ago

Hi @MarStock and thanks for opening this issue. From looking at the code, it looks like the order parameter (like many other parameters) is only read when creating the parallel plot for the first time. It's then copied to an internal state, where it can evolve as the user re-orders columns. I'm not exactly sure how to solve this properly (would need to "merge" the user-made reorderings with the changes in the order parameter somehow). A workaround could be to re-create the entire component when a new column is added - but with the drawback of losing the state if the user has sliced or made some modifications. I can try to look into that in the coming weeks.

@danthe3rd EDIT: If its not too time consuming, could you elaborate how one would recreate the entire component? Maybe that does the job for me already.

danthe3rd commented 2 years ago

I think setting a different key to the component would do the trick, and React will re-create the component from scratch rather than updating the existing one

MarStock commented 2 years ago

Hah! Not even is this sufficient for me now, I also learned something new about React. I consider my issue solved. THX!