Hi all — I need a little assistance on the google chart below; it’s just about complete, though I’m getting hung up on choice.row_count.
As I loop through cat in category I need it to also return the number of table rows that have that specific category; ideally rendering something like:
[‘Body Shop’, 12],
[‘Car Dealer’, 71]
etc. etc..
Any thoughts? Thank you.
<script src="https://www.gstatic.com/charts/loader.js" type="text/javascript">
</script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
{% set table_info = hubdb_table_rows(2666166) %}
{% set category = [] %}
{% for row in table_info %}
{% set option = row.member_category %}
{% for choice in option %}
{% do category.add(choice) %}
{% endfor %}
{% endfor %}
['Members', 'Type'],
{% for cat in category|unique('name') %}
['{{ cat.name }}', {{ choice.row_count }} ],
{% endfor %}
]);
var options = {
pieHole: 0.4,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
<div id="donutchart" style="width: 500px; height: 500px;"></div>