RazorFlow / framework

The RazorFlow Dashboard Framework
MIT License
133 stars 44 forks source link

For loop to add KPIs to dashboard #32

Closed OElesin closed 7 years ago

OElesin commented 7 years ago

I want to add KPIs to the dashboard dynamically. See my code below:

var avgSpendKPI = new KPIGroupComponent ();
for (var key in segmentProfiles) {
   var caption = key.capitalize() + " Customers"
   var id = key.replace(" ", "_")
   var options = {
      caption: caption,
      value: segmentProfiles[key].avg_amount,
      numberHumanize: true,
      numberPrefix: "NGN "
     }

    avgSpendKPI.addKPI(id, options);
   }

This only displays one KPI but when I click to show modal, it displays all KPIs as a table. Can you advice on what to do?

Thanks in advance

OElesin commented 7 years ago

Solved the issue. Turns out the KPI ids had space in them. Hence, I now create id like this:

var id = key.replace(/ /g, '_');

Ensure no spaces in KPI ids