Changeset 16621
- Timestamp:
- 06/03/13 16:18:19 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/js/chart.js
r16112 r16621 1 $(document).ready(function(){ 2 var chart = new Highcharts.Chart({ 3 chart: { 4 renderTo: 'container' /* display to div Graph*/ 5 }, 6 7 xAxis: { 8 labels: { 9 rotation: -45, 10 align: 'right', 11 }, 12 categories:["","","","","","","","19:00","20:00","21:00","22:00","23:00","24:00","1:00","2:00","3:00","4:00","5:00","6:00","7:00"]}, 13 series:[], /* array of Data */ 14 15 remove:function() 1 function GetData() 2 { 3 //calls the xml request in a loop based on the current sources 4 var source = ['Mrk 421','Mrk 501']; 5 for (i = 0; i<source.length; i++) 6 { 7 // alert (source[i]); 8 GetXMLData(i, source); 9 //$('#data').append('1st'+source); 10 } 11 } 12 13 function GetXMLData(index, source) 14 { 15 // alert("test XML Data"); 16 var XML; 17 //$('#data').append(' xmlData pass'+source+" "+index); 18 XML = new XMLHttpRequest(); 19 //NOTE: previous errors on the request was caused by appending "http://www.fact-project.org" 20 XML.open("GET","/smartfact/index.php?source="+escape(source[index])+"&time="+year+"-"+month+"-"+day,true); 21 dataSource = new Array(); 22 XML.onload=function() 23 { 24 if (testXML.status==200) 16 25 { 17 return false; 18 }, 19 20 exporting: { /*--------------------*/ 21 buttons: { /* */ 22 exportButton: { /* Export */ 23 menuItems: null, /* to */ 24 onclick: function() { /* PNG.file */ 25 this.exportChart(); /*--------------------*/ 26 } 27 } 28 } 29 }, 30 31 plotOptions: 26 alert("request ok"); 27 line=testXML.responseText.split('\n'); 28 dataSource.push(line); 29 if (dataSource.length == source.length) 30 { 31 // alert("new datasource"); 32 displayXMLData(dataSource, source); //this will be called when the last data from the list is read 33 //$('#data').append('successfully load'+source +""+dataSource); 34 } 35 } 36 else 37 alert("status is " + testXML.status); 38 39 }; 40 XML.send(); 41 } 42 43 function displayXMLData(dataSource, source) 44 { 45 var options = 46 { 47 chart: { 48 renderTo: 'container' /* display to div Graph*/ 49 50 }, 51 52 xAxis: { 53 categories:["12PM","1PM","2PM","3PM","4PM","5PM","6PM","7PM","8PM","9PM","10PM","11PM","12AM","1AM","2AM","3AM","4AM","5AM","6AM","7AM","8AM","9AM","10AM","12PM"] 54 }, 55 series:[], /* array of Data */ 56 57 remove:function() 58 { 59 return false; 60 }, 61 62 exporting: { /*--------------------*/ 63 buttons: { /* */ 64 exportButton: { /* Export */ 65 menuItems: null, /* to */ 66 onclick: function() { /* PNG.file */ 67 this.exportChart(); /*--------------------*/ 68 } 69 } 70 } 71 }, 72 plotOptions : { 73 74 series : { 75 lineWidth: 3, 76 77 marker : { 78 enabled:false 79 } 80 } 81 } 82 }; 83 //This function splits the lines of data per data source 84 var dataGraph = new Array(source.length); 85 var Time = new Array(source.length); 86 for (i=0; i<source.length; i++) 87 { 88 dataGraph[i] = new Array(); //dataGraph contains the individual points for each source i 89 Time[i] = new Array(); // Time contains the individual time for each sources. 90 for(row=0;row<dataSource[i].length;row++) 32 91 { 33 series: { 34 marker: { 35 enabled: false, 36 37 }, 92 rows=line[row].split(','); 93 dataGraph[i].push(parseFloat(rows[4])||parseFloat('0')); 94 Temp[i].push(rows[0]); 95 for(TempTime=0;TempTime<Temp.length;TempTime++) 96 { 97 rowTime=Temp[TempTime].split(':'); 98 colonTime[i].push(rowTime[0]); // Contains the data of Time 99 colonMin[i].push(parseInt(rowTime[1]/60*100)||parseFloat('0')); // Contains the data of minutes 100 for(TempHour=0;TempHour<colonTime.length;TempHour++) 101 { 102 rowHour=colonTime[TempHour].split('T'); 103 Hour[i].push(parseFloat(rowHour[1])||parseFloat('0')); 104 Time[i].push(Hour[i]+'.'+colonMin[i]); 105 } 38 106 39 events: { 40 legendItemClick: function(event) { 41 42 43 } 44 } 45 46 } 47 }, 48 49 50 51 }); 52 }); 107 108 } 109 } 110 $('#data').append(i + ": " + source[i] + ' GRAPH DATA ' + dataGraph[i] + ' Time '+ Time[i]); 111 } 112 }
Note:
See TracChangeset
for help on using the changeset viewer.