Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions graphos/renderers/gchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ def get_html_template(self):
return "graphos/gchart/html.html"


class GeoChart(BaseGChart):
def get_js_template(self):
return "graphos/gchart/geo_chart.html"


class LineChart(BaseGChart):
def get_js_template(self):
return "graphos/gchart/line_chart.html"
Expand Down
2 changes: 1 addition & 1 deletion graphos/sources/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def get_field_values(row, fields):
data = []
for field in fields:
value = getattr(row, field)
value = row[field]
data.append(value if not callable(value) else value())
return data

Expand Down
22 changes: 22 additions & 0 deletions graphos/templates/graphos/gchart/base_geochart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<script type="text/javascript">
google.charts.load('current', {'packages':['geochart']});
google.charts.setOnLoadCallback(drawChart{{ chart.get_html_id }});
// google.setOnLoadCallback(drawChart{{ chart.get_html_id }});
function drawChart{{ chart.get_html_id }}() {
{% block chart_specific_arraytodatatable %}
var data = google.visualization.arrayToDataTable({{ chart.get_data_json|safe }});
{% endblock %}

{% if chart.get_options_json %}
var options = {{ chart.get_options_json|safe }}
{% else %}
var options = {};
{% endif %}

{% block create_chart %}
{% endblock %}
chart.draw(data, options);
chart{{ chart.get_html_id }} = chart;
}
</script>
9 changes: 9 additions & 0 deletions graphos/templates/graphos/gchart/geo_chart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "graphos/gchart/base_geochart.html" %}

{% block chart_specific_arraytodatatable %}
var data = google.visualization.arrayToDataTable({{ chart.get_data_json|safe }});
{% endblock %}

{% block create_chart %}
var chart = new google.visualization.GeoChart(document.getElementById('{{ chart.get_html_id }}'));
{% endblock %}