GMOD / jbrowse

JBrowse 1, a full-featured genome browser built with JavaScript and HTML5. For JBrowse 2, see https://github.com/GMOD/jbrowse-components.
http://jbrowse.org
Other
464 stars 199 forks source link

color of glyph #1627

Closed srobb1 closed 2 years ago

srobb1 commented 2 years ago

Ok. this is probably a super easy one:

In Jbrowse 1, I want to color my canvas glyph blue if is of type mRNA and red otherwise, but they are all colored black. What have I done wrong with my javascript?

"color": "function(feature) { return feature.get('type')==='mRNA' ?'blue':'red'; }"

I see the example here and i modeled mine after it: https://jbrowse.org/docs/faq.html#how-do-i-customize-feature-colors-with-canvasfeatures

Thank you, Sofia

cmdcolin commented 2 years ago

can you check the javascript console to see if there are errors? black I think often means there is a syntax error

srobb1 commented 2 years ago

The only one I have is one that is always there

Uncaught (in promise) Error: getTranslators: detection is already running
    at Zotero.Translate.Web.<anonymous> (translate.js:1112:45)
    at Zotero.Translate.Web.getTranslators (promise.js:36:17)
    at Object.init (inject.js:108:25)
    at Object.historyChanged (inject.js:692:21)
    at messageListener (messaging_inject.js:122:50)
    at messaging_inject.js:132:6
srobb1 commented 2 years ago

I don't know. It is working now. I tried to get the console to print type and it would never print 'mRNA'. So i did this instead, and it is working. console will print out tRNA and rRNA. I am not sure what is up with my type 'mRNA'. The info box clearly says mRNA and if I get the label to print type, I see mRNA. Oh well. I have what I need.

    "color": "function(feature) { type=feature.get('type');if (type.indexOf('rRNA')==0){return 'coral'}else if(type.indexOf('tRNA')==0){return 'green'}else{ return 'orange' }}",
cmdcolin commented 2 years ago

nice :) chrome often aggressively caches the trackList.json files so need to do full clear cache to see the updates to trackList.json sometimes. small faq entry about things i've run into

cmdcolin commented 2 years ago

https://jbrowse.org/docs/faq.html#i-set-a-value-in-my-config-file-but-it-isn-t-working-why-not

srobb1 commented 2 years ago

Thanks!