From c3022317cfe022196c4120fd154839105b74a141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Thu, 29 Nov 2012 16:11:35 -0200 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=B5es=20e=20mudan=C3=A7as=20na=20?= =?UTF-8?q?gera=C3=A7=C3=A3o=20de=20gr=C3=A1ficos=20do=20diagn=C3=B3stico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/diagnosticos/models.py | 2 +- sigi/apps/diagnosticos/views.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sigi/apps/diagnosticos/models.py b/sigi/apps/diagnosticos/models.py index 9f9593a..791e1b7 100644 --- a/sigi/apps/diagnosticos/models.py +++ b/sigi/apps/diagnosticos/models.py @@ -163,7 +163,7 @@ class Pergunta(BaseSchema): cursor.execute(""" SELECT choice_id, sum(1) FROM diagnosticos_resposta - WHERE schema_id=%s + WHERE schema_id=%s and choice_id is not null GROUP BY choice_id; """, [self.id]) diff --git a/sigi/apps/diagnosticos/views.py b/sigi/apps/diagnosticos/views.py index 555aad1..98773d6 100644 --- a/sigi/apps/diagnosticos/views.py +++ b/sigi/apps/diagnosticos/views.py @@ -289,8 +289,8 @@ def grafico_api(request): graph_params = QueryDict("") graph_params = graph_params.copy() # to make it mutable - width = request.REQUEST.get('width', '300') - height = request.REQUEST.get('height', '200') + width = request.REQUEST.get('width', '800') + height = request.REQUEST.get('height', '300') graph_params.update({'chs': width + 'x' + height}) pergunta_slug = request.REQUEST.get('id', None) @@ -310,12 +310,17 @@ def grafico_api(request): percent = [str(float(r[1])*100/total) for r in pergunta.group_choices()] choices = [str(r[1]) for r in pergunta.group_choices()] legend = [str(r[0]) for r in pergunta.group_choices()] +# colors = [reduce(lambda x,y: x + hex(y).replace('0x',''), map(lambda x: x*(100-(p*10))/100,[0xff, 0xcc,0x33]),'') +# for p in range(0,len(pergunta.group_choices()))] + colors = ["%0.6x" % (0x48d1 + (0xda74 * c)) + for c in range(0,len(pergunta.group_choices()))] graph_params.update({ 'cht': 'bvg', 'chxt': 'y', 'chd': 't:' + ",".join(percent), 'chdl': '' + "|".join(legend), 'chl': '' + "|".join(choices), + 'chco': '' + "|".join(colors) }) response = {