Pie Chart

I have an expense CDT . It has fields like base charges, fuel charges, taxes.

I have a pie chart and on each slice of a pie i need to display the sum of base charges, fuel charges and taxes for a vehicle .

I am unable to use secondary grouping.

Kindly please help.

  Discussion posts and replies are publicly visible

Parents
  • This cannot be implemented by using a!pieChartConfig(), as we cannot pass multiple measures in it, so rather than using recordType as a source in data parameter and using chart config to display data, you can use list of chartSeries() in which you will provide list of data labels and values. 

    Talking about sum of different fields, you can filter your expense table on vehicleId and then aggregating on vehcileId you can use aggregationFunction to get the SUM of required fields and then pass them into the data parameter of a!chartSeries.

    This is the sample code I wrote for something similar:

    a!localVariables(
      local!data: a!queryEntity(
        entity: cons!AA_MAINTENANCE_DSE_POINTER,
        query: a!query(
          filter: a!queryFilter(field: "vehicleID", operator: "=", value: 5),
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(field: "vehicleID", isGrouping: true),
              a!queryAggregationColumn(
                field: "maintenanceCost",
                aggregationFunction: "SUM",
                alias: "costSum"
              ),
              a!queryAggregationColumn(
                field: "maintenanceDuration",
                aggregationFunction: "SUM",
                alias: "durationSum"
              )
            }
          ),
          pagingInfo: a!pagingInfo(1, 100)
        )
      ).data,
      {
        a!pieChartField(
          series: {
            a!chartSeries(
              label: "Cost Sum",
              data: local!data.costSum
            ),
            a!chartSeries(
              label: "Duration Sum",
              data: local!data.durationSum
            )
          },
          label: "Pie Chart",
          labelPosition: "ABOVE",
          showDataLabels: true,
          showTooltips: true,
          colorScheme: "SUNSET",
          style: "PIE",
          seriesLabelStyle: "LEGEND",
          height: "MEDIUM",
          refreshAfter: "RECORD_ACTION",
          config: a!pieChartConfig()
        )
      }
    )

     

Reply
  • This cannot be implemented by using a!pieChartConfig(), as we cannot pass multiple measures in it, so rather than using recordType as a source in data parameter and using chart config to display data, you can use list of chartSeries() in which you will provide list of data labels and values. 

    Talking about sum of different fields, you can filter your expense table on vehicleId and then aggregating on vehcileId you can use aggregationFunction to get the SUM of required fields and then pass them into the data parameter of a!chartSeries.

    This is the sample code I wrote for something similar:

    a!localVariables(
      local!data: a!queryEntity(
        entity: cons!AA_MAINTENANCE_DSE_POINTER,
        query: a!query(
          filter: a!queryFilter(field: "vehicleID", operator: "=", value: 5),
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(field: "vehicleID", isGrouping: true),
              a!queryAggregationColumn(
                field: "maintenanceCost",
                aggregationFunction: "SUM",
                alias: "costSum"
              ),
              a!queryAggregationColumn(
                field: "maintenanceDuration",
                aggregationFunction: "SUM",
                alias: "durationSum"
              )
            }
          ),
          pagingInfo: a!pagingInfo(1, 100)
        )
      ).data,
      {
        a!pieChartField(
          series: {
            a!chartSeries(
              label: "Cost Sum",
              data: local!data.costSum
            ),
            a!chartSeries(
              label: "Duration Sum",
              data: local!data.durationSum
            )
          },
          label: "Pie Chart",
          labelPosition: "ABOVE",
          showDataLabels: true,
          showTooltips: true,
          colorScheme: "SUNSET",
          style: "PIE",
          seriesLabelStyle: "LEGEND",
          height: "MEDIUM",
          refreshAfter: "RECORD_ACTION",
          config: a!pieChartConfig()
        )
      }
    )

     

Children
No Data