Changeset 11084 for branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Code/ChartHelper.cshtml
- Timestamp:
- 07/04/14 08:59:24 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Code/ChartHelper.cshtml
r11059 r11084 102 102 } 103 103 104 @helper ResizeCharts() 105 { 106 <text> 107 function resizeCharts(caller) { 108 //If current plot is collapsed 109 if($(caller).css("display") == "none") { 110 //Display the contents of chartContainer 111 ResizeOpenClose($(caller).siblings(".collapse")); 112 //Reset barWidth for bar charts 113 $.each(window[caller.id].series, function(index, series) { 114 series.barWidth = undefined; 115 }); 116 //Replot the chart with same name as element id 117 window[caller.id].replot({ resetAxes: false }); 118 //Hide the contents of the current div 119 ResizeOpenClose($(caller).siblings(".collapse")); 120 } 121 //Current plot is expanded 122 else { 123 //Reset barWidth for bar charts 124 $.each(window[caller.id].series, function(index, series) { 125 series.barWidth = undefined; 126 }); 127 //Replot the chart with same name as element id 128 window[caller.id].replot({ resetAxes: false }); 129 } 130 } 131 132 $(window).resize(function() { 133 $("div.jqplot-target",".chartContainer").each(function() { 134 var potentialTab = $(this).parent().parent().parent(); 135 //If the section is tabular and currently hidden 136 if(potentialTab.hasClass("tabSection") && potentialTab.css("display") == "none") { 137 ResizeOpenCloseTabular(potentialTab); 138 resizeCharts(this); 139 ResizeOpenCloseTabular(potentialTab); 140 } 141 else { 142 resizeCharts(this); 143 } 144 }); 145 }); 146 </text> 147 } 148 104 149 @helper NumberPages(string records, string limit, string container, string functionName, string currentPage = null) 105 150 { … … 134 179 } 135 180 136 @helper TasksForUser(string container, string destinationTag, string url, string functionName, string userName, string limit, string startDate = null, string endDate = null, string jobId=null, string taskState=null, string pageNumber=null) 137 { 138 <text> 139 var GetRequest = "?userName=" + @(userName) + "&limit=" + @(limit); 140 @if(startDate!=null) { 181 @helper TasksForUser(string destinationTag, string url, string functionName, string userName, string limit, string startDate = null, string endDate = null, string jobId = null, string taskState = null, string pageNumber = null) 182 { 183 <text> 184 var GetRequest = "?userName=" + @(userName); 185 @if (startDate != null) 186 { 141 187 @:if(@(startDate)!=null) { 142 188 @:GetRequest += "&start=" + @startDate; 143 189 @:} 144 190 } 145 @if(endDate!=null) { 191 @if (endDate != null) 192 { 146 193 @:if(@(endDate)!=null) { 147 194 @:GetRequest += "&end=" + @endDate; 148 195 @:} 149 196 } 150 @if(jobId!=null) { 197 @if (jobId != null) 198 { 151 199 @:if(@(jobId)!=null) { 152 200 @:GetRequest += "&jobId=" + @jobId; 153 201 @:} 154 202 } 155 @if(taskState!=null) { 203 @if (taskState != null) 204 { 156 205 @:if(@(taskState)!=null) { 157 206 @:GetRequest += "&taskState=" + @taskState; … … 161 210 async: false, url: "@(new HtmlString(url))" + GetRequest, datatype: "json", success: function(result) { 162 211 if(@(userName) == null) { 163 $("#@ container").append(212 $("#@(destinationTag)").append( 164 213 '<section class="chartContainer">' + 165 214 '<h1 class="title">Please select a user!</h1>' + … … 168 217 } 169 218 else if(result.length==0) { 170 $("#@ container").append(219 $("#@(destinationTag)").append( 171 220 '<section class="chartContainer">' + 172 221 '<h1 class="title">' + @userName + ' has no tasks for the specified filters!</h1>' + … … 182 231 //Checks if multipage display, if it is then trims results to 183 232 //the results for the page to be displayed 184 @ChartHelper.NumberPages("result", limit,container,functionName,pageNumber)233 @ChartHelper.NumberPages("result", limit, destinationTag, functionName, pageNumber) 185 234 186 235 //Globally accesible, for use when resizing, eliminates extra DB request … … 188 237 189 238 //Set display of all errors to none, errors matching the tasks will be reset below 190 $("#@( container)").find(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','none');239 $("#@(destinationTag)").find(".errorContainer, .errorTitle, .errorTask, .errorMessage").css('display','none'); 191 240 192 241 //For each result create a seperate collapsable section with a chart and info label 193 242 for(var i = 0; i < result.length; i++){ 194 $("#" + "@ container").append(243 $("#" + "@(destinationTag)").append( 195 244 '<section class="chartContainer">' + 196 '<h1 class="title" id="@( container)' + result[i].Key + '">Task ' + result[i].Key + '</h1>' +245 '<h1 class="title" id="@(destinationTag)' + result[i].Key + 'PlotTitle">Task ' + result[i].Key + '</h1>' + 197 246 '<button class="collapse" onclick="CollapseSection(this)">+</button>' + 198 247 '<div id="@(destinationTag)Plot' + i + '"></div>' + … … 202 251 //Re-enables the error display if any of the tasks on the page have Ids matching 203 252 //those of errors 204 $(".errorTask","#" + "@( container)").each(function() {253 $(".errorTask","#" + "@(destinationTag)").each(function() { 205 254 if($(this).html()==result[i].Key) { 206 $("#@( container)" + result[i].Key).css("color","red");207 $("#@( container)" + result[i].Key).append(" - ERROR");208 $(".errorContainer, .errorTitle, .underline" ).css('display','inline-block');255 $("#@(destinationTag)" + result[i].Key + "PlotTitle").css("color","red"); 256 $("#@(destinationTag)" + result[i].Key + "PlotTitle").append(" - ERROR"); 257 $(".errorContainer, .errorTitle, .underline","#@(destinationTag)").css('display','inline-block'); 209 258 $(this).css('display','inline-block'); 210 259 $(this).next().css('display','inline-block'); … … 250 299 }); 251 300 252 CollapsedByDefault(document.getElementById("@( container)" + result[i].Key));301 CollapsedByDefault(document.getElementById("@(destinationTag)Plot" + i)); 253 302 } 254 303 } … … 257 306 } 258 307 259 @helper ResizeTasks(string destinationTag) 260 { 261 <text> 262 //Resize event, resets bar width for task charts and replots them 263 $(window).resize(function() { 264 if(typeof numberTasks !== 'undefined') { 265 for(var i = 0; i < numberTasks; i++) { 266 $.each(window[ "@(destinationTag)Plot" + i].series, function(index, series) { 267 series.barWidth = undefined; 268 }); 269 if($("#@(destinationTag)Plot" + i).css("display") == "none") { 270 ResizeOpenClose($("#@(destinationTag)Plot" + i).siblings(".collapse")); 271 window["@(destinationTag)Plot" + i].replot({ resetAxes: true }); 272 ResizeOpenClose($("#@(destinationTag)Plot" + i).siblings(".collapse")); 273 } 274 else { 275 window["@(destinationTag)Plot" + i].replot({ resetAxes: true }); 276 } 277 } 278 } 279 }); 280 </text> 281 } 282 283 @helper SetStreamingProperties(int refresh, int chartLength, int upperY) { 308 @helper SetStreamingProperties(int refresh, int chartLength, int upperY) 309 { 284 310 <text> 285 311 //Refresh time (in millisec) … … 307 333 } 308 334 309 @helper CreateStreamChart(string dataName, string destinationTag, string url, string title, string format = null, double? maxY = null) { 335 @helper CreateStreamChart(string dataName, string destinationTag, string url, string title, string format = null, double? maxY = null) 336 { 310 337 <text> 311 338 //Get current time, used to create initial values … … 352 379 </text>} 353 380 min: 0, 354 @if (maxY != null) { 381 @if (maxY != null) 382 { 355 383 @:max: @maxY, 356 384 } 357 else{ 385 else 386 { 358 387 @:max: window["@(dataName)Data" + 0][window["@(dataName)Data" + 0].length - 1][1] + upperYBuffer, 359 388 } … … 375 404 } 376 405 377 @helper UpdateStreamChart(string dataName, string destinationTag, string url, string fixedY = null) { 406 @helper UpdateStreamChart(string dataName, string destinationTag, string url, string fixedY = null) 407 { 378 408 <text> 379 409 //If the data is beyond chartSize use shift to trim one off the end … … 406 436 @(destinationTag)PlotOptions.axes.xaxis.min = window["@(dataName)Data" + 0][0][0]; 407 437 @(destinationTag)PlotOptions.axes.xaxis.max = window["@(dataName)Data" + 0][window["@(dataName)Data" + 0].length - 1][0]; 408 @if (fixedY == null) { 438 @if (fixedY == null) 439 { 409 440 @:@(destinationTag)PlotOptions.axes.yaxis.max = window["@(dataName)Data" + 0][window["@(dataName)Data" + 0].length - 1][1] + upperYBuffer; 410 441 } … … 416 447 } 417 448 418 @helper SlaveInfoChart(string destinationTag, string url, string limit, bool singleSlave, string startDate=null, string endDate=null, string userName=null, string functionName=null, string pageNumber=null, string slaveId=null) { 419 <text> 420 var GetRequest = "?limit=" + @(limit); 421 @if(startDate!=null) { 449 @helper SlaveInfoChart(string destinationTag, string url, string limit, bool singleSlave, string startDate = null, string endDate = null, string userName = null, string functionName = null, string pageNumber = null, string slaveId = null) 450 { 451 <text> 452 var GetRequest = ""; 453 @if (startDate != null) 454 { 422 455 @:if(@(startDate)!=null) { 423 @:GetRequest += "&start=" + @startDate; 456 @:if(GetRequest == "") { 457 @:GetRequest += "?start=" + @startDate; 458 @:} 459 @:else { 460 @:GetRequest += "&start=" + @startDate; 461 @:} 424 462 @:} 425 463 } 426 @if(endDate!=null) { 464 @if (endDate != null) 465 { 427 466 @:if(@(endDate)!=null) { 428 @:GetRequest += "&end=" + @endDate; 467 @:if(GetRequest == "") { 468 @:GetRequest += "?end=" + @endDate; 469 @:} 470 @:else { 471 @:GetRequest += "&end=" + @endDate; 472 @:} 429 473 @:} 430 474 } 431 @if (userName != null) { 475 @if (userName != null) 476 { 432 477 @:if(@(userName)!=null) { 433 @:GetRequest += "&userName=" + @userName; 478 @:if(GetRequest == "") { 479 @:GetRequest += "?userName=" + @userName; 480 @:} 481 @:else { 482 @:GetRequest += "&userName=" + @userName; 483 @:} 434 484 @:} 435 485 } 436 @if (slaveId != null) { 486 @if (slaveId != null) 487 { 437 488 @:if(@(slaveId)!=null) { 438 @:GetRequest += "&slaveId=" + @slaveId; 489 @:if(GetRequest == "") { 490 @:GetRequest += "?slaveId=" + @slaveId; 491 @:} 492 @:else { 493 @:GetRequest += "&slaveId=" + @slaveId; 494 @:} 439 495 @:} 440 496 } … … 452 508 453 509 if(result.length == 0) { 510 @if (!singleSlave) { 511 @:$('#' + destTag).html(""); 512 } 454 513 $('#' + destTag).append( 455 514 '<section class="chartContainer">' + … … 461 520 var time = new Date(); 462 521 463 @if(!singleSlave) { 522 @if (!singleSlave) 523 { 464 524 @:$('#' + destTag).html(""); 465 525 … … 468 528 @ChartHelper.NumberPages("result", limit, destinationTag, functionName, pageNumber) 469 529 } 470 471 //Globally accesible, for use when resizing, eliminates extra DB request472 window["numberSlaves"] = result.length;473 530 474 531 for(i = 0; i < result.length; i++) { … … 483 540 $('#' + destTag).append( 484 541 '<section class="chartContainer">' + 485 '<h1 class="title" id="' + result[i][0].SlaveID + '">Slave ' + result[i][0].SlaveID + '</h1>' +542 '<h1 class="title" id="' + destTag + result[i][0].SlaveID + 'PlotTitle">Slave ' + result[i][0].SlaveID + '</h1>' + 486 543 '<button class="collapse" onclick="CollapseSection(this)">+</button>' + 487 '<div id="' + slaveChartNames[0] + 'Plot' + i + '"></div>' +488 '<div id="' + slaveChartNames[1] + 'Plot' + i + '"></div>' +489 '<div id="' + slaveChartNames[2] + 'Plot' + i + '"></div>' +544 '<div id="' + destTag + slaveChartNames[0] + 'Plot' + i + '"></div>' + 545 '<div id="' + destTag + slaveChartNames[1] + 'Plot' + i + '"></div>' + 546 '<div id="' + destTag + slaveChartNames[2] + 'Plot' + i + '"></div>' + 490 547 '</section>'); 491 548 for(j = 0; j < result[i].length; j++) { … … 498 555 } 499 556 if(result[i].length > 1) { 500 @ChartHelper.LineChartGivenSeries(" slaveChartNames[0]","i","coreSeries","Total/Used Cores")501 @ChartHelper.LineChartGivenSeries(" slaveChartNames[1]","i","memorySeries","Total/Used Memory",0)502 @ChartHelper.LineChartGivenSeries(" slaveChartNames[2]","i","cpuSeries","CPU Utilization",0,100,"%.1f%%")557 @ChartHelper.LineChartGivenSeries("destTag + slaveChartNames[0]", "i", "coreSeries", "Total/Used Cores") 558 @ChartHelper.LineChartGivenSeries("destTag + slaveChartNames[1]", "i", "memorySeries", "Total/Used Memory", 0) 559 @ChartHelper.LineChartGivenSeries("destTag + slaveChartNames[2]", "i", "cpuSeries", "CPU Utilization", 0, 100, "%.1f%%") 503 560 } 504 561 else { 505 @ChartHelper.BarChartGivenSeries(" slaveChartNames[0]","i","coreSeries","Total/Used Cores")506 @ChartHelper.BarChartGivenSeries(" slaveChartNames[1]","i","memorySeries","Total/Used Memory",0)507 @ChartHelper.BarChartGivenSeries(" slaveChartNames[2]","i","cpuSeries","CPU Utilization",0,100,"%.1f%%")562 @ChartHelper.BarChartGivenSeries("destTag + slaveChartNames[0]", "i", "coreSeries", "Total/Used Cores") 563 @ChartHelper.BarChartGivenSeries("destTag + slaveChartNames[1]", "i", "memorySeries", "Total/Used Memory", 0) 564 @ChartHelper.BarChartGivenSeries("destTag + slaveChartNames[2]", "i", "cpuSeries", "CPU Utilization", 0, 100, "%.1f%%") 508 565 } 509 566 for(k = 0; k < slaveChartNames.length; k++) { 510 CollapsedByDefault(document.getElementById( slaveChartNames[k] + "Plot" + i));567 CollapsedByDefault(document.getElementById(destTag + slaveChartNames[k] + "Plot" + i)); 511 568 } 512 569 } … … 516 573 } 517 574 518 @helper ResizeSlaves() { 519 <text> 520 //Resize event, resets bar width for slave charts and replots them 521 $(window).resize(function() { 522 if(typeof numberSlaves !== 'undefined') { 523 524 //Set chart names for use in creation below, must be set identically in 525 //SlaveInfoChart 526 var slaveChartNames = ["TotalUsedCores","TotalUsedMemory","CPUUtilization"]; 527 528 for(i = 0; i < numberSlaves; i++) { 529 if($("#" + slaveChartNames[0] + "Plot" + i).css("display") == "none") { 530 ResizeOpenClose($("#" + slaveChartNames[0] + "Plot" + i).siblings(".collapse")); 531 for(j = 0; j < slaveChartNames.length; j++) { 532 $.each(window[slaveChartNames[j] + "Plot" + i].series, function(index, series) { 533 series.barWidth = undefined; 534 }); 535 window[slaveChartNames[j] + "Plot" + i].replot({ resetAxes: true }); 536 } 537 ResizeOpenClose($("#" + slaveChartNames[0] + "Plot" + i).siblings(".collapse")); 538 } 539 else { 540 for(j = 0; j < slaveChartNames.length; j++) { 541 $.each(window[slaveChartNames[j] + "Plot" + i].series, function(index, series) { 542 series.barWidth = undefined; 543 }); 544 window[slaveChartNames[j] + "Plot" + i].replot({ resetAxes: true }); 545 } 546 } 547 } 548 } 549 }); 550 </text> 551 } 552 553 @helper LineChartGivenSeries(string destinationTag, string chartId, string series, string title, double? minY = null, double? maxY = null, string axisYFormat = null) { 575 @helper LineChartGivenSeries(string destinationTag, string chartId, string series, string title, double? minY = null, double? maxY = null, string axisYFormat = null) 576 { 554 577 <text> 555 578 window[@(destinationTag) + "Plot" + @(chartId)] = $.jqplot(@(destinationTag) + "Plot" + @(chartId), @series, { … … 562 585 }, 563 586 yaxis: { 564 @if (axisYFormat != null) { 587 @if (axisYFormat != null) 588 { 565 589 <text> 566 590 tickOptions: { … … 569 593 </text> 570 594 } 571 @if (minY != null) { 595 pad: 0, 596 @if (minY != null) 597 { 572 598 @:min: @minY, 573 599 } 574 @if (maxY != null) { 600 @if (maxY != null) 601 { 575 602 @:max: @maxY, 576 603 } 577 pad: 0578 604 } 579 605 }, … … 591 617 } 592 618 593 @helper BarChartGivenSeries(string destinationTag, string chartId, string series, string title, double? minY = null, double? maxY = null, string axisYFormat = null) { 619 @helper BarChartGivenSeries(string destinationTag, string chartId, string series, string title, double? minY = null, double? maxY = null, string axisYFormat = null) 620 { 594 621 <text> 595 622 window[@(destinationTag) + "Plot" + @(chartId)] = $.jqplot(@(destinationTag) + "Plot" + @(chartId), @series, { … … 607 634 }, 608 635 yaxis: { 609 @if (axisYFormat != null) { 636 @if (axisYFormat != null) 637 { 610 638 <text> 611 639 tickOptions: { … … 614 642 </text> 615 643 } 616 @if (minY != null) { 644 pad: 0, 645 @if (minY != null) 646 { 617 647 @:min: @minY, 618 648 } 619 @if (maxY != null) { 649 @if (maxY != null) 650 { 620 651 @:max: @maxY, 621 652 } 622 pad: 0623 653 } 624 654 },
Note: See TracChangeset
for help on using the changeset viewer.