I am looking to populate a Google-chart table by looping through a list of objects. However, before drawing the table, I need to check for duplicates within the list. If any duplicates are found, I want to remove them and increment the count for the unique item.
function drawTable()
{
var data = new google.visualization.DataTable();
data.addColumn('string', 'Teamname');
data.addColumn('number', 'Number of resources');
var number = 1;
{% for k, v in teammember %}
{% for object in object_list %}
data.addRows([['{{ object.team.name }}', number]]);
{% endfor %}
{% endfor %}
var table = new google.visualization.Table(document.getElementById('table-div'));
table.draw(data, {showRowNumber: true, width: '100%', height: '100%'});
}
The table columns represent the name of a team and the number of members associated with that team.
Within my loop, I identify all the teams. How should I proceed to handle finding duplicates, incrementing counts, and removing duplicates? An example output could be:
- Name - Team-members
- Junior Bobcat 3
- Team Bobcat 4
- Junior Coffe 4