Skip to content

Commit

Permalink
Merge branch 'patrik-graph' into 'master'
Browse files Browse the repository at this point in the history
Fix graphs loading

See merge request ikus-soft/rdiffweb!287
  • Loading branch information
ikus060 committed Dec 19, 2022
2 parents 0f07279 + fffa013 commit 4e4b4cd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions rdiffweb/templates/graphs_activities.html
@@ -1,9 +1,9 @@
{% extends 'graphs.html' %}
{% from 'include/chartkick.html' import bar_chart %}
{% import 'include/chartkick.html' as chartkick with context %}
{% set active_graph_page='activities' %}
{% block graph_body %}
<h2>{% trans %}Activities{% endtrans %}</h2>
<p>{% trans %}Cumulative number of new, deleted and changed files by period of time.{% endtrans %}</p>
{% set height=(22 * limit)|string + "px" %}
{{ bar_chart(data.activities, stacked=True, height=height) }}
{{ chartkick.bar_chart(data.activities, stacked=True, height=height) }}
{% endblock %}
4 changes: 2 additions & 2 deletions rdiffweb/templates/graphs_errors.html
@@ -1,7 +1,7 @@
{% extends 'graphs.html' %}
{% from 'include/chartkick.html' import line_chart %}
{% import 'include/chartkick.html' as chartkick with context %}
{% block graph_body %}
<h2>{% trans %}Errors{% endtrans %}</h2>
<p>{% trans %}Cumulative number of errors by period of time.{% endtrans %}</p>
{{ line_chart(data.errors, colors=["#dc3912"]) }}
{{ chartkick.line_chart(data.errors, colors=["#dc3912"]) }}
{% endblock %}
4 changes: 2 additions & 2 deletions rdiffweb/templates/graphs_files.html
@@ -1,7 +1,7 @@
{% extends 'graphs.html' %}
{% from 'include/chartkick.html' import line_chart %}
{% import 'include/chartkick.html' as chartkick with context %}
{% block graph_body %}
<h2>{% trans %}File count{% endtrans %}</h2>
<p>{% trans %}Number of files excluding history data.{% endtrans %}</p>
{{ line_chart(data.filecount) }}
{{ chartkick.line_chart(data.filecount) }}
{% endblock %}
6 changes: 3 additions & 3 deletions rdiffweb/templates/graphs_sizes.html
@@ -1,9 +1,9 @@
{% extends 'graphs.html' %}
{% from 'include/chartkick.html' import line_chart %}
{% import 'include/chartkick.html' as chartkick with context %}
{% block graph_body %}
<h2>{% trans %}Source file size{% endtrans %}</h2>
<p>{% trans %}Repository size excluding history data.{% endtrans %}</p>
{{ line_chart(data.sourcefilesize) }}
{{ chartkick.line_chart(data.sourcefilesize) }}
<h2>{% trans %}Increment file size{% endtrans %}</h2>
{{ line_chart(data.filesize) }}
{{ chartkick.line_chart(data.filesize) }}
{% endblock %}
4 changes: 2 additions & 2 deletions rdiffweb/templates/graphs_times.html
@@ -1,7 +1,7 @@
{% extends 'graphs.html' %}
{% from 'include/chartkick.html' import line_chart %}
{% import 'include/chartkick.html' as chartkick with context %}
{% block graph_body %}
<h2>{% trans %}Elapsed Time{% endtrans %}</h2>
<p>{% trans %}Average time to complete backup.{% endtrans %}</p>
{{ line_chart(data.elapsedtime, prefix='min') }}
{{ chartkick.line_chart(data.elapsedtime, prefix='min') }}
{% endblock %}
10 changes: 5 additions & 5 deletions rdiffweb/templates/include/chartkick.html
@@ -1,11 +1,11 @@
{% set chart_id = 0 %}
{% set ns = namespace(chart_id=0) %}
{% macro chartkick(name, data, height, options) %}
{% if chart_id == 0 %}
{% if ns.chart_id == 0 %}
<script src="{{ url_for('static/js/chart.min.js') }}"></script>
<script src="{{ url_for('static/js/chartkick.min.js') }}"></script>
{% endif %}
{% set chart_id = chart_id + 1 %}
<div id="chart-{{ chart_id }}"
{% set ns.chart_id = ns.chart_id + 1 %}
<div id="chart-{{ ns.chart_id }}"
style="height: {{ height }};
text-align: center;
color: #999;
Expand All @@ -16,7 +16,7 @@
</div>
<script>
//<![CDATA[
new Chartkick.{{ name }}(document.getElementById("chart-{{chart_id}}"), {{ data|tojson }}, {{options|d({})|tojson}} );
new Chartkick.{{ name }}(document.getElementById("chart-{{ns.chart_id}}"), {{ data|tojson }}, {{options|d({})|tojson}} );
//]]>
</script>
{% endmacro %}
Expand Down

0 comments on commit 4e4b4cd

Please sign in to comment.