[Gmod-ajax] Issues with callback functions to customize CanvasFeatures

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Gmod-ajax] Issues with callback functions to customize CanvasFeatures

AWilkey
Hello again!

Was working on trying to get a feel for the callbacks for customizing CanvasFeatures and have run into a problem. Any attempt to use a callback results in the track not rendering. Looking into the console, it gives a TypeError: track.config is undefined.

Code being used in the tracks.config:

[tracks.MtTranGlyMax]
...
testCallback = function( feature ) {
        return false;
    }
style.color = function( track, feature, div ) {
        track.config.testCallback(feature) ? 'red' : 'green';
    }



Note that if track.config.testCallback(feature) ? 'red' : 'green;

is replaced with :
1) return 'green';
    The feature renders without a problem.
2) 'green';
    The feature is displayed, but is coloured as if using null as the value.

Thanks,
Andrew

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Issues with callback functions to customize CanvasFeatures

Colin
Hi Andrew,
I think you caught a bug in our documentation. this callback signature is not used for CanvasFeatures (in fact CanvasFeatures don't use divs at all, so that is a good argument for why it would be different :)

I am updating the section here now http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_Right-click_Context_Menus

For future reference, instead of this type

style.color = function( track, feature, div ) {
    track.config.variantIsHeterozygous(feature) ? 'red' : 'blue';
  }


For CanvasFeatures it should say something more like

style.color = function( feature, variableName, glyphObject, track ) {
    return track.config.variantIsHeterozygous(feature) ? 'red' : 'blue';
}


-Colin


On Thu, Jun 5, 2014 at 7:48 AM, Andrew Wilkey <[hidden email]> wrote:
Hello again!

Was working on trying to get a feel for the callbacks for customizing CanvasFeatures and have run into a problem. Any attempt to use a callback results in the track not rendering. Looking into the console, it gives a TypeError: track.config is undefined.

Code being used in the tracks.config:

[tracks.MtTranGlyMax]
...
testCallback = function( feature ) {
        return false;
    }
style.color = function( track, feature, div ) {
        track.config.testCallback(feature) ? 'red' : 'green';
    }



Note that if track.config.testCallback(feature) ? 'red' : 'green;

is replaced with :
1) return 'green';
    The feature renders without a problem.
2) 'green';
    The feature is displayed, but is coloured as if using null as the value.

Thanks,
Andrew

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: Issues with callback functions to customize CanvasFeatures

AWilkey
Thanks! I had been wondering if this was a potential issue with the documentation, having recently re-read the secton and noted the part on glyph callback. Just tested and it is working as expected.


On Thu, Jun 5, 2014 at 10:20 AM, Colin <[hidden email]> wrote:
Hi Andrew,
I think you caught a bug in our documentation. this callback signature is not used for CanvasFeatures (in fact CanvasFeatures don't use divs at all, so that is a good argument for why it would be different :)

I am updating the section here now http://gmod.org/wiki/JBrowse_Configuration_Guide#Customizing_Right-click_Context_Menus

For future reference, instead of this type

style.color = function( track, feature, div ) {
    track.config.variantIsHeterozygous(feature) ? 'red' : 'blue';
  }


For CanvasFeatures it should say something more like

style.color = function( feature, variableName, glyphObject, track ) {
    return track.config.variantIsHeterozygous(feature) ? 'red' : 'blue';
}


-Colin


On Thu, Jun 5, 2014 at 7:48 AM, Andrew Wilkey <[hidden email]> wrote:
Hello again!

Was working on trying to get a feel for the callbacks for customizing CanvasFeatures and have run into a problem. Any attempt to use a callback results in the track not rendering. Looking into the console, it gives a TypeError: track.config is undefined.

Code being used in the tracks.config:

[tracks.MtTranGlyMax]
...
testCallback = function( feature ) {
        return false;
    }
style.color = function( track, feature, div ) {
        track.config.testCallback(feature) ? 'red' : 'green';
    }



Note that if track.config.testCallback(feature) ? 'red' : 'green;

is replaced with :
1) return 'green';
    The feature renders without a problem.
2) 'green';
    The feature is displayed, but is coloured as if using null as the value.

Thanks,
Andrew

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax




------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax