Having trouble fetching and displaying data in a chart? I've been struggling with it for the past few days—any help would be appreciated.
My code fetches and reads data perfectly fine, passing it to an HTML table, but I can't seem to pass it to the chart... feeling confused)
Here's the snippet of my code:
function loadReport() {
var dateFrom = document.getElementById("date1").value.toString();
var dateTo = document.getElementById("date2").value.toString();
var apiurl = "<?php echo $user->getFromTable_MyId("integration_api", "users"); ?>";
var pubID = "<?php echo $user->getFromTable_MyId("id", "users"); ?>";
$.getJSON(apiurl + '&Target=Affiliate_Report&Method=getStats&fields[]=Stat.affiliate_info1&fields[]=Stat.payout&fields[]=Stat.conversions&fields[]=Stat.clicks&filters[Stat.affiliate_info1][conditional]=EQUAL_TO&filters[Stat.affiliate_info1][values]=pop_24&filters[Stat.date][conditional]=BETWEEN&filters[Stat.date][values][]=' + dateFrom + '&filters[Stat.date][values][]=' + dateTo + '&sort[Stat.date]=desc', function(data) {
//if you want to add more on balance just enter number in value
values9=[0]
values8=[0]
values7=[0]
var data, id, conversion, clicks, payout, statDate = "";
var id = '';
var clicks = '';
var conversion = '';
var payout = '';
for (i in data.response.data.data) {
const chartDateArr = data.response.data.data[i].Stat.date;
const chartClicksArr = data.response.data.data[i].Stat.clicks;
console.log(chartClicksArr);
const chartConversionsArr = data.response.data.data[i].Stat.conversions;
const chartPayoutArr = data.response.data.data[i].Stat.payout;
// Code continues...
For screenshots of the results outputs, follow these links: chart, table, console
JSON text result from API fetch:
{
// JSON response content...
}