Permalink
Browse files

...better. not perfect. X-axis now has human-readable datetimes.

  • Loading branch information...
stnbu committed Sep 3, 2018
1 parent bb45140 commit fcf0ce3eb7f9ba2de903fd8879bd84bca623590b
Showing with 11 additions and 20 deletions.
  1. +11 −20 coincharts/views.py
@@ -10,38 +10,29 @@
import svg_graph
def index(request, symbol_id):
prices = Prices.objects.filter(symbol_id=symbol_id)[:100]
# these make no sense. testing.
x_labels = svg_graph.GraphLabel('Year',
values=(2008, 2009, 2010, 2011, 2012),
padding=100)
y_labels = svg_graph.GraphLabel('Price',
values=(0, 5, 10, 15),
padding=100,
omit_zeroith=True)
prices = Prices.objects.filter(symbol_id=symbol_id)[:1000]
def string_to_epoch(string):
return time.mktime(parse_dt(string).timetuple())
def prices_gen(prices):
x = []
for p in prices:
x.append((string_to_epoch(p.time), int(p.price)))
x.append((p.time, int(p.price)))
return x
xyz = prices_gen(prices)
print('-'*100)
print(len(xyz))
print('-'*100)
title = '{} from {} to {}'.format(
symbol_id,
prices[0].time,
prices[len(prices)-1].time, # "negative indexing is not supported"
)
graph = svg_graph.LineGraph(
'Look at This Graph',
title,
height=580,
width=700,
points=xyz,
labels=[x_labels, y_labels]
width=1200,
points=prices_gen(prices),
linear_x=True
)
context = {

0 comments on commit fcf0ce3

Please sign in to comment.