Skip to content

Commit

Permalink
Fix the calculation of fake data and parsing data
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-42 committed Oct 10, 2016
1 parent bb7ff70 commit e92b61f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions ceagle/api_fake_data/cloud_status_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

def _gen_values(mode):
if mode == 1:
return [["24-Sep-16T%s:00" % i, random.uniform(0.9, 1)]
return [["2016-09-16T%s:00" % i, random.uniform(0.9997, 1)]
for i in range(24)]
elif mode == 2:
return [["24-Sep-16T%s:00" % i, random.randint(20, 2000)]
return [["2016-09-16T%s:00" % i, random.randint(20, 2000)]
for i in range(24)]
else:
return [["24-Sep-16T%s:00" % i, random.randint(100, 40000)]
return [["2016-09-16T%s:00" % i, random.randint(100, 40000)]
for i in range(24)]


Expand Down Expand Up @@ -94,20 +94,24 @@ def overview_data():


def availability_data():

data = [_gen_values(1) for i in range(3)]
data = map(lambda x: [x, sum(x_[1] for x_ in x)/len(x)], data)

return flask.jsonify(**{
"project_names": ["nova", "glance", "cinder"],
"projects": {
"nova": {
"availability": 1,
"availability_data": _gen_values(1)
"availability": data[0][1],
"availability_data": data[0][0]
},
"glance": {
"availability": 0.9,
"availability_data": _gen_values(1)
"availability": data[1][1],
"availability_data": data[1][0]
},
"cinder": {
"availability": 0.9995,
"availability_data": _gen_values(1)
"availability": data[2][1],
"availability_data": data[2][0]
},

}
Expand Down
4 changes: 2 additions & 2 deletions ceagle/static/js/angular-d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ angular.module('d3.line_chart')

var line_chart = function(svg, title){
var margin = {top: 15, right: 20, bottom: 20, left: 35}
var parse_date = d3.timeParse("%d-%b-%yT%H:%M");
var parse_date = d3.timeParse("%Y-%m-%dT%H:%M");

svg.attr("class", "line_chart")

Expand All @@ -66,7 +66,7 @@ var line_chart = function(svg, title){
var y = d3.scaleLinear().range([height, 0]);

x.domain(d3.extent(data, function(d) { return parse_date(d[0]); }));
y.domain(d3.extent(data, function(d) { return d[1]; }));
y.domain(d3.extent(data, function(d) { return d[1] }));

svg
.attr("width", width + margin.left + margin.right)
Expand Down

0 comments on commit e92b61f

Please sign in to comment.