Generate a Pie chart with expression rule

Certified Associate Developer

Hi,

I need to create a pie chart with the output from expression rule.

I can use a!queryEntity() if the output is in Datastore entity with the help of aggregation functions.

Can anyone help me how to store the expression rule output to Data store entity or how to use the rule output directly in pie chart creation.

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents Reply Children
  • +1
    Certified Lead Developer
    in reply to ujjwalrathore

    In case you are not clear with the above answer please refer to the code below.

    a!localVariables(
      local!selectedDepartment,
      /* This query fetches the grouped data for the pie chart. */
      local!chartDatasubset: a!queryEntity(
        entity: cons!EMPLOYEE_ENTITY,/*entity name */
        query: a!query(
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(
                field: "department",
                isGrouping: true
              ),
              a!queryAggregationColumn(
                field: "id",
                alias: "id_count",
                aggregationFunction: "COUNT"
              )
            }
          ),
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: -1,
            sort: a!sortInfo(
              field: "department",
              ascending: true
            )
          )
        )
      ),
      {
        a!pieChartField(
          series: a!forEach(
            items: local!chartDatasubset.data,
            expression: a!chartSeries(
              label: fv!item.department,
              data: fv!item.id_count,
              /* Clicking on the chart sets the filter value for the grid. */
              links: a!dynamicLink(value: fv!item.department, saveInto: local!selectedDepartment)
            )
          ),
          showWhen: isnull(local!selectedDepartment), 
          colorScheme: "MOSS",
          style: "DONUT"
        )
      }
    )
    

  • 0
    Certified Associate Developer
    in reply to ujjwalrathore

    Thanks Ujjwal, I was able to generate the report 

  • 0
    Certified Lead Developer
    in reply to p2005

    If it worked please take a moment to accept the answer so that other people having the same doubt can actually refer and other contributors will know that you have found the solution.