forked from CGM_Public/pretix_original
Improve stats-UI fix (#5243)
* Improve stats-UI fix * remove unused stats_json
This commit is contained in:
committed by
GitHub
parent
dec07b2df1
commit
7bb2e4c170
@@ -59,7 +59,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" id="question-stats">
|
<div class="row">
|
||||||
{% if not stats %}
|
{% if not stats %}
|
||||||
<div class="empty-collection col-md-10 col-xs-12">
|
<div class="empty-collection col-md-10 col-xs-12">
|
||||||
<p>
|
<p>
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
<div class="chart" id="question_chart" data-type="{{ question.type }}">
|
<div class="chart" id="question_chart" data-type="{{ question.type }}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script type="application/json" id="question-chart-data">{{ stats_json|escapejson }}</script>
|
{{ stats|json_script:"question-chart-data" }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5 col-xs-12">
|
<div class="col-md-5 col-xs-12">
|
||||||
<table class="table table-bordered table-hover">
|
<table class="table table-bordered table-hover">
|
||||||
|
|||||||
@@ -748,7 +748,6 @@ class QuestionView(EventPermissionRequiredMixin, QuestionMixin, ChartContainingV
|
|||||||
ctx['items'] = self.object.items.all()
|
ctx['items'] = self.object.items.all()
|
||||||
stats = self.get_answer_statistics()
|
stats = self.get_answer_statistics()
|
||||||
ctx['stats'], ctx['total'] = stats
|
ctx['stats'], ctx['total'] = stats
|
||||||
ctx['stats_json'] = json.dumps(stats)
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def get_object(self, queryset=None) -> Question:
|
def get_object(self, queryset=None) -> Question:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*global $, Morris, gettext*/
|
/*global $, Morris, gettext*/
|
||||||
$(function () {
|
$(function () {
|
||||||
// Question view
|
// Question view
|
||||||
if (!$("#question-stats").length) {
|
if (!$("#question_chart").length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,12 +11,12 @@ $(function () {
|
|||||||
others_sum = 0,
|
others_sum = 0,
|
||||||
max_num = 8;
|
max_num = 8;
|
||||||
|
|
||||||
data = data[0]?.map(function (d) {
|
data = data.map(function (d) {
|
||||||
return {
|
return {
|
||||||
'value': d.count,
|
'value': d.count,
|
||||||
'label': d.answer.length > 20 ? d.answer.substring(0, 20) + '…' : d.answer,
|
'label': d.answer.length > 20 ? d.answer.substring(0, 20) + '…' : d.answer,
|
||||||
}
|
}
|
||||||
}) || [];
|
});
|
||||||
|
|
||||||
if (data_type == 'N') {
|
if (data_type == 'N') {
|
||||||
// Sort
|
// Sort
|
||||||
|
|||||||
Reference in New Issue
Block a user