Round dates in the device graph

This commit is contained in:
Starbeamrainbowlabs 2019-07-31 19:42:33 +01:00
parent 1f9ae2be56
commit d4a6253aeb
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -9,11 +9,12 @@ import moment from 'moment';
// Chart.js pollutes the global scope, but the main entry point is going to change soon in v2.8 - which should fix our issue here
import Chart from '../../node_modules/chart.js/dist/Chart.bundle.min.js';
import Config from './Config.mjs';
import GetFromUrl from './Helpers/GetFromUrl.mjs';
import GetContainingElement from './Helpers/GetContainingElement.mjs';
import Postify from './Helpers/Postify.mjs';
import { human_duration_unit } from './Helpers/DateHelper.mjs';
import { human_duration_unit, round_date_interval } from './Helpers/DateHelper.mjs';
class DeviceReadingDisplay {
constructor(in_config, in_device_id) {
@ -26,8 +27,10 @@ class DeviceReadingDisplay {
// The number of points to display at a time.
this.points_resolution = 50;
this.start_time = moment().subtract(1, "days");
this.end_time = moment();
let date = new Date();
round_date_interval(date, Config.date_rounding_interval);
this.start_time = moment(date).subtract(1, "days");
this.end_time = moment(date);
this.default_colours = {