Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/16 16:30:39 (8 years ago)
Author:
jlodewyc
Message:

#2582 Livefeed graph data, main unified graph + bugfixing refresh overload

Location:
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts/Graphs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts/Graphs/GraphDataCollector.js

    r13714 r13719  
    1515        }
    1616    }
    17     console.log("#SAVEDATA: " + id);
     17    //console.log("#SAVEDATA: " + id);
    1818    redrawGraph(id);
    1919}
     
    3434}
    3535function dataConversion(coll) {
     36   
     37   
     38    return [dataConversionLine(coll),dataConversionPie(coll)];
     39}
     40function dataConversionLine(coll) {
    3641    var xarr = [];
    3742    var yarr = [];
    38     var waiting = 0;
    39     var transfer = 0;
    40     var calc = 0;
     43    for (var v = 0; v < coll.length; v++) {
     44        xarr.push(Date.parse(coll[v].DateTime));
     45        if (coll[v].State == 1)
     46            yarr.push("Waiting");
     47        else if (coll[v].State == 2)
     48            yarr.push("Transferring");
     49        else if (coll[v].State == 3)
     50            yarr.push("Calculating");
     51        else if (coll[v].State == 5)
     52            yarr.push("Finished");
     53        else if (coll[v].State == 7)
     54            yarr.push("Failed");
     55    }
     56    var data = [{//Time graph
     57        x: xarr,
     58        y: yarr,
     59        type: 'scatter',
     60        mode: 'lines',
     61        name: 'Task ' ,
     62        connectgaps:true,
     63        line:{shape:'hv'}
     64    }];
     65    layout= {
     66        "showlegend": true,
     67        "width": "100%",
     68        "xaxis": {
     69            "autorange": true,
     70            "range": [
     71                Date.parse(coll[0].DateTime),
     72                Date.parse(coll[coll.length -1].DateTime)
     73            ],
     74            "title": "Time",
     75            "type": "date"
     76        }
     77
     78    }
     79   
     80    return [data,layout];
     81}
     82function dataConversionHBar(coll) {
     83    var xarr = [];
     84    var yarr = [];
    4185    for (var v = 0; v < coll.length; v++) {
    4286        xarr.push(coll[v].DateTime.substr(11, 8));
    43         if (coll[v].State == 1) {
     87        if (coll[v].State == 1)
    4488            yarr.push("Waiting");
    45             if (v < (coll.length - 1))
    46                 waiting += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime);
    47         }
    48         else if (coll[v].State == 2) {
     89        else if (coll[v].State == 2)
    4990            yarr.push("Transferring");
    50             if (v < (coll.length - 1))
    51                 transfer += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime);
    52         }
    53         else if (coll[v].State == 3) {
     91        else if (coll[v].State == 3)
    5492            yarr.push("Calculating");
    55             if (v < (coll.length - 1))
    56                 calc += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime);
    57         }
    5893        else if (coll[v].State == 5)
    5994            yarr.push("Finished");
     
    66101        type: 'scatter'
    67102    }];
     103   
     104    return data;
     105}
     106function dataConversionPie(coll) {
     107    var waiting = 0;
     108    var transfer = 0;
     109    var calc = 0;
     110    for (var v = 0; v < coll.length-1; v++) {
     111        if(coll[v].State == 1)
     112            waiting += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime);
     113        else if (coll[v].State == 2)
     114            transfer += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime);
     115        else if (coll[v].State == 3)
     116            calc += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime);
     117    }
    68118    var datap = [{//Pie graph
    69119        values: [
     
    77127        type: 'pie'
    78128    }];
    79     return [data, datap];
     129    return datap;
    80130}
    81131
    82132function redrawGraph(val) {
     133    document.getElementById("graph" + val).style.width = "100%";
     134    document.getElementById("graph" + val).style.height = "400px";
    83135    if (document.getElementById("graphtoggle" + val).checked) {
    84136        setTimeout(function () {
    85             Plotly.newPlot('graph' + val, getData(val));
     137            Plotly.newPlot('graph' + val, getData(val)[0], getData(val)[1]);
    86138        }, 100);
    87139        console.log("#REDRAWN LINE: " + val);
     
    90142            Plotly.newPlot('graph' + val, getDataPie(val));
    91143        }, 100);
    92         console.log("#REDRAWN PIE: " + val);
     144        //console.log("#REDRAWN PIE: " + val);
    93145    }
     146   
    94147
    95148}
     149function redrawMain() {
     150    var temp = [];
     151    var min = dataCollection[0][1][0][0].x[0];
     152    var max = min;
     153    for (var i = 0; i < dataCollection.length; i++) {
     154        temp.push(dataCollection[i][1][0][0]);
     155        if (dataCollection[i][1][0][0].x[dataCollection[i][1][0][0].x.length - 1] > max)
     156            max = dataCollection[i][1][0][0].x[dataCollection[i][1][0][0].x.length - 1];
     157        if (dataCollection[i][1][0][0].x[0] < min)
     158            min = dataCollection[i][1][0][0].x[0];
     159    }
     160    layout = {
     161        "showlegend": true,
     162        "title": new Date(min).toUTCString() + " to " + new Date(max).toUTCString(),
     163        "xaxis": {
     164            "autorange": true,
     165            "range": [
     166                min,
     167                max
     168            ],
     169            "title": "Time",
     170            "type": "date"
     171        }
     172
     173    }
     174     Plotly.newPlot('graphMain', temp, layout);
     175
     176
     177}
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts/Graphs/GraphHubber.js

    r13714 r13719  
    66        hubber.server.initConnection();
    77        hubber.server.updateAll();
    8        
     8        redrawMain();
    99    });
    1010    hubber.client.processData = function (id, data) {
     
    1313        saveData(id, obj.StateLog);
    1414    }
    15     hubber.client.requestDone = function(){
     15    hubber.client.requestDone = function () {
     16       
    1617        setTimeout(function () {
    1718            hubber.server.updateAll();
     19            console.log("#REFRESH ALL");
     20           
    1821        }, 5000);
    1922    }
     
    2225
    2326function editTaskData(id, task) {
    24     console.log(task);
    2527    //lastupdate
    2628    var dat = new Date(task.LastHeartbeat);
     
    5456        });
    5557        $("#statepar" + id).html("State: Finished");
    56         console.log(task.DateFinished);
    5758        var datf = new Date(task.StateLog[task.StateLog.length -1].DateTime);
    5859        $("#lastupdpar" + id).html("Finished: " + datf.toUTCString());
Note: See TracChangeset for help on using the changeset viewer.