Rev 269 | Rev 275 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 269 | Rev 270 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | 29 | ||
30 | <script src="js/Blob.js"></script> |
30 | <script src="js/Blob.js"></script> |
31 | 31 | ||
32 | 32 | ||
33 | <!-- <script type="text/javascript" src="js/JSRootCore.js?2d&onload=startGUI""></script> --> |
33 | <!-- <script type="text/javascript" src="js/JSRootCore.js?2d&onload=startGUI""></script> --> |
34 | <script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js? |
34 | <script type="text/javascript" src="https://root.cern/js/latest/scripts/JSRootCore.js?2d&onload=startGUI"></script> |
35 | <script type = "text/javascript" language = "javascript"> |
35 | <script type = "text/javascript" language = "javascript"> |
36 | 36 | ||
37 | var es; |
37 | var es; |
38 | function addLog(message) { |
38 | function addLog(message) { |
39 |
|
39 | var r = document.getElementById('results'); |
40 | //r.innerHTML += message + '<br>'; |
- | |
41 | r.insertAdjacentHTML('beforeend', message +'<br/>'); |
40 | r.insertAdjacentHTML('beforeend', message +'<br/>'); |
42 | // r.scrollTop = r.scrollHeight; |
- | |
43 | } |
41 | } |
44 | 42 | ||
45 | function showStat(message) { |
43 | function showStat(message) { |
46 | var r = document.getElementById('sbar'); |
44 | var r = document.getElementById('sbar'); |
47 | r.innerHTML = message ; |
45 | r.innerHTML = message ; |
Line 50... | Line 48... | ||
50 | 48 | ||
51 | 49 | ||
52 | function startGUI() { |
50 | function startGUI() { |
53 | // d3.select('html').style('height','100%'); |
51 | // d3.select('html').style('height','100%'); |
54 | // d3.select('body').style({'min-height':'100%', 'margin':'0px', "overflow" :"hidden"}); |
52 | // d3.select('body').style({'min-height':'100%', 'margin':'0px', "overflow" :"hidden"}); |
55 | // var r = document.getElementById('results'); |
53 | // var r = document.getElementById('results'); |
56 | // r.style.display = 'none'; |
54 | // r.style.display = 'none'; |
57 | var r0 = document.getElementById('sbar'); |
55 | var r0 = document.getElementById('sbar'); |
58 | r0.style.display = 'none'; |
56 | r0.style.display = 'none'; |
- | 57 | JSROOT.gStyle.fOptFit = 1111; |
|
59 | 58 | ||
60 | } |
59 | } |
61 | 60 | ||
62 | 61 | ||
63 | function fitpanel(oFormElement) |
62 | function fitpanel(oFormElement) |
64 | { |
63 | { |
65 | var xhr = new XMLHttpRequest(); |
64 | var xhr = new XMLHttpRequest(); |
66 | xhr.onreadystatechange = function() { |
65 | xhr.onreadystatechange = function() { |
67 | if(xhr.readyState == 4 && xhr.status == 200) { |
66 | if(xhr.readyState == 4 && xhr.status == 200) { |
68 | - | ||
69 | var event = JSON.parse(xhr.responseText); |
67 | var event = JSON.parse(xhr.responseText); |
70 | var result =event.data; |
68 | var result = event.data; |
71 | var |
69 | var th1 = JSROOT.parse(result.message); |
72 | var sframe = jsonobj.fName; |
- | |
73 | var tf1 = jsonobj.fFunctions.arr[0]; |
- | |
74 | var tformula = tf1.fFormula; |
- | |
75 | var |
70 | var hname = th1.fName; |
76 | // addLog('#TF1 ' +JSON.stringify(tf1, null, '\t')+ '$$$<br>'); |
- | |
77 | mtext = '<br/>' + "Fit Function: " + tformula.fFormula+ '<br/>'; |
- | |
78 | mtext +="Chi2/NDF: " + tf1.fChisquare.toPrecision(2) + " / "+ tf1.fNDF+ '<br/>'; |
- | |
79 | mtext +='<table border="0" width="50%" >'; |
- | |
80 | for ( var i = 0;i <len;i++){ |
- | |
81 |
|
71 | var r = document.getElementById('drawing'); |
82 |
|
72 | if (document.getElementById(hname) == null ){ |
83 | var err = tf1.fParErrors[i]; |
- | |
84 |
|
73 | r.insertAdjacentHTML('beforeend', '<div id="' + hname +'" style="width:80%; height:80%;"></div><br/>'); |
85 | } |
74 | } |
86 | mtext +="</table><br/>"; |
- | |
87 | var |
75 | var hframe = document.getElementById(hname); |
88 |
|
76 | hframe.innerHTML = ''; |
89 | - | ||
90 |
|
77 | // https://github.com/root-project/jsroot/issues/42 |
91 | if (document.getElementById(sframe) == null ){ |
- | |
92 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:80%; height:80%;"></div><br/>'); |
- | |
93 |
|
78 | |
94 |
|
79 | JSROOT.draw(hname, th1, "hist"); |
95 |
|
80 | JSROOT.gStyle.fOptFit = 1111; |
96 | JSROOT.draw( |
81 | JSROOT.draw(hname, th1, "func"); |
- | 82 | ||
97 |
|
83 | |
98 | document.getElementById('data'+ |
84 | document.getElementById('data'+ hname).value=result.message; |
99 | frame |
85 | //frame.scrollIntoView(); |
100 | } |
86 | } |
101 | } |
87 | } |
102 | xhr.open (oFormElement.method, oFormElement.action, true); |
88 | xhr.open (oFormElement.method, oFormElement.action, true); |
103 | 89 | ||
104 | var data = new FormData (oFormElement); |
90 | var data = new FormData (oFormElement); |
Line 133... | Line 119... | ||
133 | }); |
119 | }); |
134 | } |
120 | } |
135 | 121 | ||
136 | function EventListener(e) { |
122 | function EventListener(e) { |
137 | //addLog(JSON.stringify(e) ); |
123 | //addLog(JSON.stringify(e) ); |
138 | 124 | ||
139 | var result = JSON.parse( e.data ); |
125 | var result = JSON.parse( e.data ); |
140 | 126 | ||
141 | if(e.lastEventId == 'CLOSE') { |
127 | if(e.lastEventId == 'CLOSE') { |
142 | addLog('Received CLOSE closing'); |
128 | addLog('Received CLOSE closing'); |
143 | es.close(); |
129 | es.close(); |
Line 154... | Line 140... | ||
154 | showStat(result.message); |
140 | showStat(result.message); |
155 | } else { |
141 | } else { |
156 | var jsonobj = JSROOT.parse(result.message); |
142 | var jsonobj = JSROOT.parse(result.message); |
157 | var sframe = jsonobj.fName; |
143 | var sframe = jsonobj.fName; |
158 | 144 | ||
159 | 145 | ||
160 | addLog('Histogram :'+ sframe ); |
146 | addLog('Histogram :'+ sframe ); |
161 | var r = document.getElementById('results'); |
147 | var r = document.getElementById('results'); |
162 | //var r = document.getElementById('drawing'); |
148 | //var r = document.getElementById('drawing'); |
163 | if (document.getElementById(sframe) == null ){ |
149 | if (document.getElementById(sframe) == null ){ |
164 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:1000px; height:600px"></div><br/>'); |
150 | r.insertAdjacentHTML('beforeend', '<div id="' + sframe +'" style="width:1000px; height:600px"></div><br/>'); |
165 | r.insertAdjacentHTML('beforeend', '<div id="fit' + sframe +'" style="display: none"></div><br/>'); |
151 | r.insertAdjacentHTML('beforeend', '<div id="fit' + sframe +'" style="display: none"></div><br/>'); |
166 | var fit = document.getElementById('fit'+ sframe); |
152 | var fit = document.getElementById('fit'+ sframe); |
167 | mform ='<form method="post" action="th1fit.php" onsubmit="return fitpanel(this);">'; |
153 | mform ='<form method="post" action="th1fit.php" onsubmit="return fitpanel(this);">'; |
168 | mform += ' <input |
154 | mform += ' Function:<input type="text" size="20" value="gaus" name="fitfun" /><br/>'; |
169 | mform += ' Range: min=<input type="text" size="2" value="0" name="min" />'; |
155 | mform += ' Range: min=<input type="text" size="2" value="0" name="min" />'; |
170 | mform += ' |
156 | mform += ' max=<input type="text" size="2" value="20" name="max" /><br/>'; |
171 | mform += ' Function:<input type="text" size="5" value="gaus" name="fitfun" />'; |
- | |
172 | mform += ' Initial parameters<input |
157 | mform += ' Initial parameters (separated by ,)<input type="text" size="20" value="" name="prm" /><br/>'; |
173 | mform += ' <input id="data'+ sframe +'" type="hidden" value="'+ result.message +'" name="data" />'; |
158 | mform += ' <input id="data'+ sframe +'" type="hidden" value="'+ result.message +'" name="data" />'; |
174 | mform += ' <input type="hidden" value="'+ sframe +'" name="name" />'; |
159 | mform += ' <input type="hidden" value="'+ sframe +'" name="name" />'; |
- | 160 | mform += ' <input class="mybutton" type="submit" value=" Fit "/>'; |
|
175 | mform += '</form>'; |
161 | mform += '</form>'; |
176 | fit.insertAdjacentHTML('beforeend', '<div id="param' + sframe +'"></div><br/>'); |
162 | fit.insertAdjacentHTML('beforeend', '<div id="param' + sframe +'"></div><br/>'); |
177 | fit.insertAdjacentHTML('beforeend', mform); |
163 | fit.insertAdjacentHTML('beforeend', mform); |
178 | r.insertAdjacentHTML('beforeend','<input type="button" onclick="togglevisibility(\'fit'+sframe+'\');" class="mybutton" value="Show/Hide Fit Panel" /><hr/>' ); |
164 | r.insertAdjacentHTML('beforeend','<input type="button" onclick="togglevisibility(\'fit'+sframe+'\');" class="mybutton" value="Show/Hide Fit Panel" /><hr/>' ); |
179 | document.getElementById('data'+ sframe).value=result.message; |
165 | document.getElementById('data'+ sframe).value=result.message; |
180 | //r.insertAdjacentHTML('beforeend', JSON.stringify(result.message)); |
166 | //r.insertAdjacentHTML('beforeend', JSON.stringify(result.message)); |
181 | } |
167 | } |
182 | var frame = document.getElementById(sframe); |
168 | var frame = document.getElementById(sframe); |
183 | 169 | ||
184 | JSROOT.redraw(sframe, jsonobj, "hist"); |
170 | JSROOT.redraw(sframe, jsonobj, "hist"); |
185 | 171 | ||
186 | 172 | ||
187 | frame.scrollIntoView(); |
173 | frame.scrollIntoView(); |
188 | } |
174 | } |