mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Fix some UI issues related to #988
This commit is contained in:
parent
96a202acdf
commit
9f7814d384
@ -35,10 +35,10 @@ def repeat_chain(iterable):
|
||||
|
||||
|
||||
def language_data(request, language_count=Language.objects.annotate(count=Count('submission'))):
|
||||
languages = language_count.filter(count__gt=0).values('key', 'name', 'count').order_by('-count')
|
||||
threshold = getattr(settings, 'DMOJ_STATS_LANGUAGE_THRESHOLD', 10)
|
||||
languages = language_count.filter(count__gte=threshold).values('key', 'name', 'count').order_by('-count')
|
||||
num_languages = len(languages)
|
||||
other_count = language_count.filter(count__lt=threshold).aggregate(total=Sum('count'))['total']
|
||||
num_languages = min(len(languages), threshold)
|
||||
other_count = sum(map(itemgetter('count'), languages[num_languages:]))
|
||||
|
||||
return JsonResponse({
|
||||
'labels': list(map(itemgetter('name'), languages)) + ['Other'],
|
||||
@ -46,7 +46,7 @@ def language_data(request, language_count=Language.objects.annotate(count=Count(
|
||||
{
|
||||
'backgroundColor': chart_colors[:num_languages] + ['#FDB45C'],
|
||||
'highlightBackgroundColor': highlight_colors[:num_languages] + ['#FFC870'],
|
||||
'data': list(map(itemgetter('count'), languages)) + [other_count],
|
||||
'data': list(map(itemgetter('count'), languages[:num_languages])) + [other_count],
|
||||
},
|
||||
],
|
||||
}, safe=False)
|
||||
|
@ -103,10 +103,19 @@
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
lineTension: 0,
|
||||
elements: {
|
||||
line: {
|
||||
tension: 0,
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
layout: {
|
||||
padding: {
|
||||
right: 10,
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
|
Loading…
Reference in New Issue
Block a user