Hello Everyone,
I'm trying to plot a vertical bar using Vega-lite getting data from an Index. But the data does not show up in the view, only the axes.
This is the script I'm using:
{
$schema: "https://vega.github.io/schema/vega-lite/v2.4.0.json"
mark: bar
data: {
url: {
%context%: true
%timefield%:_source.data_registrado_contrato
index: trabalhista,
body: {
_source: ["diretoria", "data_registrado_contrato", "id_contrato"]
}
}
format: { property: "hits.hits" }
}
transform: [
{
aggregate: [{
op: count
field: _source.id_contrato
as: qtd
}]
groupby: ["_source.diretoria"]
}
]
encoding: {
y:{
field: qtd
type: quantitative
}
x:{
field: _source.diretoria
type: nominal
}
}
}
And the mapping of my data:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1499,
"max_score" : 1.0,
"hits" : [
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "AcwtemoBAxKStAaIEnOV",
"_score" : 1.0,
"_source" : {
"id_contrato" : 8.0,
"diretoria" : "Outras",
"data_registrado_contrato" : "2016-01-24T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "BMwtemoBAxKStAaIEnOV",
"_score" : 1.0,
"_source" : {
"id_contrato" : 11.0,
"diretoria" : "Comercial",
"data_registrado_contrato" : "2014-08-01T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "CcwtemoBAxKStAaIEnOV",
"_score" : 1.0,
"_source" : {
"id_contrato" : 16.0,
"diretoria" : "Industrial",
"data_registrado_contrato" : "2018-09-10T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "DMwtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 19.0,
"diretoria" : "Provisão",
"data_registrado_contrato" : "2015-12-08T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "FcwtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 28.0,
"diretoria" : "Demanda",
"data_registrado_contrato" : "2015-02-09T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "IMwtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 39.0,
"diretoria" : "Terceiros",
"data_registrado_contrato" : "2016-08-29T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "I8wtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 42.0,
"diretoria" : "Outras",
"data_registrado_contrato" : "2016-07-12T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "JMwtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 43.0,
"diretoria" : "Industrial",
"data_registrado_contrato" : "2019-03-05T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "KswtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 49.0,
"diretoria" : "Provisão",
"data_registrado_contrato" : "2015-08-24T00:00:00"
}
},
{
"_index" : "trabalhista",
"_type" : "data",
"_id" : "L8wtemoBAxKStAaIEnOW",
"_score" : 1.0,
"_source" : {
"id_contrato" : 54.0,
"diretoria" : "Provisão",
"data_registrado_contrato" : "2014-03-14T00:00:00"
}
}
]
}
}
This is running on:
Kibana 6.6.2