<commit_before>define( ['dojo/_base/declare',
         'JBrowse/View/Track/Canvas'
        ],
        function( declare,  CanvasTrack ) {
return declare( CanvasTrack,
/**
 * @lends JBrowse.View.Track.Wiggle.prototype
 */
{
    constructor: function( args ) {
        this.inherited( arguments );
        this.store = args.store;
        this.store.whenReady( this, 'loadSuccess' );
    },

    load: function() {
    },

    loadSuccess: function(o,url) {
        this.empty = this.store.empty || false;
        this.setLoaded();
    },

    _getView: function(scale) {
        if( !this._viewCache || this._viewCache.scale != scale ) {
            this._viewCache = {
                scale: scale,
                view: this.store.getView(1/scale)
            };
        }
        return this._viewCache.view;
    },

    renderCanvases: function( scale, leftBase, rightBase, callback ) {
        var width = ( rightBase - leftBase + 1 ) * scale;
        var trackHeight = 100;
        var globalMax = 1000;
        var fillStyle = (this.config.style||{}).fillStyle || '#00f';
        this._getView( scale )
            .readWigData( this.refSeq.name, leftBase, rightBase, function( features ) {
                var c = dojo.create(
                    'canvas',
                    { height: trackHeight,
                      width: width,
                      innerHTML: 'Canvas-based tracks not supported by this browser'
                    }
                );
                var context = c && c.getContext && c.getContext('2d');
                if( context ) {
                    //context.fillText(features.length+' spans', 10,10);
                    context.fillStyle = fillStyle;
                    //console.log( 'filling '+leftBase+'-'+rightBase);
                    dojo.forEach(features, function(f) {
                        //console.log( f.get('start') +'-'+f.get('end')+':'+f.get('score') );
                        var left  = Math.floor(( f.get('start')-1 - leftBase ) * scale );
                        var width = Math.ceil(( f.get('end') - f.get('start') + 1 ) * scale );
                        var height = f.get('score')/globalMax * trackHeight;
                        context.fillRect( left, trackHeight-height, width, height );
                    }, this );
                }

                if( ! callback ) {
                    console.error('null callback?');
                }
                else {
                    callback( [c] );
                }
            });
    }
});
});
<commit_msg>make canvas widths a round number of pixels<commit_after>define( ['dojo/_base/declare',
         'JBrowse/View/Track/Canvas'
        ],
        function( declare,  CanvasTrack ) {
return declare( CanvasTrack,
/**
 * @lends JBrowse.View.Track.Wiggle.prototype
 */
{
    constructor: function( args ) {
        this.inherited( arguments );
        this.store = args.store;
        this.store.whenReady( this, 'loadSuccess' );
    },

    load: function() {
    },

    loadSuccess: function(o,url) {
        this.empty = this.store.empty || false;
        this.setLoaded();
    },

    _getView: function(scale) {
        if( !this._viewCache || this._viewCache.scale != scale ) {
            this._viewCache = {
                scale: scale,
                view: this.store.getView(1/scale)
            };
        }
        return this._viewCache.view;
    },

    renderCanvases: function( scale, leftBase, rightBase, callback ) {
        var width = Math.ceil(( rightBase - leftBase ) * scale);
        var trackHeight = 100;
        var globalMax = 1000;
        var fillStyle = (this.config.style||{}).fillStyle || '#00f';
        this._getView( scale )
            .readWigData( this.refSeq.name, leftBase, rightBase, function( features ) {
                var c = dojo.create(
                    'canvas',
                    { height: trackHeight,
                      width: width,
                      innerHTML: 'Canvas-based tracks not supported by this browser'
                    }
                );
                var context = c && c.getContext && c.getContext('2d');
                if( context ) {
                    //context.fillText(features.length+' spans', 10,10);
                    context.fillStyle = fillStyle;
                    //console.log( 'filling '+leftBase+'-'+rightBase);
                    dojo.forEach(features, function(f) {
                        //console.log( f.get('start') +'-'+f.get('end')+':'+f.get('score') );
                        var left  = Math.floor(( f.get('start')-1 - leftBase ) * scale );
                        var width = Math.ceil(( f.get('end') - f.get('start') + 1 ) * scale );
                        var height = f.get('score')/globalMax * trackHeight;
                        context.fillRect( left, trackHeight-height, width, height );
                    }, this );
                }

                if( ! callback ) {
                    console.error('null callback?');
                }
                else {
                    callback( [c] );
                }
            });
    }
});
});

{'fraction_non_alphanumeric': 0.13596405547958584, 'fraction_numerical': 0.006837272904864231, 'mean_word_length': 1.4094117647058824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3606966', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1356, 'n_words': 283}