{
"description": "Kalorit" ,
"data": {"url" : "assets/charts/ruokadata.csv"} ,
"transform": [{"timeUnit": "yearweek", "field": "pvm", "as": "aika"}, {"joinaggregate": [{"op": "sum", "field": "lepokulutus", "as": "lepokulutus_agg"}], "groupby": ["aika"]}, {"joinaggregate": [{"op": "sum", "field": "syonti", "as": "syonti_agg"}], "groupby": ["aika"]}, {"joinaggregate": [{"op": "sum", "field": "kulutus", "as": "kulutus_agg"}], "groupby": ["aika"]}, {"calculate": "-datum.kulutus_agg-datum.lepokulutus_agg", "as": "kokonaiskulutus_flip"}, {"calculate": "clamp(datum.syonti_agg-datum.kulutus_agg-datum.lepokulutus_agg, 0, 10000)", "as": "erotus"}, {"calculate": "clamp(datum.syonti_agg-datum.kulutus_agg-datum.lepokulutus_agg, -10000, 0)", "as": "erotus_neg"}] ,
"layer": [{
"mark": {"type": "bar", "color": "lightblue", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearweek", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "kokonaiskulutus_flip", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "kokonaiskulutus_flip", "type": "quantitative", "aggregate": "max"}
}
}, {
"mark": {"type": "bar", "color": "lightgreen", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearweek", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "syonti_agg", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "syonti_agg", "type": "quantitative", "aggregate": "max"}
}
}, {
"mark": {"type": "bar", "color": "darksalmon", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearweek", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "erotus", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "erotus", "type": "quantitative", "aggregate": "max"}
}
}, {
"mark": {"type": "bar", "color": "darkorange", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearweek", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "erotus_neg", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "erotus_neg", "type": "quantitative", "aggregate": "max"}
}
}]
}
{
"description": "Kalorit" ,
"data": {"url" : "assets/charts/ruokadata.csv"} ,
"transform": [{"timeUnit": "yearmonth", "field": "pvm", "as": "aika"}, {"joinaggregate": [{"op": "sum", "field": "lepokulutus", "as": "lepokulutus_agg"}], "groupby": ["aika"]}, {"joinaggregate": [{"op": "sum", "field": "syonti", "as": "syonti_agg"}], "groupby": ["aika"]}, {"joinaggregate": [{"op": "sum", "field": "kulutus", "as": "kulutus_agg"}], "groupby": ["aika"]}, {"calculate": "-datum.kulutus_agg-datum.lepokulutus_agg", "as": "kokonaiskulutus_flip"}, {"calculate": "clamp(datum.syonti_agg-datum.kulutus_agg-datum.lepokulutus_agg, 0, 10000)", "as": "erotus"}, {"calculate": "clamp(datum.syonti_agg-datum.kulutus_agg-datum.lepokulutus_agg, -10000, 0)", "as": "erotus_neg"}] ,
"layer": [{
"mark": {"type": "bar", "color": "lightblue", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearmonth", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "kokonaiskulutus_flip", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "kokonaiskulutus_flip", "type": "quantitative", "aggregate": "max"}
}
}, {
"mark": {"type": "bar", "color": "lightgreen", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearmonth", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "syonti_agg", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "syonti_agg", "type": "quantitative", "aggregate": "max"}
}
}, {
"mark": {"type": "bar", "color": "darksalmon", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearmonth", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "erotus", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "erotus", "type": "quantitative", "aggregate": "max"}
}
}, {
"mark": {"type": "bar", "color": "darkorange", "point": true, "clip": true},
"encoding": {
"x": {"field": "pvm", "type": "temporal", "timeUnit": "yearmonth", "title": "Viikot", "axis": {"format": "%B %G", "labelAngle": 0, "labelAlign": "left", "tickCount": "month", "tickExtra": true} , "scale": {"domain": [{"year": 2025, "month": 1, "date": 1}, {"year": 2025, "month": 12, "date": 31}]}},
"y": {"field": "erotus_neg", "type": "quantitative", "aggregate": "max", "title": "Kalorit" },
"tooltip": {"field": "erotus_neg", "type": "quantitative", "aggregate": "max"}
}
}]
}