merenlab / anvio

An analysis and visualization platform for 'omics data
http://merenlab.org/software/anvio
GNU General Public License v3.0
415 stars 142 forks source link

Layer colors are not retained across views -- new suggestions for state :) #141

Closed meren closed 9 years ago

meren commented 9 years ago

Hi Ozcan,

When you set a color for a layer in a view (say in "mean_coverage" view), it goes back to defaults when you switch to a different view.

Naturally, when the user saves the state, colors are saved as a property of the view:

image

And then down below in a state file, there is this which keeps the order information for each layer:

image

I think we need a "layers" entry, instead of a "layer-order", and "order" should be a property in it along with "color" and "height".

After all these are view-specific:

And these are layer-specific:

So my suggestions for change are:

"layers": {
    42: {
        "order": 1,
        "height": 50,
    },
    2: {
        "order": 2,
        "color": "#414141",
        "height": 180,
    },
    (...)
}

What do you think? Does it make sense?

Sorry for the long list :( There is no rush for this. Just wanted to put it in here.

ozcan commented 9 years ago

Very good blueprint Meren, i agree most of it except layer-order, almost all loops in treelib is like "var i = 0; i < settings['layer-order'].length; i++" and layer-order should be independent array instead of object's property to keep this loops clean. I am going to work on this today,

meren commented 9 years ago

I see your point about the array.

I just tested your commit, and it works beautifully :) Thank you very much. Just merge it to the master whenever you feel like it.

One final note: I think it would be valuable to have a "version" number for the interactive tree separately. We can store this version number in the state file, and if a state file is missing the version variable (which will be the case for older state files), or reports a version that is not matching to the version of the JS code expects (which will be the case if we change the structure in the future), JS code could be like "well, I am not even going to try to make sense of it". Just an idea.

Thanks again!

ozcan commented 9 years ago

Okay i am going to merge it but ping me if you notice any bugs.

meren commented 9 years ago

Thank you!