commit/galaxy-central: kanwei: trackster: Refactor LineTrack overflow, fix it to work better for Line and Filled modes
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/a66255ab6b93/ changeset: r5567:a66255ab6b93 user: kanwei date: 2011-05-16 23:08:06 summary: trackster: Refactor LineTrack overflow, fix it to work better for Line and Filled modes affected #: 2 files (679 bytes) --- a/lib/galaxy/visualization/tracks/data_providers.py Mon May 16 10:03:47 2011 -0400 +++ b/lib/galaxy/visualization/tracks/data_providers.py Mon May 16 17:08:06 2011 -0400 @@ -336,7 +336,8 @@ num_points = (end-start) / 1280 if num_points < 1: num_points = end - start - num_points = max(num_points, 10) + else: + num_points = min(num_points, 500) data = bbi.query(chrom, start, end, num_points) f.close() --- a/static/scripts/trackster.js Mon May 16 10:03:47 2011 -0400 +++ b/static/scripts/trackster.js Mon May 16 17:08:06 2011 -0400 @@ -3062,14 +3062,13 @@ // Pixel position of 0 on the y axis var y_zero = Math.round( height + min_value / vertical_range * height ); - // Line at 0.0 + // Horizontal line to denote x-axis if ( mode !== "Intensity" ) { ctx.fillStyle = "#aaa"; ctx.fillRect( 0, y_zero, width, 1 ); } ctx.beginPath(); - ctx.fillStyle = this.prefs.color; var x_scaled, y, delta_x_px; if (data.length > 1) { delta_x_px = Math.ceil((data[1][0] - data[0][0]) * w_scale); @@ -3077,8 +3076,10 @@ delta_x_px = 10; } for (var i = 0, len = data.length; i < len; i++) { + ctx.fillStyle = this.prefs.color; x_scaled = Math.round((data[i][0] - view_start) * w_scale); y = data[i][1]; + var top_overflow = false, bot_overflow = false; if (y === null) { if (in_path && mode === "Filled") { ctx.lineTo(x_scaled, height_px); @@ -3087,8 +3088,10 @@ continue; } if (y < min_value) { + bot_overflow = true; y = min_value; } else if (y > max_value) { + top_overflow = true; y = max_value; } @@ -3116,6 +3119,24 @@ } } } + // Draw lines at boundaries if overflowing min or max + ctx.fillStyle = this.prefs.overflow_color; + if (top_overflow || bot_overflow) { + var overflow_x; + if (mode === "Histogram" || mode === "Intensity") { + overflow_x = delta_x_px; + } else { // Line and Filled, which are points + x_scaled -= 2; // Move it over to the left so it's centered on the point + overflow_x = 4; + } + if (top_overflow) { + ctx.fillRect(x_scaled, 0, overflow_x, 3); + } + if (bot_overflow) { + ctx.fillRect(x_scaled, height_px - 3, overflow_x, 3); + } + } + ctx.fillStyle = this.prefs.color; } if (mode === "Filled") { if (in_path) { @@ -3127,38 +3148,6 @@ ctx.stroke(); } - // Draw lines at bounderies if overflowing min or max - var overflow_min_start = -1, - overflow_max_start = -1; - ctx.fillStyle = this.prefs.overflow_color; - var last_x_scaled; - for (var i = 0, len = data.length; i < len; i++) { - y = data[i][1]; - x_scaled = Math.round((data[i][0] - view_start) * w_scale); - - // If we are in a min/max run, check if it should be ended - if ( overflow_max_start >= 0 && ( y === null || y < max_value ) ) { - // Value does not exist or is in valid range, any overflow ends - ctx.fillRect( overflow_max_start, 0, last_x_scaled + delta_x_px - overflow_max_start, 2 ); - overflow_max_start = -1; - } else if ( overflow_min_start >= 0 && ( y === null || y > min_value ) ) { - // Draw bottom overflow bar - ctx.fillRect( overflow_min_start, height - 2, last_x_scaled + delta_x_px - overflow_min_start, 2 ); - overflow_min_start = -1; - } - - // Now check if we should start a new one (this may happen on the same - // base as above if switching between min/max) - if ( y !== null && y > max_value && overflow_max_start < 0 ) { - // Top overflows and we are not already in a run of overflow - overflow_max_start = x_scaled; - } else if ( y !== null && y < min_value && overflow_min_start < 0 ) { - // Bottom overflows and we are not already in a run - overflow_min_start = x_scaled; - } - last_x_scaled = x_scaled; - } - ctx.restore(); } Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket