forked from CGM_Public/pretix_original
Statistics: Ellipsize long product names
This commit is contained in:
@@ -34,10 +34,23 @@ $(function () {
|
|||||||
new Morris.Bar({
|
new Morris.Bar({
|
||||||
element: 'obp_chart',
|
element: 'obp_chart',
|
||||||
data: JSON.parse($("#obp-data").html()),
|
data: JSON.parse($("#obp-data").html()),
|
||||||
xkey: 'item',
|
xkey: 'item_short',
|
||||||
ykeys: ['ordered', 'paid'],
|
ykeys: ['ordered', 'paid'],
|
||||||
labels: [gettext('Placed orders'), gettext('Paid orders')],
|
labels: [gettext('Placed orders'), gettext('Paid orders')],
|
||||||
barColors: ['#3b1c4a', '#50a167'],
|
barColors: ['#3b1c4a', '#50a167'],
|
||||||
|
hoverCallback: function (index, options, content, row) {
|
||||||
|
console.log(content);
|
||||||
|
var $c = $("<div>" + content + "</div>");
|
||||||
|
var $label = $c.find(".morris-hover-row-label");
|
||||||
|
$label.text(row.item);
|
||||||
|
var newc = $label.get(0).outerHTML;
|
||||||
|
$c.find('.morris-hover-point').each(function (i, r) {
|
||||||
|
if ($.trim($(r).text().split("\n")[2]) !== "0") {
|
||||||
|
newc += r.outerHTML;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return newc;
|
||||||
|
},
|
||||||
resize: true,
|
resize: true,
|
||||||
xLabelAngle: 30
|
xLabelAngle: 30
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class IndexView(EventPermissionRequiredMixin, ChartContainingView, TemplateView)
|
|||||||
ctx['obp_data'] = json.dumps([
|
ctx['obp_data'] = json.dumps([
|
||||||
{
|
{
|
||||||
'item': item_names[item],
|
'item': item_names[item],
|
||||||
|
'item_short': item_names[item] if len(item_names[item]) < 15 else (item_names[item][:15] + "…"),
|
||||||
'ordered': cnt,
|
'ordered': cnt,
|
||||||
'paid': num_paid.get(item, 0)
|
'paid': num_paid.get(item, 0)
|
||||||
} for item, cnt in num_ordered.items()
|
} for item, cnt in num_ordered.items()
|
||||||
|
|||||||
Reference in New Issue
Block a user