From 37f0ea7de7125084bca9ff1b7b3991c83abf3e6f Mon Sep 17 00:00:00 2001 From: "Steve Nyemba, The Architect" Date: Mon, 29 Oct 2018 17:52:11 -0500 Subject: [PATCH] bug fix with layout --- src/api/index.py | 12 +++++++----- src/utils/charting.py | 6 +++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/api/index.py b/src/api/index.py index 1b54e3b..badda77 100755 --- a/src/api/index.py +++ b/src/api/index.py @@ -1102,8 +1102,8 @@ def prepare_plot(id): # X.append(np.random.choice(100,4).tolist()) - q = [{"info":"Monitoring RAM consumption trends","ylabel":"% used","node":node,"x":XRAM,"labels":np.arange(1,xn).tolist(),"series":names,"title":"RAM Usage"}] - q.append({"info":"Monitoring CPU consumption trends","ylabel":"% used","node":node,"x":XCPU,"labels":np.arange(1,xn_).tolist(),"series":names,"title":"CPU Usage"}) + q = [{"info":"Monitoring RAM consumption trends","ylabel":"% used","node":node, "x":XRAM,"labels":np.arange(1,xn).tolist(),"series":names,"title":"RAM Usage"}] + q.append({"info":"Monitoring CPU consumption trends","ylabel":"% used","node":node,"type":"bar","x":XCPU,"labels":np.arange(1,xn_).tolist(),"series":names,"title":"CPU Usage"}) key = 'app.trend.'+node session[key] = q return (key,200) @@ -1120,14 +1120,16 @@ def get_charts(format,id,key): series = ['series_1'] args = session[key] - if isinstance(args,list) and 'index' in request.args: - index = int(request.args['index']) - args = args[index] + if isinstance(args,list) is False: args['remove'] = remove info = [Graph.instance(format,id,**args)] else: # print args info = [ Graph.instance(format,id, **dict(item,**{'remove':remove})) for item in args] + if 'index' in request.args : + index = int(request.args['index']) + args = args[index] + # if remove is not None : # args['remove'] = remove diff --git a/src/utils/charting.py b/src/utils/charting.py index e7571b7..41838f3 100644 --- a/src/utils/charting.py +++ b/src/utils/charting.py @@ -145,10 +145,14 @@ class HTMLGraph(Graph): for row in X : - index = X.index(row) + index = X.index(row) name = series[index] dataset = {"label":name,"fill":False,"backgroundColor":Graph.COLORS[index],"borderColor":Graph.COLORS[index],"data":row} config["data"]["datasets"].append(dataset) + if 'type' in self.args : + config['type'] = self.args['type'] + else : + config['type'] = 'line' return config