Why Vega Tree shows unnecessary leaf node at the end of the tree

vega

(Bijayalaxmi Padhy) #1

Hi All,
I am trying to plot a flatten transformation tree using vega visualization type in Kibana. I am able to display all the data as expected. However there is an extra leaf node level shows up with no data. I want to remove this last leaf node at the end of the tree. I am adding the code and data snippet for your reference. Thanks in advance for your help.

{
$schema: https://vega.github.io/schema/vega/v3.0.json
signals: [
{
name: labels
value: true
bind: {input: "checkbox"}
}
{
name: aspectRatio
value: 1.6
bind: {input: "range", min: 0.2, max: 5, step: 0.1}
}
{
name: layout
value: tidy
bind: {
input: radio
options: ["tidy", "cluster"]
}
}
{
name: links
value: diagonal
bind: {
input: select
options: ["line", "curve", "diagonal", "orthogonal"]
}
}
],
data: [
{
name: tree
url: {
%context%: true
// Filter the time picker (upper right corner) with this field
%timefield%: last_update_time
index: automataactivity
body: {
"aggs": {
"business": {
"composite": {
"sources" : [
{ "competency_name": { "terms" : { "field": "busn_competency_name.keyword" } }
},
{ "component_name": { "terms" : { "field": "busn_component_name.keyword" } }
},
{ "busn_srvc_name": { "terms" : { "field": "busn_srvc_name.keyword" } }
}
]
},
"aggs": {
"Comp" : {
"filter" : { "term": { "automata_status.keyword": "Completed" } }
},
"Exp" : {
"filter" : { "term": { "automata_status.keyword": "Exception" } }
},
"percentage": {
"bucket_script": {
"buckets_path": {
"excp": "Exp._count",
"comp": "Comp._count"
},
"script": "Math.round((params.excp/params.comp) * 100)"
}
}
}
}
},
}
}
// format: {property: "aggregations.mycount.buckets"}
transform: [
{
type: flatten
fields: ["aggregations.business.buckets"],
as: ["a"]
}
{
type: nest
keys: ["a.key.competency_name", "a.key.component_name","a.key.busn_srvc_name", "a.percentage.value"],
generate: true
},
{
"type": "tree",
"method": {"signal": "layout"},
"size": [{"signal": "height - 100"}, {"signal": "width - 100"}],
"as": ["y", "x", "depth", "children"]
}
]
}
{
"name": "links",
"source": "tree",
"transform": [
{ "type": "treelinks" },
{
"type": "linkpath",
"orient": "horizontal",
"shape": {"signal": "links"}
}
]
}
],
scales: [
{
"name": "color",
"type": "sequential",
"range": {"scheme": "blues"},
"domain": {"data": "tree", "field": "depth"},
"zero": true
}
],
marks: [
{
"type": "path",
"from": {"data": "links"},
"encode": {
"update": {
"path": {"field": "path"},
"stroke": {"value": "#105bdd"}
}
}
},
{
"type": "symbol",
"from": {"data": "tree"},
"encode": {
"enter": {
"size": {"value": 300},
"stroke": {"value": "black"}
},
update: {
"x": {"field": "x"},
"y": {"field": "y"},
"fill": {"scale": "color", "field": "depth"}
}
}
}
{
"type": "text",
"from": {"data": "tree"},
"encode": {
"enter": {
"text": {"field": "key"},
"fontSize": {"value": 12},
"baseline": {"value": "top"},
"fill": {"value": "#C0C0C0"}
}
update: {
"x": {"field": "x"},
"y": {"field": "y"},
"dx": {"signal": "datum.children ? -7 : 7"},
"align": {"signal": "datum.children ? 'right' : 'left'"},
"opacity": {"signal": "labels ? 1 : 0"}
}
}
}
]
}


(Bhavya R M) #2

@nyuriks

Thanks,
Bhavya