# Beginner help with node - Change fill color SVG Graphics

**URL:** <https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258>\
**Category:** General\
**Created:** [25 February 2020 21:17 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258 "2020-02-25T21:17:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nodebeginner](https://avatars.discourse-cdn.com/v4/letter/n/dc4da7/32.png) [@nodebeginner](https://discourse.nodered.org/u/nodebeginner)\
**Post date:** [25 February 2020 21:17 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/1 "2020-02-25T21:17:30Z")

</div>

Node: (node-red-contrib-ui-svg)

I'm just a beginner and I'm starting to toy around with Node Red and I'm running into some trouble with changing the fill color of one of my SVG images with the inject node. Tutorials online are fine but I can't seem to get the payload to go through to the graphics node. I'm unsure on what to actually put into the payload, as it never seems to work. Can somebody quickly walk me through from start to finish with an example?

 ![Screen Shot 2020-02-24 at 2.04.59 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f699c2072dccd2bc4b577f3ea0b73c927e638eb8.png)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [25 February 2020 21:42 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/2 "2020-02-25T21:42:03Z")

</div>

> [@nodebeginner](#):
>
> Tutorials online are fine but I can't seem to get the payload to go through to the graphics node.

Hi @nodebeginner,  
Welcome to the forum!  
It is a bit hard to tell from your screenshot what you have tried already. It is always advised to export a part from your flow, and share it here ...

Did you use the following example flow from our readme page on Github?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/863a76881a8d880d5c1805ee313c57c18331f446.png)

For me that example still works fine to change the color of the camera icon, as soon as I click on the inject node's button ...

---

<div class="post-metadata">

**Author:** ![nodebeginner](https://avatars.discourse-cdn.com/v4/letter/n/dc4da7/32.png) [@nodebeginner](https://discourse.nodered.org/u/nodebeginner)\
**Post date:** [25 February 2020 22:33 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/3 "2020-02-25T22:33:45Z")

</div>

Yes I've seen it. It's just not entirely clear for me what to actually type in because I'm so new. I believe the picture you sent refers to adding events, but I'm still lost on how to properly use input binds and what to put into the inject node.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [25 February 2020 23:18 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/4 "2020-02-25T23:18:22Z")

</div>

Here is a much simpler flow to get you started:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/3/f3a0552b535a0417d785578847716253db4c426d.png)

```auto
[{"id":"8f0e54d7.4d1668","type":"ui_svg_graphics","z":"d9a54719.b13a88","group":"8d3148e0.0eee88","order":1,"width":"14","height":"10","svgString":"<svg preserveAspectRatio=\"none\" x=\"0\" y=\"0\" viewBox=\"0 0 900 710\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <image width=\"889\" height=\"703\" id=\"background\" xlink:href=\"https://www.roomsketcher.com/wp-content/uploads/2016/10/1-Bedroom-Floor-Plans.jpg\" />\n <text id=\"banner\" x=\"10\" y=\"16\" fill=\"black\" stroke=\"black\" font-size=\"35\" text-anchor=\"left\" alignment-baseline=\"middle\" stroke-width=\"1\">This is the #banner</text>\n <circle id=\"pir_living\" cx=\"310\" cy=\"45\" r=\"5\" stroke-width=\"0\" fill=\"#FF0000\" />\n <text id=\"cam_living_room\" x=\"310\" y=\"45\" font-family=\"FontAwesome\" fill=\"green\" stroke=\"green\" font-size=\"35\" text-anchor=\"middle\" alignment-baseline=\"middle\" stroke-width=\"1\"></text>\n</svg> ","clickableShapes":[{"targetId":"#cam_living_room","action":"click","payload":"camera_living","payloadType":"str","topic":"camera_living"}],"smilAnimations":[],"bindings":[],"showCoordinates":false,"autoFormatAfterEdit":false,"outputField":"","editorUrl":"http://drawsvg.org/drawsvg.html","directory":"","name":"","x":560,"y":500,"wires":[[]]},{"id":"588ccdd4.5ad384","type":"inject","z":"d9a54719.b13a88","name":"fill with red","topic":"","payload":"{\"command\":\"update_style\",\"selector\":\"#cam_living_room\",\"attributeName\":\"fill\",\"attributeValue\":\"red\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":500,"wires":[["8f0e54d7.4d1668"]]},{"id":"3272d837.2122e8","type":"inject","z":"d9a54719.b13a88","name":"fill with blue","topic":"","payload":"{\"command\":\"update_style\",\"selector\":\"#cam_living_room\",\"attributeName\":\"fill\",\"attributeValue\":\"blue\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":540,"wires":[["8f0e54d7.4d1668"]]},{"id":"8d3148e0.0eee88","type":"ui_group","z":"","name":"Floorplan test","tab":"93e19e4f.b80ed","disp":true,"width":"14","collapse":false},{"id":"93e19e4f.b80ed","type":"ui_tab","z":"","name":"SVG","icon":"dashboard","disabled":false,"hidden":false}]

```

It contains a fontawesome icon (for the camera), with id "cam\_living\_room":

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/3/b3d08a958e7bcb0e118257a7617d2153cd40a706.png)

In the inject node, I apply a _ **"fill"** _ style with color red to the element with that id:

```auto
{
    "command": "update_style",
    "selector": "#cam_living_room",
    "attributeName": "fill",
    "attributeValue": "red"
}

```

This is the result:

![color_demo](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9a70e67b06f891745ec00e8f040980c56a2a5d82.gif)

I will create a wiki page on my Github repository with this example.  
Should add some more tutorials to the wiki, but no time for that at the moment...

---

<div class="post-metadata">

**Author:** ![nodebeginner](https://avatars.discourse-cdn.com/v4/letter/n/dc4da7/32.png) [@nodebeginner](https://discourse.nodered.org/u/nodebeginner)\
**Post date:** [25 February 2020 23:26 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/5 "2020-02-25T23:26:45Z")

</div>

Ok got it. Turns out I was using the wrong "command" for the inject node. Thanks!

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [26 February 2020 21:19 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/6 "2020-02-26T21:19:32Z")

</div>

I have added a new tutorial to the SVG node's [wiki page](https://github.com/bartbutenaers/node-red-contrib-ui-svg/wiki), which explains how to change a style attribute (e.g. fill color) in two ways: as an SVG fill attribute, or as a CSS style fill attribute. Hopefully that makes it easier to understand for other users...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 April 2020 21:19 UTC](https://discourse.nodered.org/t/beginner-help-with-node-change-fill-color-svg-graphics/22258/7 "2020-04-26T21:19:40Z")

</div>

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