Skip to content

Commit efdbc7e

Browse files
Copilotdanmarshall
andcommitted
Fix Vega expressions - replace JavaScript reduce() with Vega sum() and pluck() functions
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
1 parent 45d9d36 commit efdbc7e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/web-deploy/json/persona-budget.idoc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@
118118
"type": "number",
119119
"initialValue": 0,
120120
"calculation": {
121-
"vegaExpression": "data('adjustedBudgetData') ? data('adjustedBudgetData').reduce((sum, d) => sum + d.adjustedBudget, 0) : 0"
121+
"vegaExpression": "data('adjustedBudgetData') ? sum(pluck(data('adjustedBudgetData'), 'adjustedBudget')) : 0"
122122
}
123123
},
124124
{
125125
"variableId": "totalSpent",
126126
"type": "number",
127127
"initialValue": 0,
128128
"calculation": {
129-
"vegaExpression": "data('adjustedBudgetData') ? data('adjustedBudgetData').reduce((sum, d) => sum + d.spent, 0) : 0"
129+
"vegaExpression": "data('adjustedBudgetData') ? sum(pluck(data('adjustedBudgetData'), 'spent')) : 0"
130130
}
131131
},
132132
{

0 commit comments

Comments
 (0)