def create_round_meter_chart(selected_dealer, term, checkpoint, value): angular_meter = AngularMeter(100, 100, silverColor(), '0x000000', -2) angular_meter.setRoundedFrame() angular_meter.setMeter(50, 50, 45, -135, 135) angular_meter.setScale(0, 100, 10, 5, 1) angular_meter.setLabelStyle("normal", 7) angular_meter.setLineWidth(0, 2, 1) angular_meter.addRing(0, 90, metalColor('0x9999dd')) angular_meter.addRing(88, 90, '0x6666ff') angular_meter.addZone(0, 60, '0x99ff99') angular_meter.addZone(60, 80, '0xffff00') angular_meter.addZone(80, 100, '0xff3333') angular_meter.addText(50, 70, u"总分", "simsun.ttc", 8, TextColor, Center) angular_meter.addText(50, 85, angular_meter.formatValue(value, "1"), "Arial", 8, '0xffffff', Center).setBackground('0x000000', '0x000000', -1) angular_meter.addPointer(value, '0x40333399') file_name = "round_meter_%s_%s_%s_%s.png" % ( selected_dealer.id, term.id, checkpoint.id, utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) data = angular_meter.makeChart2(PNG) file(save_as, 'wb').write(data) return file_name
def create_sub_checkpoint_chart(checkpoint_group, dealer, term, score, data, data_last=None): labels = [cp.name + '. ' + cp.desc for cp in checkpoint_group.child_list] title = checkpoint_group.desc file_name = "sub_checkpoint_%s_%s_%s_%s.png" % ( checkpoint_group.id, dealer.id, term.id, utils.get_verify_code2( term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_row_xychart(title,labels,data,mark_value=score,format='{value|1}') new_labels = [truncate_hanzi(label, 25) for label in labels] chart_height = 60 + 20 * len(new_labels) data = create_bar_line_xychart(title, new_labels, data, data_last, mark_value=score, swapxy=True, x=860, y=chart_height) file(save_as, 'wb').write(data) return file_name
def create_region2_score_chart(term, selected_dealer, report_nation, labels, data): title = u'小区总得分' file_name = 'region2_score_%s_%s_%s.png' % ( term.id, selected_dealer.id, utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_xychart(title,labels,data,mark_value=report_nation.score,format='{value|1}',fontAngle=90) if term.id > 1: term_last = mc.get_term(term.id - 1) report_nationLine, labelsLine, other_labelLine, dataLine = mc.get_region2_score_chart_data( term_last) data = create_bar_line_xychart(title, labels, data, dataLine, mark_value=report_nation.score, format='{value|1}', swapxy=True, y=600) else: data = create_bar_line_xychart(title, labels, data, mark_value=report_nation.score, format='{value|1}', swapxy=True, y=600) file(save_as, 'wb').write(data) return file_name
def create_dealer_score_group_by_chart(term, labels, parent_name, data): title = u'经销商得分分布情况' file_name = 'dealer_score_group_by_%s_%s_%s.png' % ( term.id, parent_name, utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_xychart(title,labels,data,mark_value=None,format='{value|1}%') if term.id > 1: term_last = mc.get_term(term.id - 1) dataLine, labels_last = mc.get_dealer_score_group_by(term_last) data = create_bar_line_xychart(title, labels, data, dataLine, mark_value=None, format='{value|1}%') else: data = create_bar_line_xychart(title, labels, data, mark_value=None, format='{value|1}%') file(save_as, 'wb').write(data) return file_name
def create_dealer_score_chart(dealer, term): cp_list = mc.get_checkpoint_group_list_with_total() data = mc.get_dealer_score(term, dealer) #labels = [cp.name_abbr for cp in cp_list] labels = [add_line_break(cp.name_abbr, 4) for cp in cp_list] labels = [add_line_break(label, 9) for label in labels] file_name = 'dealer_score_%s_%s_%s.png' % ( dealer.id, term.id, utils.get_verify_code2(dealer.id, term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) title = u'总得分与环节得分' if term.id > 1: term_last = mc.get_term(term.id - 1) dataLine = mc.get_dealer_score(term_last, dealer) data = create_bar_line_xychart(title, labels, data, dataLine, mark_value=data[0]) else: data = create_bar_line_xychart(title, labels, data, mark_value=data[0]) file(save_as, 'wb').write(data) return file_name
def create_cp_chart(dealer,term,cp,labels,data,data_last=None): if cp: title = cp.desc+u"得分对比" else: title = "总得分对比" file_name = "cp_chart_%s_%s_%s_%s.png" %(cp.id,term.id,dealer.id,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_row_xychart(title,labels,data,format='{value|1}',width=420) data = create_bar_line_xychart(title,labels,data,data_last,x=420,swapxy=True,legendVertical=True) file(save_as,'wb').write(data) return file_name
def create_region3_score_chart(term,selected_dealer,labels,data,data_last=None): title = u'环节得分' labels = [add_line_break(label,8) for label in labels] file_name = 'region3_score_%s_%s_%s.png' % (term.id,selected_dealer.id,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) if data_last: data = create_bar_line_xychart(title,labels,data,data_last,swapxy=True,x=400,y=330,format='{value|1}',legendVertical=True) else: data = create_bar_line_xychart(title,labels,data,swapxy=True,x=400,y=330,format='{value|1}',legendVertical=True) file(save_as,'wb').write(data) return file_name
def create_region2_score_chart(term,selected_dealer,report_nation,labels,data): title = u'小区总得分' file_name = 'region2_score_%s_%s_%s.png' % (term.id,selected_dealer.id,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_xychart(title,labels,data,mark_value=report_nation.score,format='{value|1}',fontAngle=90) if term.id > 1: term_last = mc.get_term(term.id-1) report_nationLine,labelsLine,other_labelLine,dataLine = mc.get_region2_score_chart_data(term_last) data = create_bar_line_xychart(title,labels,data,dataLine,mark_value=report_nation.score,format='{value|1}',swapxy=True,y=600) else: data = create_bar_line_xychart(title,labels,data,mark_value=report_nation.score,format='{value|1}',swapxy=True,y=600) file(save_as,'wb').write(data) return file_name
def create_dealer_score_group_by_chart(term,labels,parent_name,data): title = u'经销商得分分布情况' file_name = 'dealer_score_group_by_%s_%s_%s.png' % (term.id,parent_name,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_xychart(title,labels,data,mark_value=None,format='{value|1}%') if term.id > 1: term_last = mc.get_term(term.id-1) dataLine,labels_last = mc.get_dealer_score_group_by(term_last) data = create_bar_line_xychart(title,labels,data,dataLine,mark_value=None,format='{value|1}%') else: data = create_bar_line_xychart(title,labels,data,mark_value=None,format='{value|1}%') file(save_as,'wb').write(data) return file_name
def create_dealer_index_chart(labels, checkpoint_group, selected_dealer, term, score): file_name = "dealer_index_%s_%s_%s_%s.png" % ( checkpoint_group.id, selected_dealer.id, term.id, utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) title = u'环节得分比较' data = create_dealer_index_xychart(title, labels, score, mark_value=score, format='{value|1}') file(save_as, 'wb').write(data) return file_name
def create_dealer_score_chart(dealer,term): cp_list = mc.get_checkpoint_group_list_with_total() data = mc.get_dealer_score(term,dealer) #labels = [cp.name_abbr for cp in cp_list] labels = [add_line_break(cp.name_abbr,4) for cp in cp_list] labels = [add_line_break(label,9) for label in labels] file_name = 'dealer_score_%s_%s_%s.png' % (dealer.id,term.id,utils.get_verify_code2(dealer.id,term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) title = u'总得分与环节得分' if term.id > 1: term_last = mc.get_term(term.id-1) dataLine = mc.get_dealer_score(term_last,dealer) data = create_bar_line_xychart(title,labels,data,dataLine,mark_value=data[0]) else: data = create_bar_line_xychart(title,labels,data,mark_value=data[0]) file(save_as,'wb').write(data) return file_name
def create_cp_chart(dealer, term, cp, labels, data, data_last=None): if cp: title = cp.desc + u"得分对比" else: title = "总得分对比" file_name = "cp_chart_%s_%s_%s_%s.png" % (cp.id, term.id, dealer.id, utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_row_xychart(title,labels,data,format='{value|1}',width=420) data = create_bar_line_xychart(title, labels, data, data_last, x=420, swapxy=True, legendVertical=True) file(save_as, 'wb').write(data) return file_name
def create_region3_score_chart(term, selected_dealer, labels, data, data_last=None): title = u'环节得分' labels = [add_line_break(label, 8) for label in labels] file_name = 'region3_score_%s_%s_%s.png' % ( term.id, selected_dealer.id, utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT, file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) if data_last: data = create_bar_line_xychart(title, labels, data, data_last, swapxy=True, x=400, y=330, format='{value|1}', legendVertical=True) else: data = create_bar_line_xychart(title, labels, data, swapxy=True, x=400, y=330, format='{value|1}', legendVertical=True) file(save_as, 'wb').write(data) return file_name
def create_round_meter_chart(selected_dealer,term,checkpoint,value): angular_meter = AngularMeter(100,100,silverColor(),'0x000000', -2) angular_meter.setRoundedFrame() angular_meter.setMeter(50,50,45,-135,135) angular_meter.setScale(0,100,10,5,1) angular_meter.setLabelStyle("normal",7) angular_meter.setLineWidth(0, 2, 1) angular_meter.addRing(0, 90, metalColor('0x9999dd')) angular_meter.addRing(88, 90, '0x6666ff') angular_meter.addZone(0, 60, '0x99ff99') angular_meter.addZone(60, 80, '0xffff00') angular_meter.addZone(80, 100, '0xff3333') angular_meter.addText(50, 70, u"总分", "simsun.ttc", 8,TextColor, Center) angular_meter.addText(50, 85, angular_meter.formatValue(value, "1"),"Arial", 8, '0xffffff', Center ).setBackground('0x000000', '0x000000', -1) angular_meter.addPointer(value, '0x40333399') file_name = "round_meter_%s_%s_%s_%s.png" %(selected_dealer.id,term.id,checkpoint.id,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) data = angular_meter.makeChart2(PNG) file(save_as,'wb').write(data) return file_name
def create_dealer_index_chart(labels,checkpoint_group,selected_dealer,term,score): file_name = "dealer_index_%s_%s_%s_%s.png" %(checkpoint_group.id,selected_dealer.id,term.id,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) title = u'环节得分比较' data = create_dealer_index_xychart(title,labels,score,mark_value=score,format='{value|1}') file(save_as,'wb').write(data) return file_name
def create_sub_checkpoint_chart(checkpoint_group,dealer,term,score,data,data_last=None): labels = [cp.name+'. '+cp.desc for cp in checkpoint_group.child_list] title = checkpoint_group.desc file_name = "sub_checkpoint_%s_%s_%s_%s.png" %(checkpoint_group.id,dealer.id,term.id,utils.get_verify_code2(term.id)) save_as = '%s/shouhou/static/mcview/chart/%s' % (settings.SITE_ROOT,file_name) if not os.path.exists(os.path.dirname(save_as)): os.makedirs(os.path.dirname(save_as)) #data = create_simple_row_xychart(title,labels,data,mark_value=score,format='{value|1}') new_labels = [truncate_hanzi(label,25) for label in labels] chart_height = 60+20*len(new_labels) data = create_bar_line_xychart(title,new_labels,data,data_last,mark_value=score,swapxy=True,x=860,y=chart_height) file(save_as,'wb').write(data) return file_name