Pie chart via. a task report

Hi

I am currently working on version 17.3.
I have created a task report and the data of this task report is being displayed on a Tempo report in a grid.
I have a column "Status" in this report for which I have an array of values:
0; 0; 0; 0; 0; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2

On the similar lines I want to depict the report data via. a pie chart.
I want to having a grouping based on the "Status" but when I make use of aggregation in a!query(); I get the output "No Records Found".
Also the tasks with status 0 i.e. Assigned is also not getting displayed in the pie chart if I ignore grouping and want to display the entire data set.
Below is the code snippet for the same:

 

load(
local!selectedStatus,
local!chartPagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort:a!sortInfo(
field:"c1",
ascending:true
)
),
with(

local!chartDatasubset:a!queryProcessAnalytics(
report: cons!PH_DAILY_TASK_REPORT,
contextProcessModels: cons!PH_MODEL_FOR_DAILY_TASK_REPORT,
query: a!query(

pagingInfo: local!chartPagingInfo
)
),
{
if(
local!chartDatasubset.totalCount = 0,
a!textField(
value: "No records found",
readOnly: "TRUE"
),
{
a!textField(
value:local!chartDatasubset.data.c1,
readOnly:true
),
a!pieChartField(
series: a!forEach(
items: local!chartDatasubset.data,
expression: a!chartSeries(
label: fv!item.c1,
data: fv!item.c1,
links: a!dynamicLink(value: fv!item.c1, saveInto: local!selectedStatus)
)
)
)
}
)
}
)
)


Thanx in advance!!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    First, I strongly recommend that when you're going to paste a large block of code, you use the Rich Text editor and use the menu, "Insert" --> "Insert Code", and paste your code in there - it preserves indentation which makes things much easier to read, and puts it in a box to prevent the post from stretching super long.

    So, I was able to manually construct a faux aggregation within a local variable and use that to make a pie chart which I believe is pretty close to what you're after.  See code below:

    load(
      
      local!statusArray: {
        0; 0; 0; 0; 0; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2
      },
      
      with(
        local!aggregate: rule!GLBL_removeDuplicateArrayMembers(
          a!forEach(
            local!statusArray,
            
            {
              status: fv!item,
              count: length(where(local!statusArray = fv!item))
            }
            
          )
        ),
        
        a!sectionLayout(
          contents: {
            
            a!paragraphField(
              label: "debug output",
              labelPosition: "ADJACENT",
              value: local!aggregate
            ),
            
            a!pieChartField(
              label: "test pie chart",
              labelPosition: "ADJACENT",
              series: a!forEach(
                local!aggregate,
                a!chartSeries(
                  label: fv!item.status,
                  data: fv!item.count
                )
              )
            )
          }
        )
      )
    )

     

    This is the output as-is:

  • As a best practice, I recommend removing duplicates on the a!forEach items input, so that fewer cycles of the loop are executed -- in this, 2 instead of ~30. While the performance difference may be unnoticeable with a small array, it could start to degrade as the data grows into 4, 5, or 6 digits. Also it is a best practice to always write your loops that way so it is a consistent habit since there is no reason for the less efficient loop.
  • 0
    Certified Lead Developer
    in reply to codys

    You're right - initially it didn't occur to me that the aggregation count would work just as well when run on a pre-de-duplicated array.

    Here's my revised version:

    load(
      
      local!statusArray: {
        0; 0; 0; 0; 0; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2
      },
      
      with(
        local!aggregate: a!forEach(
          rule!GLBL_removeDuplicateArrayMembers( local!statusArray ),
          
          {
            status: fv!item,
            count: length(where(local!statusArray = fv!item))
          }
        ),
        
        a!sectionLayout(
          contents: {
            
            a!paragraphField(
              label: "debug output",
              labelPosition: "ADJACENT",
              value: local!aggregate
            ),
            
            a!pieChartField(
              label: "test pie chart",
              labelPosition: "ADJACENT",
              series: a!forEach(
                local!aggregate,
                a!chartSeries(
                  label: fv!item.status,
                  data: fv!item.count
                )
              )
            )
          }
        )
      )
    )

  • 0
    A Score Level 1
    in reply to Mike Schmitt
    Thanx Mike!! My requirement is achievable with your guidance.
Reply Children
No Data