Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit f81be04

Browse files
committed
Fix Graph Bugs
1 parent ab0a8fd commit f81be04

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
latest
2-
0.3.0
2+
0.3.1
33
0.3
44
0

php/load/graphs/BarDailyWork.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function createGraph(combiData, plainData, singleDayData, canvas){
1515

1616
// get time span and all categories
1717
var minDate = Number.MAX_SAFE_INTEGER;
18-
var maxDate = -1;
18+
var maxDate = Number.MIN_SAFE_INTEGER;
1919
var allCategories = {}
2020
plainData.forEach(data => {
2121
if( data.begin < minDate ){
@@ -32,11 +32,16 @@ function createGraph(combiData, plainData, singleDayData, canvas){
3232
// fill (empty) categories in each day
3333
let plotdata = {};
3434
let plotdataLabels = [];
35-
for( timestamp = minDate; timestamp <= maxDate; timestamp += 86400){
35+
for( let timestamp = minDate; timestamp <= maxDate; timestamp += 86400){
3636
let label = getLabelFromTimestamp(timestamp);
3737
plotdata[label] = Object.assign({}, allCategories);
3838
plotdataLabels.push(label)
3939
}
40+
let lastLabel = getLabelFromTimestamp(maxDate);
41+
if( !plotdata.hasOwnProperty(lastLabel)){
42+
plotdata[lastLabel] = Object.assign({}, allCategories);
43+
plotdataLabels.push(lastLabel)
44+
}
4045

4146
// fill with data
4247
plainData.forEach(data => {
@@ -93,8 +98,7 @@ function createGraph(combiData, plainData, singleDayData, canvas){
9398
return `${chartData.datasets[tooltipItem.datasetIndex].label} ${chartData.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]} hours`;
9499
},
95100
title : function(tooltipItem, chartData) {
96-
var daySum = chartData.datasets.reduce((p,c) => p + c.data[tooltipItem[0].index], 0);
97-
return `${tooltipItem[0].label}: ${daySum} hours`;
101+
return tooltipItem[0].label + ': '+ Math.round(chartData.datasets.reduce((p,c) => p + c.data[tooltipItem[0].index], 0) * 100) / 100 + ' hours';
98102
}
99103
}
100104
},

php/load/graphs/BarDayTimes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ function createGraph(combiData, plainData, singleDayData, canvas){
7777
return `${chartData.datasets[tooltipItem.datasetIndex].label} ${chartData.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]} hours`;
7878
},
7979
title : function(tooltipItem, chartData) {
80-
var daySum = chartData.datasets.reduce((p,c) => p + c.data[tooltipItem[0].index], 0);
81-
return `${tooltipItem[0].label}:00 - ${tooltipItem[0].label}:59: ${daySum} hours`;
80+
return tooltipItem[0].label + ':00 - ' + tooltipItem[0].label + ':59: ' + Math.round(chartData.datasets.reduce((p,c) => p + c.data[tooltipItem[0].index], 0) * 100) / 100 + ' hours';
8281
}
8382
}
8483
},

php/load/graphs/BarDays.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ function createGraph(combiData, plainData, singleDayData, canvas){
5454
return `${chartData.datasets[tooltipItem.datasetIndex].label} ${chartData.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]} hours`;
5555
},
5656
title : function(tooltipItem, chartData) {
57-
var daySum = chartData.datasets.reduce((p,c) => p + c.data[tooltipItem[0].index], 0);
58-
return `${tooltipItem[0].label}: ${daySum} hours`;
57+
return tooltipItem[0].label + ': '+ Math.round(chartData.datasets.reduce((p,c) => p + c.data[tooltipItem[0].index], 0) * 100) / 100 + ' hours';
5958
}
6059
}
6160
},

0 commit comments

Comments
 (0)