def domain_charts(request): context = {} mychartgroup = utils.get_chart_group(request.user) if mychartgroup == None: return summary_trend(request) else: return view_group(request, mychartgroup.id)
def view_graph(request, graph_id, template_name="graphing/view_graph.html"): context = {} graph = RawGraph.objects.all().get(id=graph_id) #get the root group # inject some stuff into the rawgraph. we can also do more # here but for now we'll just work with the domain and set # some dates. these can be templated down to the sql graph.domain = request.user.selected_domain.name startdate, enddate = utils.get_dates(request, graph.default_interval) graph.startdate = startdate.strftime("%Y-%m-%d") graph.enddate = (enddate + timedelta(days=1)).strftime("%Y-%m-%d") context['chart_title'] = graph.title context['chart_data'] = graph.get_flot_data() context['thegraph'] = graph rootgroup = utils.get_chart_group(request.user) graphtree = get_graphgroup_children(rootgroup) context['graphtree'] = graphtree context['view_name'] = 'graphing.views.view_graph' context['width'] = graph.width context['height'] = graph.height context['empty_dict'] = {} context['datatable'] = graph.convert_data_to_table(context['chart_data']) for item in request.GET.items(): if item[0] == 'bare': template_name = 'graphing/view_graph_bare.html' elif item[0] == 'data': template_name='graphing/view_graph_data.html' elif item[0] == 'csv': return _get_chart_csv(graph) return render_to_response(request, template_name, context)
def view_group(request, group_id, template_name="graphing/view_group.html"): context = {} group = GraphGroup.objects.all().get(id=group_id) context['group'] = group context['group_charts'] = [] context['width'] = 900 context['height'] = 350 for thegraph in group.graphs.all(): if hasattr(thegraph,'rawgraph'): context['group_charts'].append(thegraph.rawgraph) else: context['group_charts'].append(thegraph) context['child_groups'] = GraphGroup.objects.all().filter(parent_group=group) rootgroup = utils.get_chart_group(request.user) graphtree = get_graphgroup_children(rootgroup) context['graphtree'] = graphtree return render_to_response(request, template_name, context)