1717from zoomeye import config
1818
1919
20- def char_by_atan (stat , at , color ):
20+ def char_by_atan (stat , at , color ):#用于根据给定的百分比值(at)和颜色(color),返回相应的字符,用于绘制饼状图的每个部分
2121 """
2222 :param stat: list, all data and label
2323 :param at: float, percentage
@@ -31,7 +31,7 @@ def char_by_atan(stat, at, color):
3131 return char_by_atan (stat [1 :], at - stat [0 ][1 ], color [1 :])
3232
3333
34- def show_pie_chart (stat ):
34+ def show_pie_chart (stat ):#用于显示饼状图
3535 """
3636 print pie chart in terminal
3737 :param stat: list, all data and label
@@ -65,7 +65,7 @@ def show_pie_chart(stat):
6565 count += 1
6666
6767
68- def unicode_output ():
68+ def unicode_output ():#用于检查当前的标准输出是否支持Unicode
6969 """
7070 unicode standard output
7171 """
@@ -75,7 +75,7 @@ def unicode_output():
7575 )
7676
7777
78- def trim_zeros (lst ):
78+ def trim_zeros (lst ):#用于去除列表(lst)末尾的零元素
7979 """
8080
8181 """
@@ -87,7 +87,7 @@ def trim_zeros(lst):
8787 return lst [:- k ] if k > 0 else lst
8888
8989
90- def get_matrix (counts , max_size , bar_width ):
90+ def get_matrix (counts , max_size , bar_width ):#用于生成直方图的矩阵表示,用于绘制直方图
9191 """
9292 get the length of the histogram corresponding to each data
9393 :param counts: list, all data
@@ -117,7 +117,7 @@ def get_matrix(counts, max_size, bar_width):
117117 return out
118118
119119
120- def generate_histogram (values , labels = None , force_ascii = False ):
120+ def generate_histogram (values , labels = None , force_ascii = False ):#用于生成直方图
121121 """
122122 print histogram in terminal
123123 take the largest data as the standard, that is, the largest data is the longest
@@ -134,20 +134,20 @@ def generate_histogram(values, labels=None, force_ascii=False):
134134 else :
135135 chars = [" " , "#" , "#" , "#" , "#" , "#" , "#" , "#" , "#" ]
136136
137- ft = []
137+ fmt = []
138138 if labels is not None :
139139 cfmt = "{{:{}s}}" .format (max ([len (str (label )) for label in labels ]))
140- ft .append (cfmt )
140+ fmt .append (cfmt )
141141 # show values
142142 all_int = all (val == int (val ) for val in values )
143143 if all_int :
144144 cfmt = "{{:{}d}}" .format (max ([len (str (val )) for val in values ]))
145145 else :
146146 cfmt = "{}"
147- ft .append ("[" + cfmt + "]" )
147+ fmt .append ("[" + cfmt + "]" )
148148
149- ft .append ("{}" )
150- ft = " " .join (ft )
149+ fmt .append ("{}" )
150+ fmt = " " .join (fmt )
151151
152152 out = []
153153 for k , (val , row ) in enumerate (zip (values , matrix )):
@@ -159,7 +159,7 @@ def generate_histogram(values, labels=None, force_ascii=False):
159159 # cut off trailing zeros
160160 r = trim_zeros (row )
161161 data .append ("" .join (chars [item ] for item in r ))
162- out .append (ft .format (* data ))
162+ out .append (fmt .format (* data ))
163163 for item in out :
164164 print (' ' + item )
165165
0 commit comments