Skip to content

Commit 963f62e

Browse files
committed
fix floating time issue, xaxis window issue and show missing refresh
1 parent f8fc2df commit 963f62e

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

graph.core.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const GraphLayoutApp = {
7676
? GH.formatGraphWindowTime(ms)
7777
: new Date(ms).toLocaleString();
7878

79-
return { start: formatTs(startMs), end: formatTs(endMs), length: `${hours}h${mins} (${windowSecs} seconds)` };
79+
return { start: formatTs(startMs), end: formatTs(endMs), length: `${hours}h${mins} (${windowSecs} seconds)`, floating: !!this.state.floatingtime };
8080
},
8181

8282
selectedSavedGraph() {
@@ -134,7 +134,9 @@ const GraphLayoutApp = {
134134
watch: {
135135
savedGraphSelected(v) { this.onSavedGraphSelectedChange(v); },
136136
'state.showlegend': 'renderChart',
137-
'state.showmissing': 'renderChart',
137+
// showmissing maps to the skipmissing fetch param, so it must re-fetch
138+
// (a re-render alone can't restore data the server already skipped).
139+
'state.showmissing': 'fetchFeedData',
138140
'state.showtag': 'renderChart',
139141
'state.csvtimeformat': 'updateCsvText',
140142
'state.csvnullvalues': 'updateCsvText',
@@ -1089,6 +1091,14 @@ const GraphLayoutApp = {
10891091
const { startMs, endMs } = this.getWindowRange();
10901092
let { start: s, end: e } = normalized;
10911093
if (!isFinite(s) || !isFinite(e) || s >= e) { s = startMs; e = endMs; }
1094+
// A floating-time graph stores a relative window: re-anchor it to "now"
1095+
// on load, keeping the saved duration, so it always shows recent data.
1096+
else if (normalized.floatingtime) {
1097+
const now = Math.round(Date.now() / 1000) * 1000;
1098+
this.graphTimeHours = String(Math.round((e - s) / 3600_000));
1099+
s = now - (e - s);
1100+
e = now;
1101+
}
10921102

10931103
this.syncWindowInputs(s, e);
10941104
this.applySavedGraphState(normalized);

graph.lib.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,11 @@ const buildFlotOptions = (startMs, endMs, state) => {
388388
applyYAxisBounds(yaxes[1], state.yaxismin2, state.yaxismax2);
389389
return {
390390
lines: { fill: false, lineWidth: 2 },
391-
xaxis: { mode: 'time', timezone: 'browser', min: startMs, max: endMs,
391+
xaxis: { mode: 'time', timezone: 'browser', min: startMs*0.001, max: endMs*0.001,
392+
// Honour the requested view window regardless of where data
393+
// exists; without this Flot 5's default autoScale ("exact")
394+
// snaps the axis to the data extents instead.
395+
autoScale: 'none',
392396
monthNames: monthNamesShort,
393397
dayNames: dayNamesShort,
394398
axisPan: true,

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "Graph",
3-
"version" : "3.2.3",
3+
"version" : "3.2.4",
44
"location" : "/var/www/emoncms/Modules",
55
"branches_available": ["stable","master"]
66
}

view.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@
562562
<div id="window-info" class="window-info" v-if="windowInfo">
563563
<b><?php echo tr('Window'); ?>:</b> {{ windowInfo.start }} <b>&#x2192;</b> {{ windowInfo.end }}
564564
&nbsp;&middot;&nbsp; <b><?php echo tr('Length'); ?>:</b> {{ windowInfo.length }}
565+
<span v-if="windowInfo.floating">&nbsp;&middot;&nbsp; <b><?php echo tr('Floating time on'); ?></b></span>
565566
</div>
566567

567568
</div>

0 commit comments

Comments
 (0)