-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced Line Plot Multi for Evaluation Comparisons
- Loading branch information
1 parent
50d5e33
commit 799c47f
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="box box-default" id="[[id]]"> | ||
<div class="box-header with-border"> | ||
<h3 class="box-title">Line Plot For Evaluations (multiple parameters)</h3> | ||
</div> | ||
<div class="box-body"> | ||
<div class="form-group"> | ||
<label>Title</label> | ||
<input name="name" type="text" class="form-control" placeholder="Line Plot Title" value="[[name]]"> | ||
<input type="hidden" name="type" value="line-plot-multi"> | ||
<label>Configuration parameter(s) to iterate over (Comma separated)</label> | ||
<input name="parameter" type="text" class="form-control" placeholder="Configuration Parameter(s)" value="{{IF [[parameter]] != false}}[[parameter]]{{ENDIF}}"> | ||
<label>Parameter to plot</label> | ||
<input name="plotting" type="text" class="form-control" placeholder="Parameter to plot" value="{{IF [[plotting]] != false}}[[plotting]]{{ENDIF}}"> | ||
</div> | ||
</div> | ||
<div class="box-footer"> | ||
Apply aggregation function: | ||
<br> | ||
<input type="radio" id="agg_avg[[id]]" value="avg" name="aggregate[[id]]" checked> Average | ||
<br> | ||
<input type="radio" id="agg_min[[id]]" value="min" name="aggregate[[id]]" {{IF [[aggregate]] == "min"}}checked{{ENDIF}}> Minimum | ||
<br> | ||
<input type="radio" id="agg_max[[id]]" value="max" name="aggregate[[id]]" {{IF [[aggregate]] == "max"}}checked{{ENDIF}}> Maximum | ||
<br> | ||
<input type="radio" id="agg_sum[[id]]" value="sum" name="aggregate[[id]]" {{IF [[aggregate]] == "sum"}}checked{{ENDIF}}> Sum | ||
<hr> | ||
<button type="button" class="btn btn-danger" onclick="deletePlot('[[id]]')">Delete</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Line Plot For Evaluations(multiple parameters)", | ||
"type": "line-plot-multi-eval", | ||
"required": "chartjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
/** | ||
* Given values: | ||
* - $data: containing the full data of the results | ||
* - $parameter(s): containing the name(s)/basename(s) of the parameter which this plot should parse | ||
* - $plotData: put here the values which later will be passed to the plot | ||
*/ | ||
|
||
use DBA\Job; | ||
|
||
/** @var $jobs Job[][] */ | ||
/** @var $parameter string|string[] */ | ||
/** @var $plotData string */ | ||
/** @var $allData array */ //these are all the values which are posted by this plot | ||
|
||
$dataArray = ['datasets' => []]; | ||
$colors = ['#00c0ef', '#3c8dbc', '#f56954']; | ||
|
||
$parameterData = []; | ||
$labels = []; | ||
|
||
if (!is_array($parameter)) { | ||
$parameter = explode(",", $parameter); | ||
} | ||
|
||
// put together jobs | ||
$arr = Util::mergeJobs($jobs, $parameter); | ||
$jobGroups = $arr[0]; | ||
$internLabels = $arr[1]; | ||
|
||
$colorIndex = 0; | ||
for ($i = 0; $i < sizeof($jobGroups[0]); $i++) { | ||
$parameterData[$i]['label'] = $internLabels[$i]; | ||
$parameterData[$i]['backgroundColor'] = $colors[$colorIndex % sizeof($colors)]; | ||
$parameterData[$i]['borderColor'] = $colors[$colorIndex % sizeof($colors)]; | ||
$parameterData[$i]['fill'] = false; | ||
$colorIndex++; | ||
} | ||
|
||
$arr = Util::getDifferentParameters($jobs); | ||
$changingParameters = $arr[0]; | ||
$jobParameters = $arr[1]; | ||
|
||
foreach ($jobGroups as $jobGroup) { | ||
/** @var $jobGroup Job[][] */ | ||
$jobIds = []; | ||
$index = 0; | ||
foreach ($jobGroup as $j) { | ||
$sum = 0; | ||
foreach ($j as $job) { | ||
$results = json_decode($job->getResult(), true); | ||
foreach ($parameter as $p) { | ||
if (isset($results[$allData['plotting']])) { | ||
$sum += floatval($results[$allData['plotting']]); | ||
} | ||
} | ||
} | ||
$parameterData[$index]['data'][] = $sum / sizeof($j); | ||
$jobIds[] = $j[0]->getInternalId(); | ||
$index++; | ||
} | ||
$label = []; | ||
foreach ($changingParameters as $changingParameter) { | ||
if (in_array($changingParameter, $parameter)) { | ||
continue; | ||
} else if ($changingParameter == 'run') { | ||
continue; | ||
} | ||
$label[] = $changingParameter . ": " . $jobParameters[$jobGroup[0][0]->getId()][$changingParameter]; | ||
} | ||
|
||
$labels[] = "Jobs[" . implode(", ", $label) . "]"; | ||
} | ||
|
||
foreach ($parameterData as $pData) { | ||
$dataArray['datasets'][] = $pData; | ||
$dataArray['labels'] = $labels; | ||
} | ||
|
||
$plotData = json_encode($dataArray); |
33 changes: 33 additions & 0 deletions
33
libraries/graphs/line-plot-multi-eval/render.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="chart"> | ||
<canvas id="[[plotId]]" style="height:230px"></canvas> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
var config[[plotId]] = { | ||
type: "line", | ||
data: [[plotData]], | ||
options: { | ||
responsive: true, | ||
title: { | ||
display: false | ||
}, | ||
tooltips: { | ||
mode: 'index', | ||
intersect: false, | ||
}, | ||
hover: { | ||
mode: 'nearest', | ||
intersect: true | ||
} | ||
} | ||
}; | ||
|
||
chart[[plotId]] = undefined; | ||
|
||
function plot[[plotId]](){ | ||
chart[[plotId]] = new Chart($('#[[plotId]]').get(0).getContext('2d'), config[[plotId]]); | ||
} | ||
|
||
|
||
</script> | ||
|