Dynamic single score component question

Robert Kelly
Tera Expert

Hello,

 

I'm trying to get a single score data visualization component to display the sum of an integer field based on a filtered data source that updates when options in a dropdown menu are selected.

 

When I add the data source to the single score as dynamic data binding I can no longer select anything in the metric field.  I believe I am failing to structure the data needed for the metric to visually display it in the component when the data source is filtered based on previous selections.

 

RobertKelly_0-1675811586443.png

 

I know I'm close since I can switch the metric over to a script and output the records to the console using:

 

var hours = 0;

  for(var i = 0; i < api.data.requirement_lookup.results.length; i++) {
    hours += api.data.requirement_lookup.results[i].estimated_hours.value;
  }
  console.log(api.data.requirement_lookup.results);
  console.log(hours);

 

 
I'm think the way to go about this is to return an object to the metric section so it can display based on the properties listed under the developer references for single score components.
 

 

function evaluateProperty({api, helpers}) {
  
  var myObj = {};
  myObj.datasource = 'requirement_lookup';
  myObj.id = 'Estimated hours';
  myObj.aggregateFunction = 'SUM';
  myObj.aggregateField = 'estimated_hours';
  return myObj;

}

 

 

Any help with this would be greatly appreciated.

 

Thank you,

Robert

1 ACCEPTED SOLUTION

Hey @Johns Marokky,

 

I ended up building a separate custom data transform to get all of the data calculated as I needed.

 

RobertKelly_1-1681322641241.png

 

I then threw that into a repeater with some card components to map the data out.  I still have a little styling to correct but it worked out pretty well considering.

 

RobertKelly_0-1681322415465.png

 

I'm definitely curious to hear your alternate method on this.  I would be very appreciative to take in some more info on the topic to see what all is possible.  It's great knowing there's a few ways to get things done in the UI Builder.

 

--Edit--

I also wanted to add that using the repeater and custom data transform lets me add/remove reports as needed without having to configure additional components.  It's just an additional little bit of scripting to parse it out and drop it into that JSON object.  I'm becoming a big fan of the repeaters in this aspect since I can customize how I want all consistent data to look and just iterate through it.

Also tagging @Sri Ram1 for my solution

 

 

Thank you,

Robert

View solution in original post

5 REPLIES 5

Hey @Johns Marokky,

 

I ended up building a separate custom data transform to get all of the data calculated as I needed.

 

RobertKelly_1-1681322641241.png

 

I then threw that into a repeater with some card components to map the data out.  I still have a little styling to correct but it worked out pretty well considering.

 

RobertKelly_0-1681322415465.png

 

I'm definitely curious to hear your alternate method on this.  I would be very appreciative to take in some more info on the topic to see what all is possible.  It's great knowing there's a few ways to get things done in the UI Builder.

 

--Edit--

I also wanted to add that using the repeater and custom data transform lets me add/remove reports as needed without having to configure additional components.  It's just an additional little bit of scripting to parse it out and drop it into that JSON object.  I'm becoming a big fan of the repeaters in this aspect since I can customize how I want all consistent data to look and just iterate through it.

Also tagging @Sri Ram1 for my solution

 

 

Thank you,

Robert