From 72baf5fc242e6be089a7667cc266933ae25f2328 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Sun, 24 Jan 2021 22:55:29 +0100 Subject: [PATCH] multiple fixes for charts --- apps/core/static/js/skeleton-tabs.js | 7 ++++--- apps/monitor/graph.py | 8 ++++---- apps/monitor/templates/monitor.html | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/core/static/js/skeleton-tabs.js b/apps/core/static/js/skeleton-tabs.js index 27b1360..04e50e1 100644 --- a/apps/core/static/js/skeleton-tabs.js +++ b/apps/core/static/js/skeleton-tabs.js @@ -5,10 +5,11 @@ tabButtons.map(function(button) { button.addEventListener('click', function() { - document.querySelector('li a.active.button').classList.remove('active'); + active = document.querySelector('li a.active.button') + if (active) active.classList.remove('active'); button.classList.add('active'); - - document.querySelector('.tab-pane.active').classList.remove('active'); + active = document.querySelector('.tab-pane.active') + if (active) active.classList.remove('active'); document.querySelector(button.getAttribute('href')).classList.add('active'); }) }) diff --git a/apps/monitor/graph.py b/apps/monitor/graph.py index b923280..6d8c3b2 100644 --- a/apps/monitor/graph.py +++ b/apps/monitor/graph.py @@ -15,7 +15,7 @@ class Graph: y = [] with connection.cursor() as cursor: - sql = """SELECT date(datetime_valid), rate FROM + sql = """SELECT datetime_valid, rate FROM (select date(datetime_valid) as day, max(datetime_valid) as last from exchangerate WHERE crypto_currency = %s AND fiat_currency = %s AND datetime_valid >= %s @@ -28,7 +28,7 @@ class Graph: cursor.execute(sql, [Crypto, Fiat, startDate, Crypto, Fiat]) rows = cursor.fetchall() for row in rows: - x.append(datetime.datetime.strptime(row[0], '%Y-%m-%d')) + x.append(row[0]) y.append(row[1]) if len(x) == 0: @@ -46,7 +46,7 @@ class Graph: marker='o', markerfacecolor='blue', markersize=2) loc = plticker.MultipleLocator(base=(len(x)/4.0)) - ax.xaxis.set_major_locator(loc) + #ax.xaxis.set_major_locator(loc) ax.set_xlabel("time") ax.set_ylabel(Fiat) @@ -84,7 +84,7 @@ class Graph: marker='o', markerfacecolor='blue', markersize=2) loc = plticker.MultipleLocator(base=(len(x)/5.0)) - ax.xaxis.set_major_locator(loc) + #ax.xaxis.set_major_locator(loc) ax.set_xlabel("time") ax.set_ylabel(Fiat) diff --git a/apps/monitor/templates/monitor.html b/apps/monitor/templates/monitor.html index 50d5652..67bc91c 100644 --- a/apps/monitor/templates/monitor.html +++ b/apps/monitor/templates/monitor.html @@ -49,7 +49,7 @@
-
+
48 hours
3 days - +
1 week - +
1 month