Hello -
In an effort to build a boxplot against my real elastic data, I have started by following this documentation to create a simple boxplot using Vega (v5) in Kibana (v8.0)
Instead of using the pre-canned penguins.json data file, I have the data in elastic and am fetching it using vega syntax. (I have modified the data slightly to remove spaces in the property names, originally thinking that was my problem.) I understand that I can fetch the documents themselves, rather than aggregate, since the boxplot does the aggregation under the hood.
My problem seems to be in the encoding section, in how to reference the properties in the returned data. Getting errors such as this (and 4 others for the rest of the boxplot fields
Infinite extent for field "lower_whisker__source.BodyMass": [Infinity, -Infinity]
Here is my spec
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
name: theData
url: {
%context%: true
index: species-no-spaces
body: {
size: 10000,
_source: ["Species", "BodyMass"]
}
},
"format": {
"property": "hits.hits"
}
},
"mark": {
"type": "boxplot",
extent: "min-max"
},
"encoding": {
"x": {
"field": "_source.BodyMass"
"type": "quantitative"
"scale": {"zero": false}
},
"y": {
"field": "_source.Species",
"type": "nominal"
}
}
}
I have tried with and without quotes (understand HJSON doesn't care about quotes), with and without _source prefix, tried datum prefix, ... all similar errors.
I have changed away from boxplot to other marks (simple boxes) and it works, referencing _source.{propertyName} so it's something to do with the way the boxplot refers to the properties.
Here is a hack that gets at least the X axis to render. Using transform I can perform a no-op on the property, only to rename it to something that boxplot can find.
transform: [
{
# hack alert! no-op just to rename the property
calculate: "datum._source.BodyMass+0"
as: "mass"
},
# can't get this one to work
# error: ignoring an invalid transform
// {
// caculate: "trim(datum._source.Species)"
// as: "species"
// }
],
and for reference, here is the data, as returned in the Kibana/Vega inspector ("response" data)
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 9,
"max_score": 1,
"hits": [
{
"_index": "species-no-spaces",
"_id": "W1gpuYABT40rochQcMaM",
"_score": 1,
"_source": {
"BodyMass": 3750,
"Species": "Adelie"
}
},
{
"_index": "species-no-spaces",
"_id": "XFgpuYABT40rochQ3sZ4",
"_score": 1,
"_source": {
"BodyMass": 3800,
"Species": "Adelie"
}
},
{
"_index": "species-no-spaces",
"_id": "XVgquYABT40rochQCcam",
"_score": 1,
"_source": {
"BodyMass": 3250,
"Species": "Adelie"
}
},
{
"_index": "species-no-spaces",
"_id": "XlgquYABT40rochQTsbn",
"_score": 1,
"_source": {
"BodyMass": 3800,
"Species": "Chinstrap"
}
},
{
"_index": "species-no-spaces",
"_id": "X1gquYABT40rochQcMbi",
"_score": 1,
"_source": {
"BodyMass": 3775,
"Species": "Chinstrap"
}
},
{
"_index": "species-no-spaces",
"_id": "YFgquYABT40rochQmcaF",
"_score": 1,
"_source": {
"BodyMass": 3700,
"Species": "Chinstrap"
}
},
{
"_index": "species-no-spaces",
"_id": "YVgquYABT40rochQ3saj",
"_score": 1,
"_source": {
"BodyMass": 5150,
"Species": "Gentoo"
}
},
{
"_index": "species-no-spaces",
"_id": "YlgruYABT40rochQA8au",
"_score": 1,
"_source": {
"BodyMass": 5400,
"Species": "Gentoo"
}
},
{
"_index": "species-no-spaces",
"_id": "Y1gruYABT40rochQNcYo",
"_score": 1,
"_source": {
"BodyMass": 4950,
"Species": "Gentoo"
}
}
]
}
}
So - how to properly reference the property names in encoding?
Thank you in advance!!