I'm currently trying to populate an analytics chat from a data source in budibase.
The datasource produces output that looks like so:
{"enabled":8,"disabled":1,"total":9}
The code for the data provider is here but in simple terms it counts the amount of JSON 'enabled' keys set to true or false from a previous rest API call:
let enabledCount = 0;
let disabledCount = 0;
const data = $("Users Scans.Rows");
data.forEach(item => {
if (item.enabled) {
enabledCount++;
} else {
disabledCount++;
}
});
const totalCount = data.length;
const result = {
enabled: enabledCount,
disabled: disabledCount,
total: totalCount
};
console.log(JSON.stringify(result));
const jsondata = JSON.stringify(result);
return jsondata;
I've added a chart wtihin that data provider and can click it as a data source but none of the other data populates for the chart options includign drawing chart on the page see chart config below: enter image description here
I've tried many different ways including removign the data provider and simply adding the data parsing into the chart, outputting the data as CSV and different chart types. I have had it work previously but cannot figure otu what changed. The REST API call is working as intended and retrives data no problem.