Skip to content

Commit fb019df

Browse files
committed
fix: fixed bugs in PeriodUsage (wrong date labels) and TimelineBarChart (suggestedMax not set correctly)
1 parent b9398c0 commit fb019df

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/views/activity/Activity.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,13 @@ export default {
397397
const new_period_length_moment = periodLengthConvertMoment(periodLength);
398398
new_date = moment(date).startOf(new_period_length_moment).format('YYYY-MM-DD');
399399
}
400-
this.$router.push({
401-
path: `/activity/${this.host}/${periodLength}/${new_date}/${this.subview}/${this.currentViewId}`,
402-
query: this.$route.query,
403-
});
400+
const path = `/activity/${this.host}/${periodLength}/${new_date}/${this.subview}/${this.currentViewId}`;
401+
if (this.$route.path !== path) {
402+
this.$router.push({
403+
path,
404+
query: this.$route.query,
405+
});
406+
}
404407
},
405408
406409
refresh: async function (force) {

src/visualizations/TimelineBarChart.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ export default {
5555
computed: {
5656
labels() {
5757
const start = this.timeperiod_start;
58-
const count = this.timeperiod_length[0];
59-
const resolution = this.timeperiod_length[1];
58+
const [count, resolution] = this.timeperiod_length;
6059
if (resolution.startsWith('day') && count == 1) {
6160
const hourOffset = get_hour_offset();
6261
return _.range(0, 24).map(h => `${(h + hourOffset) % 24}`);
@@ -95,6 +94,7 @@ export default {
9594
};
9695
},
9796
chartOptions(): ChartOptions {
97+
const resolution = this.timeperiod_length[1];
9898
return {
9999
plugins: {
100100
tooltip: {
@@ -112,10 +112,10 @@ export default {
112112
y: {
113113
stacked: true,
114114
min: 0,
115-
suggestedMax: this.resolution === 'day' ? 1 : undefined,
115+
suggestedMax: resolution.startsWith('day') ? 1 : undefined,
116116
ticks: {
117117
callback: hourToTick,
118-
stepSize: this.resolution === 'day' ? 0.25 : 1,
118+
stepSize: resolution.startsWith('day') ? 0.25 : 1,
119119
},
120120
},
121121
},

src/visualizations/periodusage.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const d3 = require('d3');
44
const _ = require('lodash');
55
const moment = require('moment');
66

7-
import { seconds_to_duration } from '../util/time';
7+
import { seconds_to_duration, get_hour_offset } from '../util/time';
88

99
function create(svg_elem) {
1010
// Clear element
@@ -64,7 +64,7 @@ function update(svg_elem, usage_arr, onPeriodClicked) {
6464
let date = '';
6565
if (events.length > 0) {
6666
// slice off so it's only the day
67-
date = moment(usage_arr[i][0].timestamp).format(dateformat);
67+
date = moment(events[0].timestamp).subtract(get_hour_offset(), 'hours').format(dateformat);
6868
}
6969
const color = i == center_elem ? diagramcolor_selected : diagramcolor;
7070
const offset = 50;
@@ -113,9 +113,7 @@ function update(svg_elem, usage_arr, onPeriodClicked) {
113113
.on('click', function () {
114114
onPeriodClicked(date);
115115
});
116-
rect
117-
.append('title')
118-
.text(moment(date).format(dateformat) + '\n' + seconds_to_duration(usage_time));
116+
rect.append('title').text(date + '\n' + seconds_to_duration(usage_time));
119117
});
120118
}
121119

0 commit comments

Comments
 (0)