# labelLimit doesn't work in legend update (Vega)

**URL:** https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839
**Category:** Kibana
**Created:** [October 31, 2018, 12:26pm UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839 "2018-10-31T12:26:38Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Lidiya\_Chernova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lidiya_chernova/32/21140_2.png) [@Lidiya\_Chernova](https://discuss.elastic.co/u/Lidiya_Chernova)
#### Post date: [October 31, 2018, 12:26pm UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/1 "2018-10-31T12:26:39Z")

</div>

Hi there!

I have an issue with length of legend labels, because my text doesn't go in the standart length and a command for widening doesn't work. Could you please give a reccomendation about how to use that command correctly.

I put it here:

"legends": [  
{  
"fill": "color",  
"encode": {  
"labels": {  
"update": {  
"labelLimit": {  
"value": 300  
},  
...

![legend](https://us1.discourse-cdn.com/elastic/original/3X/f/c/fc59fc733a2ae78e4e56e69aab1b7cea568ce350.png)

---

<div class="post-metadata">

### Author: ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)
#### Post date: [October 31, 2018, 4:06pm UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/2 "2018-10-31T16:06:33Z")

</div>

@Lidiya_Chernova,

I don't believe Vega can truncate legends. I think that would be more of a question for that project to get details on it: [https://groups.google.com/forum/#!forum/vega-js](https://groups.google.com/forum/#!forum/vega-js).

Perhaps as a work-around, you could include a script-field in your Elasticsearch-query, where you do the truncation. For more info, see here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html)

---

<div class="post-metadata">

### Author: ![Lidiya\_Chernova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lidiya_chernova/32/21140_2.png) [@Lidiya\_Chernova](https://discuss.elastic.co/u/Lidiya_Chernova)
#### Post date: [November 1, 2018, 8:53am UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/3 "2018-11-01T08:53:05Z")

</div>

Hi @thomasneirynck! Thank you for your quick answer.  
No, it's exact Vega does, because I have a legend with defined meanings which I set in scales:

```
{
  "name": "color",
  "type": "ordinal",
  "domain": [
    "число здоровых команд",
    "число команд с отклонениями"
  ],
  "range": [
    "#11a74c",
    "#ff0000"
  ]
} 

```

As you see a phrase "число команд с отклонени **ями**" here is full.

---

<div class="post-metadata">

### Author: ![Lidiya\_Chernova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lidiya_chernova/32/21140_2.png) [@Lidiya\_Chernova](https://discuss.elastic.co/u/Lidiya_Chernova)
#### Post date: [November 12, 2018, 2:55pm UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/4 "2018-11-12T14:55:28Z")

</div>

Hi @nyuriks! Maybe you could help me with this issue?

---

<div class="post-metadata">

### Author: ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)
#### Post date: [November 12, 2018, 3:46pm UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/5 "2018-11-12T15:46:45Z")

</div>

@Lidiya_Chernova to better help, could you provide a small example of a runnable Vega graph? This way if it is a bug in Vega itself, we could file a bug with them. The smaller your example, the easier it will be for everyone to understand the issue. Thanks!

---

<div class="post-metadata">

### Author: ![Lidiya\_Chernova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lidiya_chernova/32/21140_2.png) [@Lidiya\_Chernova](https://discuss.elastic.co/u/Lidiya_Chernova)
#### Post date: [November 13, 2018, 9:34am UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/6 "2018-11-13T09:34:13Z")

</div>

Ok, so what the best way to do it in a case when I use and transform data from Elastic indeces ( "url": {  
"index": "metrics-data-\*", ...)?

---

<div class="post-metadata">

### Author: ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)
#### Post date: [November 14, 2018, 5:31pm UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/7 "2018-11-14T17:31:49Z")

</div>

@Lidiya_Chernova could you provide a working Vega example (something very small but working), demonstrating the problem? Especially something that would work without any data in the [Vega editor](https://vega.github.io/editor/#/). It will be easier to show what to change in that example.

---

<div class="post-metadata">

### Author: ![Lidiya\_Chernova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lidiya_chernova/32/21140_2.png) [@Lidiya\_Chernova](https://discuss.elastic.co/u/Lidiya_Chernova)
#### Post date: [November 19, 2018, 9:18am UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/8 "2018-11-19T09:18:03Z")

</div>

Ok, if i understood you correctly, here a Vega template example where I put the legend the way I do it in my visualizations. And there are also a limit on amount of legend labels.

{  
"$schema": "[https://vega.github.io/schema/vega/v4.json](https://vega.github.io/schema/vega/v4.json)",  
"width": 400,  
"height": 200,  
"padding": 5,

"data": [  
{  
"name": "table",  
"values": [  
{"category": "A", "amount": 28},  
{"category": "B", "amount": 55},  
{"category": "C", "amount": 43},  
{"category": "D", "amount": 91},  
{"category": "E", "amount": 81},  
{"category": "F", "amount": 53},  
{"category": "G", "amount": 19},  
{"category": "H", "amount": 87}  
]  
}  
],

"signals": [  
{  
"name": "tooltip",  
"value": {},  
"on": [  
{"events": "rect:mouseover", "update": "datum"},  
{"events": "rect:mouseout", "update": "{}"}  
]  
}  
],

"scales": [  
{  
"name": "xscale",  
"type": "band",  
"domain": {"data": "table", "field": "category"},  
"range": "width",  
"padding": 0.05,  
"round": true  
},  
{  
"name": "yscale",  
"domain": {"data": "table", "field": "amount"},  
"nice": true,  
"range": "height"  
},  
{  
"name": "color",  
"type": "ordinal",  
"domain": [  
"N командам назначены задачи по отклонениям",  
"Количество чего-то по выбранной команде"  
],  
"range": [  
"steelblue",  
"red"  
]  
}  
],

"axes": [  
{ "orient": "bottom", "scale": "xscale" },  
{ "orient": "left", "scale": "yscale" }  
],

"marks": [  
{  
"type": "rect",  
"from": {"data":"table"},  
"encode": {  
"enter": {  
"x": {"scale": "xscale", "field": "category"},  
"width": {"scale": "xscale", "band": 1},  
"y": {"scale": "yscale", "field": "amount"},  
"y2": {"scale": "yscale", "value": 0}  
},  
"update": {  
"fill": {"value": "steelblue"}  
},  
"hover": {  
"fill": {"value": "red"}  
}  
}  
},  
{  
"type": "text",  
"encode": {  
"enter": {  
"align": {"value": "center"},  
"baseline": {"value": "bottom"},  
"fill": {"value": "#333"}  
},  
"update": {  
"x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},  
"y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},  
"text": {"signal": "tooltip.amount"},  
"fillOpacity": [  
{"test": "datum === tooltip", "value": 0},  
{"value": 1}  
]  
}  
}  
}  
],  
"legends": [  
{  
"fill": "color",  
"encode": {  
"labels": {  
"update": {

```
        "fontSize": {
          "value": 13
        },
        "font": {
          "value": "Segoe UI, Helvetica, Open Sans, Arial"
        },
        "fill": {
          "value": "#999"
        }
      },
      "hover": {
        "fill": {
          "value": "firebrick"
        }
      }
    },
    "symbols": {
      "update": {
      "size": {"value": 80},
      "shape": {"value": "square"}
       
      }
    },
    "legend": {
      "update": {
        "stroke": {
          "value": "#ccc"
        },
        "strokeWidth": {
          "value": 0
        }
      }
    }
  },
  "orient": "bottom"
}

```

]  
}

---

<div class="post-metadata">

### Author: ![Lidiya\_Chernova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lidiya_chernova/32/21140_2.png) [@Lidiya\_Chernova](https://discuss.elastic.co/u/Lidiya_Chernova)
#### Post date: [November 29, 2018, 11:56am UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/9 "2018-11-29T11:56:08Z")

</div>

@nyuriks can you help me with this problem, please?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 27, 2018, 11:56am UTC](https://discuss.elastic.co/t/labellimit-doesnt-work-in-legend-update-vega/154839/10 "2018-12-27T11:56:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
