-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimple.html
183 lines (157 loc) · 4.84 KB
/
simple.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!doctype html>
<head>
<meta charset="utf-8">
<script src="libs/d3.v3.js"></script>
<script src="libs/d3.chart.js"></script>
<script src="libs/h1dsuri.js"></script>
<script src="../dataviewer.js"></script>
<!-- above don't require jquery -->
<script src="libs/jquery-1.10.2.min.js"></script>
<style>
svg rect.background {
fill: white;
shape-rendering: crispEdges;
/* pointer-events: none; */
}
svg line {
stroke: #ddd;
stroke-opacity: 0.5;
stroke-width: 1;
shape-rendering: crispEdges;
}
svg rect.background {
fill: white;
shape-rendering: crispEdges;
/* pointer-events: none; */
}
svg rect.background-edit {
fill: blue;
fill-opacity:0.2;
shape-rendering: crispEdges;
pointer-events: none;
}
svg rect.resizebar {
fill: yellow;
fill-opacity: 0.5;
shape-rendering: crispEdges;
}
svg rect.resizebar:hover {
fill-opacity: 0.8;
}
svg rect.resizebar.corner {
fill: red;
}
path {
stroke-width: 1;
stroke: #0000FF;
fill: none;
stroke-opacity:0.8
}
line {
stroke: #999;
stroke-width:1px;
}
text {
font-family: Arial;
font-size: 9pt;
}
rect.extent {
fill: pink;
fill-opacity:0.7;
}
</style>
</head>
<body>
<div id="dataviewer"></div>
<script>
function getRawUri(original_uri, width) {
// assume original_url gives a timeseries.
var h1ds_uri = new H1DSUri(original_uri);
h1ds_uri.addExtraFilter('resample_minmax', {'n_bins':width});
h1ds_uri.extra_non_h1ds_query['format'] = 'json';
return h1ds_uri;
}
function testWorksheet() {
// data = [plot_1, plot_2, plot_3, ..., plot_n]
// plot_n = {plot_coords:[x0, y0, x1, y1],
// data = [series_1,series_2,..., series_n],
// }
// series_n = {url: source_url,
// url_parser: function which returns object defined below}
// url_parser: function(url, {dim_limits=[[dim0_min, dim0_max], [dim1_min, dim1_max],...], (other modifiers)})
//
// returns {
// dimension: [dim1, dim2, ...],
// dimension_dtype: str,
// dimension_units: str,
// metadata: {key1:val1, key2:val2, ...},
// name: str,
// value: [ch1, ch2, ...],
// value_dype: str,
// value_units: str,
// }
function url_parser(url, settings) {
// TODO: allow for settings - zooming etc
var new_uri = getRawUri(url, settings.width);
if (settings.hasOwnProperty("min")) { // TODO - what if only min or max but not both?
new_uri.updateOrAddBaseFilter("dim_range", {'min':settings.min, 'max':settings.max});
}
var output;
$.ajax({url: new_uri.renderExtraUri(),
dataType: "json",
async:false})
.done(function(a) {
// for new h1ds version, not yet on h1ds.anu server
//output = a.data;
// for old version, still running on h1ds.anu server
output = convertOldH1DSData(a);
});
return output;
}
var test_data = [
{'plot_coords':[0,5,5,10],
'modifiers':{},
'data':[
{url: "http://h1ds.anu.edu.au/data/H1DATA/58063/OPERATIONS/MIRNOV/A14_14/INPUT_1", url_parser:url_parser},
{url: "http://h1ds.anu.edu.au/data/H1DATA/58065/OPERATIONS/MIRNOV/A14_14/INPUT_1", url_parser:url_parser}
]},
{'plot_coords':[5,5,10,10],
'modifiers':{},
'data':[
{url:"http://h1ds.anu.edu.au/data/H1DATA/58063/OPERATIONS/I_SEC", url_parser: url_parser},
{url:"http://h1ds.anu.edu.au/data/H1DATA/58065/OPERATIONS/I_SEC", url_parser: url_parser},
]},
{'plot_coords':[0,0,5,5],
'modifiers':{},
'data':[
{url:"http://h1ds.anu.edu.au/data/ELECTR_DENS/58064/NE_HET/NE_CENTRE", url_parser: url_parser},
{url:"http://h1ds.anu.edu.au/data/ELECTR_DENS/58065/NE_HET/NE_CENTRE", url_parser: url_parser},
]},
{'plot_coords':[5,0,10,5],
'modifiers':{},
'data':[
{url: "http://h1ds.anu.edu.au/data/H1DATA/58063/OPERATIONS/BOLO_DELTA_R", url_parser:url_parser},
{url: "http://h1ds.anu.edu.au/data/H1DATA/58065/OPERATIONS/BOLO_DELTA_R", url_parser:url_parser},
]}
];
var worksheet = dataviewer.create("div#dataviewer");
worksheet.data(test_data);
worksheet.draw();
}
convertOldH1DSData = function(d) {
output_data = {
dimension: [d.dim],
dimension_dtype: "float", // not used yet by jsdataviewer
dimension_units: d.units[1], // not used yet by jsdataviewer
metadata: (d.labels.length == 2 && d.labels[0] == "min" && d.labels[1] == "max") ? {minmax_pairs:[[0,1]]} : {},
name: d.meta.shot + ": " + d.meta.path,
value: (d.data.length <=3 ) ? d.data : [d.data], // HACK - old system returns [val] for 1dim, and [[1,2,3], [1,2,3]] for 2 dim,
value_dtype: "float", // not used yet by jsdataviewer
value_units: d.units[0], // not used yet by jsdataviewer
};
return output_data;
};
testWorksheet();
</script>
</body>
</html>