Browse Source

Fix interactive page for individual energy point

compton 2 years ago
parent
commit
006479103b
1 changed files with 13 additions and 19 deletions
  1. 13 19
      page/init.php

+ 13 - 19
page/init.php

@@ -28,8 +28,8 @@ $selected_csv = isset($_GET["csv_file"])&&in_array($_GET["csv_file"], $cleanArrs
 
 
 <html>
 <html>
 <head>
 <head>
-    <!--<script src="plotly-2.11.1.min.js"></script> -->
-    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
+    <script src="plotly-latest.min.js"></script>
+    <!-- <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> -->
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" href="main.css">
     <link rel="stylesheet" href="main.css">
     <title>Compton interactive plots</title>
     <title>Compton interactive plots</title>
@@ -41,22 +41,15 @@ $selected_csv = isset($_GET["csv_file"])&&in_array($_GET["csv_file"], $cleanArrs
     <form name="form" action="" method="get">
     <form name="form" action="" method="get">
         <p style="text-align: center;">Select energy point:</p>
         <p style="text-align: center;">Select energy point:</p>
 	<div style="margin: 0 auto; display: flex; justify-content: center;">
 	<div style="margin: 0 auto; display: flex; justify-content: center;">
-	<select name="season" class="select-css" style="margin: 0;" onchange="this.form.submit()">
-	<?
-	    foreach($availableSeasons as $s){
-	    ?><option value="<?echo $s?>" <?echo isSelected($s, $season)?>><?echo $s?></option>
-	    <?
-	    }
-	?>
-
-	</select>
+        <select name="season" class="select-css" style="margin: 0;" onchange="this.form.submit()">
+            <? foreach($availableSeasons as $s){ ?>
+            <option value="<?echo $s?>" <?echo isSelected($s, $season)?>><?echo $s?></option>
+            <? } ?>
+        </select>
         <select name="csv_file" class="select-css" style="margin: 0;" onchange="this.form.submit()">
         <select name="csv_file" class="select-css" style="margin: 0;" onchange="this.form.submit()">
-            <?
-            foreach($cleanArrs as $file){
-                ?><option value="<?echo $file?>" <?echo isSelected($file, $selected_csv)?>><?echo $file?></option>
-                <?
-            }
-            ?>
+            <? foreach($cleanArrs as $file){ ?>
+            <option value="<?echo $file?>" <?echo isSelected($file, $selected_csv)?>><?echo $file?></option>
+            <? } ?>
         </select>
         </select>
 	</div>
 	</div>
     </form>
     </form>
@@ -65,7 +58,7 @@ $selected_csv = isset($_GET["csv_file"])&&in_array($_GET["csv_file"], $cleanArrs
     <script>
     <script>
         function makeplot(){
         function makeplot(){
             Plotly.d3.csv('<?echo $url_total_info;?>', (allRows)=>{
             Plotly.d3.csv('<?echo $url_total_info;?>', (allRows)=>{
-                const {mean_energy, mean_spread} = parseResultsTable(allRows, <?echo reset(explode('_', $selected_csv));?>);        
+                const {mean_energy, mean_spread} = parseResultsTable(allRows, "<?echo $selected_csv;?>");        
                 Plotly.d3.csv('<?echo $url.$selected_csv;?>', function(data){processData(data, mean_energy, mean_spread)});
                 Plotly.d3.csv('<?echo $url.$selected_csv;?>', function(data){processData(data, mean_energy, mean_spread)});
             }
             }
             );
             );
@@ -73,8 +66,9 @@ $selected_csv = isset($_GET["csv_file"])&&in_array($_GET["csv_file"], $cleanArrs
         
         
         function parseResultsTable(allRows, energy_point){
         function parseResultsTable(allRows, energy_point){
             // Extracts a row following the energy point in the total csv file (or null if energy point is not exists)
             // Extracts a row following the energy point in the total csv file (or null if energy point is not exists)
+            data = energy_point.slice(0, -4).split('_');
             for (var i=0; i<allRows.length; i++){
             for (var i=0; i<allRows.length; i++){
-                if (allRows[i].energy_point == energy_point ){
+                if (allRows[i].first_run == data[1] ){
                     return allRows[i];
                     return allRows[i];
                 }
                 }
             }
             }