mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Clean up code for chart colors
This commit is contained in:
parent
af8bf0cd01
commit
7294d223a2
@ -3,25 +3,17 @@ from operator import itemgetter
|
||||
__all__ = ('chart_colors', 'highlight_colors', 'get_pie_chart', 'get_bar_chart')
|
||||
|
||||
|
||||
chart_colors = [0x3366CC, 0xDC3912, 0xFF9900, 0x109618, 0x990099, 0x3B3EAC, 0x0099C6, 0xDD4477, 0x66AA00, 0xB82E2E,
|
||||
0x316395, 0x994499, 0x22AA99, 0xAAAA11, 0x6633CC, 0xE67300, 0x8B0707, 0x329262, 0x5574A6, 0x3B3EAC]
|
||||
BASE_COLORS = [0x3366CC, 0xDC3912, 0xFF9900, 0x109618, 0x990099, 0x3B3EAC, 0x0099C6, 0xDD4477, 0x66AA00, 0xB82E2E,
|
||||
0x316395, 0x994499, 0x22AA99, 0xAAAA11, 0x6633CC, 0xE67300, 0x8B0707, 0x329262, 0x5574A6, 0x3B3EAC]
|
||||
|
||||
|
||||
highlight_colors = []
|
||||
def _to_highlight_color(color):
|
||||
r, g, b = color >> 16, (color >> 8) & 0xFF, color & 0xFF
|
||||
return '#%02X%02X%02X' % (min(int(r * 1.2), 255), min(int(g * 1.2), 255), min(int(b * 1.2), 255))
|
||||
|
||||
|
||||
def _highlight_colors():
|
||||
for color in chart_colors:
|
||||
r, g, b = color >> 16, (color >> 8) & 0xFF, color & 0xFF
|
||||
highlight_colors.append('#%02X%02X%02X' % (min(int(r * 1.2), 255),
|
||||
min(int(g * 1.2), 255),
|
||||
min(int(b * 1.2), 255)))
|
||||
|
||||
|
||||
_highlight_colors()
|
||||
|
||||
|
||||
chart_colors = list(map('#%06X'.__mod__, chart_colors))
|
||||
chart_colors = list(map('#%06X'.__mod__, BASE_COLORS))
|
||||
highlight_colors = list(map(_to_highlight_color, BASE_COLORS))
|
||||
|
||||
|
||||
def get_pie_chart(data):
|
||||
|
Loading…
Reference in New Issue
Block a user