diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 9080b210..b1e96620 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -119,104 +119,6 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b return msg.send(fail_silently) -def normalise_data(data, to=100): - """ - Used for normalising data prior to graphing with Google charting API. EG: - - [1, 4, 10] becomes [10, 40, 100] - [36, 54, 240] becomes [15, 23, 100] - """ - max_value = max(data) - if max_value > to: - new_data = [] - for d in data: - new_data.append(int(d/float(max_value)*to)) - data = new_data - return data - - -def line_chart(data): - """ - 'data' is a list of lists making a table. - Row 1, columns 2-n are data headings (the time periods) - Rows 2-n are data, with column 1 being the line labels - """ - - column_headings = data[0][1:] - max = 0 - for row in data[1:]: - for field in row[1:]: - if field > max: - max = field - - - # Set width to '65px * number of months + 100 for headings.'. - chart_url = 'http://chart.apis.google.com/chart?cht=lc&chs=%sx150&chd=t:' % (min(len(column_headings)*65+100, 1000)) - first_row = True - row_headings = [] - for row in data[1:]: - # Add data to URL, normalised to the maximum for all lines on this chart - norm = normalise_data(row[1:], max) - if not first_row: - chart_url += '|' - chart_url += ','.join([str(num) for num in norm]) - row_headings.append(row[0]) - first_row = False - - chart_url += '&chds=' - rows = len(data)-1 - first = True - for row in range(rows): - # Set maximum data ranges to '0:x' where 'x' is the maximum number in use. - if not first: - chart_url += ',' - chart_url += '0,%s' % max - first = False - chart_url += '&chdl=%s' % '|'.join(row_headings) # Display legend/labels - chart_url += '&chco=%s' % ','.join(chart_colours) # Default colour set - chart_url += '&chxt=x,y' # Turn on axis labels - chart_url += '&chxl=0:|%s|1:|0|%s' % ('|'.join(column_headings), max) # Axis Label Text - - return chart_url - - -def bar_chart(data): - """ - 'data' is a list of lists making a table. - Row 1, columns 2-n are data headings - Rows 2-n are data, with column 1 being the line labels - """ - - column_headings = data[0][1:] - max = 0 - for row in data[1:]: - for field in row[1:]: - if field > max: - max = field - - - # Set width to '220px * number of months'. - chart_url = 'http://chart.apis.google.com/chart?cht=bvg&chs=%sx150&chd=t:' % (min(len(column_headings) * 220, 1000)) - first_row = True - row_headings = [] - for row in data[1:]: - # Add data to URL, normalised to the maximum for all lines on this chart - norm = normalise_data(row[1:], max) - if not first_row: - chart_url += '|' - chart_url += ','.join([str(num) for num in norm]) - row_headings.append(row[0]) - first_row = False - - chart_url += '&chds=0,%s' % max - chart_url += '&chdl=%s' % '|'.join(row_headings) # Display legend/labels - chart_url += '&chco=%s' % ','.join(chart_colours) # Default colour set - chart_url += '&chxt=x,y' # Turn on axis labels - chart_url += '&chxl=0:|%s|1:|0|%s' % ('|'.join(column_headings), max) # Axis Label Text - - return chart_url - - def query_to_dict(results, descriptions): """ Replacement method for cursor.dictfetchall() as that method no longer diff --git a/helpdesk/templates/helpdesk/report_index.html b/helpdesk/templates/helpdesk/report_index.html index ac9df4b6..6159be06 100644 --- a/helpdesk/templates/helpdesk/report_index.html +++ b/helpdesk/templates/helpdesk/report_index.html @@ -3,33 +3,29 @@ {% block helpdesk_title %}{% trans "Reports & Statistics" %}{% endblock %} {% block helpdesk_body %} -{% ifequal number_tickets 0 %}{% blocktrans %} -

Reports & Statistics

+

{% trans "Reports & Statistics" %}

-

You haven't created any tickets yet, so you cannot run any reports.

-{% endblocktrans %} +{% ifequal number_tickets 0 %} +

{% trans "You haven't created any tickets yet, so you cannot run any reports." %}

{% else %} -{% blocktrans %} -

Reports & Statistics

-