JSON data returned by API not showing in webdatarocks angular

325 Views Asked by At

I am trying to display the data returned by REST api in json format using angular but nothing loads on screen. Any idea how to achieve that?

Below is what I am trying to do -

getData() {
   this.service.getData().subscribe((res) => {
     this.result = res;


this.pivotReport = 
         {
     
            "dataSource": {
               "dataSourceType":"json",
               "data":this.result
             },
            "slice": {
                "rows": [
                  {
                     "uniqueName":"Country",
                     "sort":"asc"
                  },
                  {
                     "uniqueName":"Business Type",
                     "sort":"asc"
                  },
                  {
                     "uniqueName":"Category"
                  }
                 ],
                "columns": [
                     // {
                     //    "uniqueName":"Category",
                     //    "sort":"asc"
                     // },
                     // {
                     //    "uniqueName":"Country",
                     //    "sort":"asc"
                     // }
                 ]
}
});
}
1

There are 1 best solutions below

0
On

Nothing loads on the screen because you need to pass the report into the pivot component explicitly. You should use the setReport() command to do that.
Find examples of this method in documentation.

Also, your report example seems to display an empty grid even if all data is passed to pivot. You may also try to set measures to aggregate your data, like this:

"slice": {
      "rows": [...],
      "columns": [...],
      "measures": [{
       "uniqueName": "Category",
       "aggregation": "count"
      }]
    }