-
Notifications
You must be signed in to change notification settings - Fork 1
/
d3heat-lib.html
113 lines (98 loc) · 3.18 KB
/
d3heat-lib.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
<style>
html, body {
position: relative;
height: 100%;
font-family: 'Open Sans' !important;
}
#plot1 {
width: 100%;
height: 75%;;
}
svg,
canvas {
position: absolute;
image-rendering: optimizeSpeed;
image-rendering: crisp-edges;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;
}
.axis text {
font: 14px 'Open Sans';
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.axis .axis-label {
font-size: 14px;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
}
.axis path {
/* display: none; */
}
.grid .tick {
stroke: lightgrey;
opacity: 0.7;
}
.grid path {
stroke-width: 0;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="../lib/jquery-extend.js"></script>
<script src="../lib/heat-chart.js" charset="utf-8"></script>
<script src="../lib/colormap.js" charset="utf-8"></script>
</head>
<body>
<!--<script src="d3.v3.min.js"></script>-->
<script>
window.onload = function() {
var dispatch = d3.dispatch("update_main", "update_colorbar");
var colormap_selector = document.getElementById('colormap_selector');
for (var m in colormap.colormap_data) {
var new_option = document.createElement("option");
new_option.value = m;
new_option.text = m;
colormap_select.add(new_option);
}
colormap_select.value = "jet"; // default
chart = heatChart.default({ztransform: 'log', margin: {"bottom": 75}})
.autoscale(true)
.xlabel("Qx (\u212B\u207B\u00B9)")
.ylabel("Qz (\u212B\u207B\u00B9)");
d3.json("sample_data/512.json", function(error, heatmap) {
//mydata = heatmap;
c = d3.select("#plot1")
.data([heatmap])
.call(chart);
chart.zoomScroll(true);
});
}
// chart.target_ratio(1).update(); // changes aspect ratio!
// var new_dims = chart.dims();
// new_dims.xmax = 256;
// chart.dims(new_dims).update(); // new dimensions for 2d plot object
// chart.show_grid(false); // grid off
</script>
<div id="plot1">
</div>
<div id="demos">
<pre>chart.colormap(cm.get_colormap(<select id="colormap_select" onchange="chart.colormap(colormap.get_colormap(this.value)).redrawImage(); chart.colorbar.update();"></select>)).redrawImage();</pre>
<pre>chart.aspect_ratio(<input type="text" value="null" name="aspect_ratio" onchange="chart.aspect_ratio(this.value).update()" />).update();</pre>
<pre>chart.dims({xmax: <input type="number" value="1" name="xmax" onchange="chart.dims({xmax: parseFloat(this.value)}).update()" />}).update(); // new xmax for 2d plot object</pre>
<pre>chart.show_grid(<input type="text" value="true" name="show_grid" onchange="chart.show_grid(this.value)" />); // grid off/on</pre>
<pre>chart.ztransform(<input type="text" value="log" name="ztransform" onchange="chart.ztransform(this.value).update()" />).update(); // do we like linear or sqrt color scale better?</pre>
</div>
</body>
</html>