Skip to content

Commit

Permalink
load stats
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Apr 1, 2023
1 parent 5d528e9 commit f6ba8f2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion html/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

<body>
<nav class="topmenu">
<a class="selected" data-type="tree">Tree</a>
<a data-type="tree" class="selected" >Tree</a>
<a data-type="functions">Functions</a>
<a data-type="tags">Tags</a>
<a data-type="loads">Loads</a>
</nav>
<header class="header container">
<p class="title"></p>
Expand Down
36 changes: 36 additions & 0 deletions js/class.Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class Stats {
else if('tags' === chartType) {
this.updateTags();
}
else if('loads' === chartType) {
this.updateLoads();
}
}


Expand Down Expand Up @@ -227,6 +230,39 @@ class Stats {
}
}


// update the Canvas by displaying the stats of the loads
updateLoads() {
let datasets = {typ:[], max:[]};
let labels = [];
let max = 0;

// display the title
$('.title').html('Loads Power');

// hide the 'go to parent' button
$('.goToParent').fadeOut(200);

// fill the chart with loads power
this.tree.forEachLoad((load) => {
let name = load.characs.name;
let ptyp = load.getInputPower('typ');
let pmax = load.getInputPower('max');

datasets.typ.push(ptyp);
datasets.max.push(pmax);
labels.push(name);

if(ptyp > max) max = ptyp;
if(pmax > max) max = pmax;
});

// create two charts and fill them, without click callback
this.plotChart('typ', datasets.typ, labels, max, 'power (W)', null);
this.plotChart('max', datasets.max, labels, max, 'power (W)', null);
}


// remove both canvas and print a default text
empty(title = 'No selection') {
if(null !== this.charts.typ) this.charts.typ.destroy();
Expand Down

0 comments on commit f6ba8f2

Please sign in to comment.