From 827785eb1fe7f2513bfb373b3cc4c9e0a7bfb18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Wed, 27 Feb 2013 16:38:29 -0300 Subject: [PATCH] =?UTF-8?q?Altera=C3=A7=C3=A3o=20no=20padr=C3=A3o=20de=20c?= =?UTF-8?q?ores=20dos=20gr=C3=A1ficos=20do=20SIGI=20a=20pedido=20da=20Patr?= =?UTF-8?q?=C3=ADcia/Liliane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/diagnosticos/views.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sigi/apps/diagnosticos/views.py b/sigi/apps/diagnosticos/views.py index 98773d6..ae89ce6 100644 --- a/sigi/apps/diagnosticos/views.py +++ b/sigi/apps/diagnosticos/views.py @@ -284,6 +284,8 @@ def percentage(fraction, population): return '' def grafico_api(request): + colors = ['ffff00', 'cc7900', 'ff0000', '92d050', '006600', '0097cc', '002776', 'ae78d6', 'ff00ff', '430080', + '28d75c', '0000ff', 'fff200'] graph_url = "http://chart.apis.google.com/chart" #graph_params = QueryDict("chxt=y&chbh=a&chco=A2C180,3D7930") graph_params = QueryDict("") @@ -300,27 +302,28 @@ def grafico_api(request): total = sum([r[1] for r in pergunta.group_choices()]) choices = [str(r[1]) for r in pergunta.group_choices()] legend = [percentage(r[1],total) + " " + str(r[0]) for r in pergunta.group_choices()] + colors = ['ff0000', 'fff200', '0000ff', '28d75c'] + ["%0.6x" % (0x48d1 + (0xda74 * c)) + for c in range(0,len(pergunta.group_choices()))] graph_params.update({ 'cht': 'p', 'chd': 't:' + ",".join(choices), 'chdl': '' + "|".join(legend), + 'chco': '' + '|'.join(colors[:len(pergunta.group_choices())]) }) elif pergunta.datatype == 'many': total = sum([r[1] for r in pergunta.group_choices()]) 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()))] + colors = ['ffff00', 'cc7900', 'ff0000', '92d050', '006600', '0097cc', '002776', 'ae78d6', 'ff00ff', '430080'] + \ + ["%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) + 'chco': '' + '|'.join(colors[:len(pergunta.group_choices())]) }) response = {