Aggregate
Calcula um valor sobre todos os registros de um data source. Normalmente usado em SummaryBand.
JSON
json
{
"type": "aggregate",
"id": "total",
"x": 400,
"y": 10,
"width": 100,
"height": 24,
"verb": "SUM",
"dataSourceId": "items",
"targetKey": "price",
"format": "currency:BRL",
"bold": true,
"fontSize": 14,
"align": "right",
"verticalAlign": "middle",
"padding": 4,
"hasBorder": true,
"borderColor": "d0d0d0",
"borderWidth": 1,
"borderDashed": false
}Propriedades
| Propriedade | Tipo | Padrão | Descrição |
|---|---|---|---|
width | double | — | Largura em pontos |
height | double | 20.0 | Altura em pontos |
verb | string | — | Operação: SUM, COUNT, AVG, MAX, MIN |
targetKey | string | — | Campo sobre o qual aplicar a operação |
dataSourceId | string | null | Data source alvo. Se omitido, usa o da detail band. |
format | string | "" | Formato de exibição |
fontSize | double | 12.0 | Tamanho da fonte |
bold | bool | false | Negrito |
italic | bool | false | Itálico |
color | string | "000000" | Cor hexadecimal |
align | string | "left" | Alinhamento horizontal: left, center, right |
verticalAlign | string | "middle" | Alinhamento vertical: top, middle, bottom |
padding | double | 0.0 | Espaçamento interno |
hasBorder | bool | false | Exibir borda |
borderColor | string | "000000" | Cor da borda |
borderWidth | double | 1.0 | Espessura da borda |
borderDashed | bool | false | Borda tracejada |
borderDashGap | double | 4.0 | Espaçamento do tracejado |
rounding | object | null | Configuração de arredondamento |
Verbos
| Verbo | Resultado |
|---|---|
SUM | Soma de todos os valores do campo |
COUNT | Quantidade de registros |
AVG | Média aritmética |
MAX | Maior valor |
MIN | Menor valor |
Exemplo com múltiplos agregados
json
{
"type": "summary",
"id": "sum",
"height": 80,
"elements": [
{ "type": "text", "id": "lbl_count", "x": 30, "y": 10, "content": "Pedidos:" },
{ "type": "aggregate", "id": "count", "x": 120, "y": 10, "width": 60, "verb": "COUNT", "dataSourceId": "sales", "targetKey": "order_id" },
{ "type": "text", "id": "lbl_total", "x": 30, "y": 35, "content": "Total:" },
{ "type": "aggregate", "id": "total", "x": 120, "y": 35, "width": 100, "verb": "SUM", "dataSourceId": "sales", "targetKey": "amount", "format": "currency:BRL", "bold": true },
{ "type": "text", "id": "lbl_avg", "x": 30, "y": 60, "content": "Média:" },
{ "type": "aggregate", "id": "avg", "x": 120, "y": 60, "width": 100, "verb": "AVG", "dataSourceId": "sales", "targetKey": "amount", "format": "currency:BRL" }
]
}