Charting numbers inside nested RG

Hi all, looking for some help

I have a table that is made up nested RGs and a group that does a search. It goes RG(api call)>RG>(api call)>Group(do a search & :sum)

the result looks like this:

I would like to be able to stick these values into a bar chart. I can’t seem to find a way to pull those numbers out of the nested rgs though… anyone have an idea?


This is a long shot as I don’t really know your data or how your API call responses are structured, so I’m not sure if this will work for you. I’m making some important assumptions as follows. if they are true, then maybe what I’m about to propose might just work.


  1. That your RGs are based on the same API, or more importantly that the data behind them can be sorted uniformly, i.e by the same field. Ideally, they both refer to the same dataset.

  2. That if you were storing the data in a table in your database, it would look something like this:

    Player ¦ Position ¦ Score
    St 108’s ¦QB ¦45.6
    St 108’s ¦RB ¦139.3
    St 108’s ¦WR ¦153.5
    St 108’s ¦TE ¦26.6
    Franch 3 ¦QB ¦42.5
    Franch 3 ¦RB ¦157.4

At any rate, try putting the following in an html element, replacing the searches with your API calls. I think you need to ensure that your data from the calls (assuming you’re actually making multiple calls) are sorted by the same field so that row 1 in the first search relates to row 1 in the second search and so on.

<!--Load the AJAX API-->
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
  // Create and populate the data table.
google.charts.load('current', {'packages':['corechart', 'table']});
function drawVisualization() {

var positions = ["searchAPICall's Positions_SortedByFieldX"];
var players = ["searchAPICall's Players_SortedByFieldX"];
  var scores = [searchAPICall's Scores_SortedByFieldX];
var data = new google.visualization.DataTable();
  data.addColumn('string', 'Player');  
  data.addColumn('string', 'Position');
  data.addColumn('number', 'Score');
  for(i = 0; i < players.length; i++)
    data.addRow([players[i], positions[i], scores[i]]);

var distinctValues = data.getDistinctValues(1);
  var viewColumns = [0, 1];
    var groupColumns = [];
    // build column arrays for the view and grouping
    for (var i = 0; i < distinctValues.length; i++) {
            type: 'number',
            label: distinctValues[i],
            calc: (function (x) {
                return function (dt, row) {
                    return (dt.getValue(row, 1) == x) ? dt.getValue(row, i) : 0;
            column: i+2,
            type: 'number',
            //label: distinctValues[i],
	data.sort({column: 0, desc: false},{column: 1, desc: false}); 
     var view = new google.visualization.DataView(data);
    // next, we group the view on column A, which gets us the pivoted data
    var pivotedData =, [0], groupColumns);

    // draw agg table
    new google.visualization.ChartWrapper({
      chartType: 'Table',
      containerId: 'table-div',
      dataTable: pivotedData

        var options = {
          vAxis: {title: 'Scores (totals)'},
          hAxis: {title: 'Players', maxTextLines: 3},
          seriesType: 'bars',
          legend: {position: 'top', maxLines: 1, alignment:'center'},
          isStacked: 'false'

  // Create and draw the visualization.
 new google.visualization.ComboChart(document.getElementById('curve_chart')).
    draw(pivotedData, options);

    <div id="curve_chart" style="width: 600px; height: 400px" align="center"></div>
<div id="table-div" style="width: 600px; left: 100px" align="center"></div>

Update: Just had a thought, rather than making your api calls a second time in the html, you could just use RG1’s list of results and RG2’s list of results.

In the above html code, this is where you insert your searches (API calls):

Keep the quotes in the first two.

There is a plugin called “RepeatingGroup Tools (BDK)”

It’s not free but it will allow you to extract those numbers from the RG.

Yeah, a big problem i’m having is that i’m mixing data from the API and searches from MY bubble database.

Essentially i’m getting lists of player ids for every team in a fantasy football league. Then i’m searching my database for those id’s and returning values i’ve assigned them. Then i :sum it… that’s where the number displayed is coming from. If i could just get THAT number into the database, i could use it…

ahh, i might have to go this route. I wish i could just do a “if # >0, put in DB” but i don’t think that’s possible. thx for the tip

This topic was automatically closed after 70 days. New replies are no longer allowed.