# Vega + Sankey Diagram Color Change

**URL:** https://discuss.elastic.co/t/vega-sankey-diagram-color-change/191106
**Category:** Kibana
**Tags:** vega
**Created:** [July 17, 2019, 11:03pm UTC](https://discuss.elastic.co/t/vega-sankey-diagram-color-change/191106 "2019-07-17T23:03:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jeremy.smith](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jeremy.smith](https://discuss.elastic.co/u/jeremy.smith)
#### Post date: [July 17, 2019, 11:03pm UTC](https://discuss.elastic.co/t/vega-sankey-diagram-color-change/191106/1 "2019-07-17T23:03:16Z")

</div>

Hello All,

I followed the example for the Sankey Diagram from the Elastic Blog Post [[Kibana/Vega Sankey Post.](https://www.elastic.co/blog/sankey-visualization-with-vega-in-kibana) ] .

We use a dark theme and I can't seem to find where to update the color of the text. I was able to adjust the color of the text on the Axes; what I'm attempting to do is change the color of the "country codes" [from the example] to something other than Black.

Thanks.

FYI: Couldn't post the vega due to character limitations.

---

<div class="post-metadata">

### Author: ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)
#### Post date: [July 18, 2019, 4:58pm UTC](https://discuss.elastic.co/t/vega-sankey-diagram-color-change/191106/2 "2019-07-18T16:58:02Z")

</div>

You could try and use this example as a guide:

> [@Vega plugin:Changing color and size of the labels](https://discuss.elastic.co/t/vega-plugin-changing-color-and-size-of-the-labels/128847):
>
> Hello, Is it possible to change the laben size and/or color? I am using Vega plugin. Here is the screenshot of my diagram. and the query is { "$schema": "[https://vega.github.io/schema/vega-lite/v2.json](https://vega.github.io/schema/vega-lite/v2.json)", "description": "A bar chart that directly encodes color names in the data.", "data": { "values": [ {"customer":"A", "@timestamp": 7, "state": "red"}, {"customer":"A", "@timestamp": 5, "state": "green"}, {"customer":"B", "@timestamp": 6, "state": "green"}, {"customer…

---

<div class="post-metadata">

### Author: ![astv](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@astv](https://discuss.elastic.co/u/astv)
#### Post date: [July 19, 2019, 11:44pm UTC](https://discuss.elastic.co/t/vega-sankey-diagram-color-change/191106/3 "2019-07-19T23:44:05Z")

</div>

In the marks array, find the code for the text mark (shown below,) and add a fill property with the color you want, i.e. "fill": {"value": "red"}. I've added it to the code below for illustration.

My code may be a bit different from the version you linked to in your post, but this should point you in the right direction.

Astrit

```
{
  "type": "text",
  "from": {"data": "groups"},
  "interactive": false,
  "encode": {
    "update": {
      "x": {
        "signal": "scale('x', datum.stack) + (datum.rightLabel ? bandwidth('x') + 8 : -8)"
      },
      "yc": {
        "signal": "(datum.scaledY0 + datum.scaledY1)/2"
      },
      "align": {
        "signal": "datum.rightLabel ? 'left' : 'right'"
      },
      "baseline": {"value": "middle"},
      "fontWeight": {"value": "bold"},
      "fill": {"value": "red"},
      "text": {
        "signal": "abs(datum.scaledY0-datum.scaledY1) > 13 ? datum.grpId : ''"
      }
    }
  }
}
```

---

<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: [August 16, 2019, 11:44pm UTC](https://discuss.elastic.co/t/vega-sankey-diagram-color-change/191106/4 "2019-08-16T23:44:06Z")

</div>

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