From 8e4d7024dbdf56625ace33881f30245395d4c18f Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 10 Jan 2013 14:52:24 -0600 Subject: Made x-axis values into ints; committing before trying to add multiple graphs for each chromosome --- .../static/new/javascript/marker_regression.coffee | 17 +++++++++++++---- .../wqflask/static/new/javascript/marker_regression.js | 14 +++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee index cb19712f..9f2eb8d7 100644 --- a/wqflask/wqflask/static/new/javascript/marker_regression.coffee +++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee @@ -74,9 +74,14 @@ $ -> class Manhattan_Plot constructor: -> + #@chromosomes = {} # Hash of chromosomes + # + #@init_chromosomes() + @process_data() @display_graph() + process_data: -> qtl_results = js_data.qtl_results #console.log("qtl_results: ", qtl_results) @@ -84,9 +89,10 @@ $ -> @max_mb = 0 for result in qtl_results if result.locus.chromosome == '1' - if parseInt(result.locus.mb) > @max_mb - @max_mb = result.locus.mb - @plot_points.push([result.locus.mb, result.lrs]) + mb = parseInt(result.locus.mb) + if mb > @max_mb + @max_mb = mb + @plot_points.push([mb, result.lrs]) display_graph: -> x_axis_max = Math.ceil(@max_mb/25) * 25 @@ -95,6 +101,8 @@ $ -> while (x_tick <= x_axis_max) x_axis_ticks.push(x_tick) x_tick += 25 + console.log("x_axis_ticks:", x_axis_ticks) + console.log("type of x_axis ticks:", typeof(x_axis_ticks[0]), typeof(x_axis_ticks[2])) #console.log("@plot_points is:", @plot_points) $.jqplot('manhattan_plot', [@plot_points], title: '1' @@ -103,7 +111,7 @@ $ -> markerRenderer: $.jqplot.MarkerRenderer markerOptions: style: "filledCircle" - size: 3 + size: 3 axesDefaults: tickRenderer: $.jqplot.CanvasAxisTickRenderer labelRenderer: $.jqplot.CanvasAxisLabelRenderer @@ -115,6 +123,7 @@ $ -> tickOptions: angle: 90 showGridline: false + formatString: '%d' label: "Megabases" yaxis: min: 0 diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js index 30e287dd..c69d0340 100644 --- a/wqflask/wqflask/static/new/javascript/marker_regression.js +++ b/wqflask/wqflask/static/new/javascript/marker_regression.js @@ -80,7 +80,7 @@ } Manhattan_Plot.prototype.process_data = function() { - var qtl_results, result, _i, _len, _results; + var mb, qtl_results, result, _i, _len, _results; qtl_results = js_data.qtl_results; this.plot_points = []; this.max_mb = 0; @@ -88,10 +88,11 @@ for (_i = 0, _len = qtl_results.length; _i < _len; _i++) { result = qtl_results[_i]; if (result.locus.chromosome === '1') { - if (parseInt(result.locus.mb) > this.max_mb) { - this.max_mb = result.locus.mb; + mb = parseInt(result.locus.mb); + if (mb > this.max_mb) { + this.max_mb = mb; } - _results.push(this.plot_points.push([result.locus.mb, result.lrs])); + _results.push(this.plot_points.push([mb, result.lrs])); } else { _results.push(void 0); } @@ -108,6 +109,8 @@ x_axis_ticks.push(x_tick); x_tick += 25; } + console.log("x_axis_ticks:", x_axis_ticks); + console.log("type of x_axis ticks:", typeof x_axis_ticks[0], typeof x_axis_ticks[2]); return $.jqplot('manhattan_plot', [this.plot_points], { title: '1', seriesDefaults: { @@ -129,7 +132,8 @@ ticks: x_axis_ticks, tickOptions: { angle: 90, - showGridline: false + showGridline: false, + formatString: '%d' }, label: "Megabases" }, -- cgit v1.2.3