def gen_institutes_trend(self, start, end, machine_category): start_str = start.strftime('%Y-%m-%d') end_str = end.strftime('%Y-%m-%d') i_start = start i_end = end for i in Institute.active.all(): start = i_start end = i_end rows = get_insitutes_trend(i, start, end, machine_category) i_data, i_colours = smooth_data(rows, start, end) x = gdchart.Line() x.width = 700 x.height = 350 x.bg_color = "white" x.xtitle = "Days" x.ytitle = "CPU Time (hours)" x.title = '%s - %s-%s' % (i.name, start_str, end_str) x.grid = "NONE" x.setData(i_data) x.draw("%s/i_trends/%s_%s_%s-trend.png" % (settings.GRAPH_ROOT, i.name.replace(' ', '').lower(), start_str, end_str))
def gen_institute_bar(self, institute, start, end, machine_category): """Generates a bar graph showing the trend usage for an institute Keyword arguments: institute -- Institute start -- start date end -- end date machine_category -- MachineCategory object """ start_str = start.strftime('%Y-%m-%d') end_str = end.strftime('%Y-%m-%d') x = gdchart.Bar() x.width = 700 x.height = 350 x.bg_color = "white" x.xtitle = "Days" x.ytitle = "CPU Time (hours)" x.title = '%s - %s-%s' % (institute.name, start_str, end_str) x.grid = "NONE" rows = get_insitutes_trend(institute, start, end, machine_category) data, colours = smooth_data(rows, start, end) x.ext_color = colours x.setData(data) #x.setComboData(data) try: x.draw("%s/institutes/bar_%s_%s-%s_%i.png" % (settings.GRAPH_ROOT, institute.id, start_str, end_str, machine_category.id)) except: pass