Hello There,
I'm trying to plot a graph using Vega-Lite, everything works fine, but I need the Y-axis to be reversed. The most recent date on top and the older dates on bottom. I've tried use the sort, but nothing seems to work.
Here is my script:
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.0.json",
"title": "TOP 15 Causa de Pedir Diário",
"data": {
"url": {
"index": "processos",
"%context%": true,
"body": {
"aggs": {
"causa_mes": {
"composite": {
"sources": [
{
"mes_fiscal": {
"date_histogram": {
"field": "data_distribuicao",
"interval": "day",
"time_zone":"UTC"
}
}
},
{
"causa": {
"terms": {"field": "acao.keyword"}
}
}
]
}
}
}
}
},
"format": {
"property": "aggregations.causa_mes.buckets"
}
},
"transform": [
{"calculate": "datum.key.causa", "as": "causa"},
{"calculate": "datum.key.mes_fiscal", "as": "mes"},
{"calculate": "datum.doc_count", "as": "processos"},
{"calculate": "datum.doc_count / 2", "as": "center"}
],
"encoding": {
"y": {
"field": "mes",
"type": "ordinal",
"timeUnit":"daymonthyear",
"sort": "descending",
"axis": {"title": "Data"}
},
"x": {
"field": "processos",
"type": "quantitative",
"axis": {"title": "Quantidade"},
"stack": "zero"
},
"color": {
"field": "causa",
"type": "nominal",
"legend": {"title": "Tipo de AçÃo"},
"scale": {
"range": [
"#26478D",
"#632678",
"#406EB3",
"#BA2F7D",
"#BB0048"
]
}
},
"order": {"field": "causa", "type": "quantitative"}
},
"layer": [
{"mark": {"type": "bar", "color": "#26478d"}},
{
"mark": {
"type": "text",
"baseline": "middle",
"dx": -15
},
"encoding": {
"x": {
"field": "processos",
"type": "quantitative",
"stack": "zero"
},
"text": {"field": "processos", "type": "nominal"},
"color": {"value": "white"}
}
}
]
}
And this is my actual plot: