Commit 3b8a95c9 authored by Zixian Cai's avatar Zixian Cai

Fix x axis of line plot and make it relative

parent 3ff2a9de
......@@ -19,6 +19,11 @@ import json
import os
def attach_info(log, stem):
log["revision"] = stem.split("_")[0]
log["timestamp"] = stem.split("_")[1]
class Storage:
pass
......@@ -31,7 +36,9 @@ class LocalStorage(Storage):
dirname = cls.STORAGE_PATH / repo / host
filename = dirname.glob("{}*".format(rev)).__next__()
with open(filename) as logfile:
return json.load(logfile)
l = json.load(logfile)
attach_info(l, str(filename.stem))
return l
@classmethod
def store(cls, repo, host, rev, timestamp, text_form):
......@@ -49,7 +56,9 @@ class LocalStorage(Storage):
key=lambda x: int(x.split("_")[1]))
filename = dirname / fs[-(1 + num)]
with open(filename) as logfile:
return json.load(logfile)
l = json.load(logfile)
attach_info(l, str(filename.stem))
return l
@classmethod
def load_all(cls, repo, host):
......@@ -60,5 +69,7 @@ class LocalStorage(Storage):
results = []
for f in fs:
with open(dirname / f) as logfile:
results.append(json.load(logfile))
l = json.load(logfile)
attach_info(l, str((dirname / f).stem))
results.append(l)
return results
......@@ -19,7 +19,7 @@
var d3 = Plotly.d3;
var WIDTH_IN_PERCENT_OF_PARENT = 100;
var HEIGHT_IN_PERCENT_OF_PARENT = 50;
var HEIGHT_IN_PERCENT_OF_PARENT = 80;
var gd3 = d3.select('#{{ elementID }}')
.style({
......
......@@ -21,9 +21,13 @@
var data = [];
{% for keyname in timeline %}
var trace = {type: "scatter"};
{% if "zebu" in keyname or "mu" in keyname %}
var trace = {type: "scatter"};
{% else %}
var trace = {type: "scatter", visible: 'legendonly'};
{% endif %}
var n = {{ timeline[keyname]|length }};
var x = Array.apply(null, {length: n}).map(Number.call, Number);
var x = {{ timeline_revisions|safe }};
var y = {{ timeline[keyname] }};
trace["x"] = x;
trace["y"] = y;
......
......@@ -29,6 +29,8 @@ def make_timeline(ops):
for op in ops:
group_stats_result(op)
extracts = [extract(x) for x in ops]
revisions = [op["revision"] for op in ops]
timestamp = [op["timestamp"] for op in ops]
results = defaultdict(dict)
for (idx, x) in enumerate(extracts):
for ts in x:
......@@ -41,5 +43,11 @@ def make_timeline(ops):
collect_dict = [None] * len(extracts)
for k1, v1 in v.items():
collect_dict[k1] = v1
results[k] = collect_dict
return results
ratio = [1] * len(extracts)
for i in range(1, len(extracts)):
if collect_dict[i - 1] is not None:
ratio[i] = collect_dict[i] / collect_dict[i - 1]
else:
ratio[i - 1] = 1
results[k] = ratio
return results, revisions
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment