My data set is an array of the following form:
[
{ "DATE" : "2020-01-02", "COUNTRY" : "Spain", "COUNT" : 110 },
{ ... },
{ ... }
]
There are multiple countries and multiple days. There are no gaps in dates.
I want to inject field DAYS_PASSED (and subsequently use it for the X axis)
using the following algorithm:
- Check the value of
DAYS_PASSEDfor the previous day for the same country and assign it to variableTEMP. (If the previous day does not exist, assume 0); - Calculate
DAYS_PASSEDusing the following formula:
if TEMP > 0, then DAYS_PASSED = TEMP + 1
else-if COUNT > 100 then DAYS_PASSED = 1
else DAYS_PASSED = 0
So far I have done this in a preprocessing step (outside of Vega-Lite) but I was wondering if it was possible to migrate the calculation to Vega-Lite, maybe by plugging-in in a JavaScript function somehow?
I would also like to be able to expose 100 (from the COUNT > 100 condition) in the
graph so that the user can tweak it to, say, 200.
