def create_pie_chart (input_dict, input_colors, suffix, special_item_key=None) :
if special_item_key != None :
special_item = dict()
special_item[special_item_key] = 0
output_text = u'{{#invoke:Chart|pie chart\n' \
u'| radius = 180\n' \
u'| slices = \n'
input_dict = dict(input_dict)
sorted_dict = OrderedDict(sorted(input_dict.items(), key=itemgetter(1), reverse=True))
for key, value in sorted_dict.iteritems() :
if special_item_key == None or key != special_item_key :
output_text += u' ( %d: %s : %s)\n' %(value, key, input_colors[key])
else :
special_item[special_item_key] = value
if special_item_key != None :
output_text += u' ( %d: %s : %s)\n' % (special_item[special_item_key], special_item_key, input_colors[special_item_key])
output_text += u'| units suffix = _%s\n' \
u'| percent = true\n' \
u'}}\n' %(suffix)
return output_text
评论列表
文章目录