This commit is contained in:
mantao 2020-07-28 04:44:28 +00:00
parent 53783025e2
commit 78b916c3a7
2 changed files with 10 additions and 12 deletions

View File

@ -1,5 +1,6 @@
from datetime import datetime
from datetime import timezone
import numpy
class TimeSeriesAccumulator:
@ -26,19 +27,15 @@ class TimeSeriesAccumulator:
result = []
for i in self.data:
new = f(i)
if new == numpy.nan:
if numpy.isnan(new):
result.append(prev)
else:
result.append(new)
prev = new
return result
return [f(i) for i in self.data]
def get_ts(self):
return [datetime.utcfromtimestamp(self.start_timestamp+(i+1)*self.bin_time) for i in range(self.n_bins)]
def get_ts(self):
return [datetime.utcfromtimestamp(self.start_timestamp+(i+1)*self.bin_time) for i in range(self.n_bins)]
if __name__ == "__main__":

View File

@ -430,9 +430,9 @@
<script src="./dist/js/tabler.min.js"></script>
<script>
$.get("/stat", function (data) {
// @formatter:off
document.addEventListener("DOMContentLoaded", function () {
var load_stat = function(){
$.getJSON("/stat", function (data) {
// @formatter:off
window.ApexCharts && (new ApexCharts(document.getElementById('chart-mentions'), {
chart: {
type: "line",
@ -516,9 +516,10 @@
},
},
})).render();
});
// @formatter:on
});
};
load_stat();
</script>
@ -601,4 +602,4 @@
</script>
</body>
</html>
</html>