multiple fixes for charts
This commit is contained in:
@@ -5,10 +5,11 @@
|
|||||||
|
|
||||||
tabButtons.map(function(button) {
|
tabButtons.map(function(button) {
|
||||||
button.addEventListener('click', function() {
|
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');
|
button.classList.add('active');
|
||||||
|
active = document.querySelector('.tab-pane.active')
|
||||||
document.querySelector('.tab-pane.active').classList.remove('active');
|
if (active) active.classList.remove('active');
|
||||||
document.querySelector(button.getAttribute('href')).classList.add('active');
|
document.querySelector(button.getAttribute('href')).classList.add('active');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Graph:
|
|||||||
y = []
|
y = []
|
||||||
|
|
||||||
with connection.cursor() as cursor:
|
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
|
(select date(datetime_valid) as day, max(datetime_valid) as last
|
||||||
from exchangerate WHERE crypto_currency = %s AND fiat_currency = %s
|
from exchangerate WHERE crypto_currency = %s AND fiat_currency = %s
|
||||||
AND datetime_valid >= %s
|
AND datetime_valid >= %s
|
||||||
@@ -28,7 +28,7 @@ class Graph:
|
|||||||
cursor.execute(sql, [Crypto, Fiat, startDate, Crypto, Fiat])
|
cursor.execute(sql, [Crypto, Fiat, startDate, Crypto, Fiat])
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
x.append(datetime.datetime.strptime(row[0], '%Y-%m-%d'))
|
x.append(row[0])
|
||||||
y.append(row[1])
|
y.append(row[1])
|
||||||
|
|
||||||
if len(x) == 0:
|
if len(x) == 0:
|
||||||
@@ -46,7 +46,7 @@ class Graph:
|
|||||||
marker='o', markerfacecolor='blue', markersize=2)
|
marker='o', markerfacecolor='blue', markersize=2)
|
||||||
|
|
||||||
loc = plticker.MultipleLocator(base=(len(x)/4.0))
|
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_xlabel("time")
|
||||||
ax.set_ylabel(Fiat)
|
ax.set_ylabel(Fiat)
|
||||||
@@ -84,7 +84,7 @@ class Graph:
|
|||||||
marker='o', markerfacecolor='blue', markersize=2)
|
marker='o', markerfacecolor='blue', markersize=2)
|
||||||
|
|
||||||
loc = plticker.MultipleLocator(base=(len(x)/5.0))
|
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_xlabel("time")
|
||||||
ax.set_ylabel(Fiat)
|
ax.set_ylabel(Fiat)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
<ul class="tab-nav">
|
<ul class="tab-nav">
|
||||||
<li>
|
<li>
|
||||||
<a class="button active" href="#h48{{ c.crypto }}">48 hours</a>
|
<a class="button" href="#h48{{ c.crypto }}">48 hours</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="button" href="#d3{{ c.crypto }}">3 days</a>
|
<a class="button" href="#d3{{ c.crypto }}">3 days</a>
|
||||||
@@ -68,17 +68,17 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="h48{{ c.crypto }}">
|
<div class="tab-pane" id="h48{{ c.crypto }}">
|
||||||
48 hours
|
48 hours
|
||||||
<img src="/graph?crypto={{ c.crypto }}&fiat=EUR&number_of_hours=48" loading="lazy">
|
<img src="/graph?crypto={{ c.crypto }}&fiat=EUR&number_of_hours=48" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="d3{{ c.crypto }}">
|
<div class="tab-pane" id="d3{{ c.crypto }}">
|
||||||
3 days
|
3 days
|
||||||
<img src="/graph?crypto={{ c.crypto }}&fiat=EUR&number_of_days=3" loading="lazy">
|
<img src="/graph?crypto={{ c.crypto }}&fiat=EUR&number_of_hours=72" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="w1{{ c.crypto }}">
|
<div class="tab-pane" id="w1{{ c.crypto }}">
|
||||||
1 week
|
1 week
|
||||||
<img src="/graph?crypto={{ c.crypto }}&fiat=EUR&number_of_days=7" loading="lazy">
|
<img src="/graph?crypto={{ c.crypto }}&fiat=EUR&number_of_hours=168" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="m1{{ c.crypto }}">
|
<div class="tab-pane" id="m1{{ c.crypto }}">
|
||||||
1 month
|
1 month
|
||||||
|
|||||||
Reference in New Issue
Block a user