Skip to content

Commit

Permalink
Clean up code for chart colors
Browse files Browse the repository at this point in the history
  • Loading branch information
int-y1 authored and quantum5 committed Aug 25, 2023
1 parent af8bf0c commit 7294d22
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions judge/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@
__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):
Expand Down

0 comments on commit 7294d22

Please sign in to comment.