aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/static/new/javascript/create_manhattan_plot.js
blob: 30af484d21e2ba74d2ea88c82b802ac6bd4199e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Generated by CoffeeScript 1.8.0
var create_manhattan_plot;

create_manhattan_plot = function() {
  var chrrect, data, h, halfh, margin, mychart, totalh, totalw, w;
  h = 500;
  w = 1200;
  margin = {
    left: 60,
    top: 40,
    right: 40,
    bottom: 40,
    inner: 5
  };
  halfh = h + margin.top + margin.bottom;
  totalh = halfh * 2;
  totalw = w + margin.left + margin.right;
  console.log("js_data:", js_data);
  mychart = lodchart().lodvarname("lod.hk").height(h).width(w).margin(margin).ylab("LOD score").manhattanPlot(js_data.manhattan_plot);
  data = js_data.json_data;
  d3.select("div#topchart").datum(data).call(mychart);
  chrrect = mychart.chrSelect();
  chrrect.on("mouseover", function() {
    return d3.select(this).attr("fill", "#E9CFEC");
  }).on("mouseout", function(d, i) {
    return d3.select(this).attr("fill", function() {
      if (i % 2) {
        return "#F1F1F9";
      }
      return "#FBFBFF";
    });
  });
  return mychart.markerSelect().on("click", function(d) {
    var r;
    r = d3.select(this).attr("r");
    return d3.select(this).transition().duration(500).attr("r", r * 3).transition().duration(500).attr("r", r);
  });
};

create_manhattan_plot();

$("#export").click((function(_this) {
  return function() {
    var filename, form, svg, svg_xml;
    svg = $("#topchart").find("svg")[0];
    svg_xml = (new XMLSerializer).serializeToString(svg);
    console.log("svg_xml:", svg_xml);
    filename = "manhattan_plot_" + js_data.this_trait;
    form = $("#exportform");
    form.find("#data").val(svg_xml);
    form.find("#filename").val(filename);
    return form.submit();
  };
})(this));

$("#export_pdf").click((function(_this) {
  return function() {
    var filename, form, svg, svg_xml;
    svg = $("#topchart").find("svg")[0];
    svg_xml = (new XMLSerializer).serializeToString(svg);
    console.log("svg_xml:", svg_xml);
    filename = "manhattan_plot_" + js_data.this_trait;
    form = $("#exportpdfform");
    form.find("#data").val(svg_xml);
    form.find("#filename").val(filename);
    return form.submit();
  };
})(this));