Hello,
I had to rewrite some visualisations in Kibana with Veg-Lite because they are based on nested fields.
I set the automated resize in the script:
"autosize": {
"type": "fit",
"contains": "padding",
resize: true
},
but it works only partially.
If I resize vertically, the pie chart is resized correctly. But if I resize horizontally, the pie charts does not resize, it gets only partially visualized if the window gets smaller than the chart, and scroll bars appear.
Also: the pie chart, at the moment of the creation, is horizontally centered. If I increase the horizontal width, it gets recentered, going then further from the left border, but if I decrease that width, it doesn't recenter, and it stays far from the left border.
Also: when I resize, the legend moves to the right, and it's not moved back to the left if I reduce the horizontal width.
The final effect is that every time I resize, everything is messed up.
What is wrong in what I do?
Here is the code I use:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
//"width": "container",
//"height": container,
data: {
url: {
%context%: true
%timefield%: timestamp
index: search-sonarqube-telemetry-*
body: {
"aggs": {
"languages": {
"terms": { "field": "nclocByLanguage.language.keyword"}
}
}
size: 0
}
}
format: {property: "aggregations.languages.buckets" }
}
config:{
padding:{
left:{
"expr": "width/100"
}
}
}
"autosize": {
"type": "fit",
"contains": "padding",
resize: true
},
encoding: {
color: {
field: "key"
type: nominal
sort: theta
"legend": {
title: false
"labelFontSize": {
//"expr": "min(width,height)/35"
"expr": "(width+height)/90"
}
padding: 20
offset:-200
rowPadding: {
"expr": "(width+height)/90"
}
/*
offset: {
"expr": "-height/2"
}
padding: {
"expr": "(width+height)/15"
}
rowPadding: {
"expr": "(width+height)/90"
}
clipHeight:{
"expr": "(width+height)/90"
}
*/
},
}
theta: {
field: "PercentOfTotal"
type: quantitative
stack: true
}
"order": {
"field": "PercentOfTotal", "type": "quantitative", "sort":"descending"
}
}
"transform": [{
"window": [{
"op": "sum",
"field": "doc_count",
"as": "total_doc_count"
}],
"frame": [null, null]
},
{
"calculate": "datum.doc_count/datum.total_doc_count",
"as": "PercentOfTotal"
}],
"layer": [
{
"mark": {
type: "arc",
"stroke": "#fff",
"tooltip": true,
"padAngle": 0.01,
"radius": {
"expr": "min(width,height)/2.1"
},
"params": [
{
"name": "highlight",
"select": {
"type": "point",
"on": "mouseover"
}
},
{
"name": "select",
"select": "point"
}
]
},
},
{
"mark": {
"type": "text",
"fontSize": {
"expr": "min(width,height)/25"
}
"radius": {
"expr": "min(width,height)/3.3"
}
"limit": {
"expr": "min(width,height)/5"
}
},
"encoding": {
"text": {"field": "key","type": "nominal"}
color: {
value: white
}
}
}
{
"mark": {
"type": "text",
"fontSize": {
"expr": "min(width,height)/25"
}
"radius": {
"expr": "min(width,height)/2.5"
}
"limit": {
"expr": "min(width,height)/5"
}
},
"encoding": {
"text": {"field": "PercentOfTotal","type": "nominal", "format": ".1%"}
color: {
value: white
}
}
}
]
}