# Gauge with pointer centred

**URL:** <https://discourse.nodered.org/t/gauge-with-pointer-centred/66375>\
**Category:** General\
**Created:** [12 August 2022 23:52 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375 "2022-08-12T23:52:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackHenry99](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jackhenry99/32/65160_2.png) [@JackHenry99](https://discourse.nodered.org/u/JackHenry99)\
**Post date:** [12 August 2022 23:52 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/1 "2022-08-12T23:52:48Z")

</div>

Hi

I'm looking for a gauge that will display solar panel information as to whether I'm drawing from the grid or the panel. I want zero to be the centre. If drawing from the grid, the gauge should move anticlockwise and clockwise when drawing from the panels. I've search for this without success.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 August 2022 00:00 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/2 "2022-08-13T00:00:52Z")

</div>

I hesitate to ask, but have you tried setting the gauge minimum to a negative number and the maximum to a positive number?  
 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec695ac7dc49fa970049674da569d734e9c98ac1.jpeg)

![Untitled 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/760ca7822c878cb684999f69101e2c01b06fb937.jpeg)

---

<div class="post-metadata">

**Author:** ![JackHenry99](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jackhenry99/32/65160_2.png) [@JackHenry99](https://discourse.nodered.org/u/JackHenry99)\
**Post date:** [13 August 2022 00:47 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/4 "2022-08-13T00:47:58Z")

</div>

OMG. I didn't think it was that simple.

Thanx muchly

Is there a way to get the colour to follow the needle, so that the colour goes from the zero position rather than the full left position?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 August 2022 00:51 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/5 "2022-08-13T00:51:19Z")

</div>

You might be able to do that with node-red-contrib-ui-artless-gauge, not sure.

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [13 August 2022 08:28 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/6 "2022-08-13T08:28:14Z")

</div>

To echo what @jbudd suggests,  
here is an animated gif of my gauges going from positive to negative.  
Take a few seconds to see the animation, these are real values and there is some normal latency.  
 ![demo-gauge-artless](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d683b2ab494b9e198702475ff9d35b5e26a4c873.gif)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [13 August 2022 10:49 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/7 "2022-08-13T10:49:19Z")

</div>

You can use ui\_control to hide needle and colour left right on positive or negative, on a ui-gauge set to donut.  
e.g.

```auto
[{"id":"28100460.a4b09c","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":150,"y":2660,"wires":[["7bbe61b3.327768"]]},{"id":"7bbe61b3.327768","type":"function","z":"30af2d3e.d94ea2","name":"","func":"msg.ui_control = {\n \"min\":0,\n \"max\":100,\n \"gtype\":\"donut\",\n \"options\":{\n \"donutStartAngle\":90,\n \"pointer\":false,\n \"levelColors\": [\"#00FF00\",\"#00FF00\",\"#00FF00\"]\n }\n}\nlet display_degree = 360; // 360 or 180\nif(msg.payload > 0) {\n msg.positive = \"+\";\n}else if(msg.payload < 0) {\n msg.positive = \"-\";\n msg.payload = Math.abs(msg.payload)\n msg.ui_control.options.donutStartAngle = 450 - (msg.payload * (display_degree / msg.ui_control.max));\n msg.ui_control.options.levelColors = [\"#ff0000\",\"#ff0000\",\"#ff0000\"];\n} else {\n msg.positive = \"\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":2740,"wires":[["38e75ce6.317f3c","52b6d283.4a8ff4"]]},{"id":"3f8bf1b4.674f9e","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":130,"y":2740,"wires":[["7bbe61b3.327768"]]},{"id":"63673ae9.530344","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-15","payloadType":"num","x":110,"y":2800,"wires":[["7bbe61b3.327768"]]},{"id":"e90e283f.5e234","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-48","payloadType":"num","x":110,"y":2840,"wires":[["7bbe61b3.327768"]]},{"id":"f3569b41.944de8","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-100","payloadType":"num","x":130,"y":2880,"wires":[["7bbe61b3.327768"]]},{"id":"aaf2f9c0.686bb","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55","payloadType":"num","x":130,"y":2700,"wires":[["7bbe61b3.327768"]]},{"id":"38e75ce6.317f3c","type":"ui_gauge","z":"30af2d3e.d94ea2","name":"","group":"2d4fe667.28f8ba","order":9,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"","format":"{{msg.positive}}{{value}}","min":"0","max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":500,"y":2680,"wires":[]},{"id":"52b6d283.4a8ff4","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"ui_control","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":2580,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

 ![chrome_screenshot_1660387692519](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a769eb8f9926f45845b70ef61e74e4df8960838e.png)

 ![chrome_screenshot_1660387574854](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/082680bc06a31383b617d899f7221755d3e5e0bc.png)

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [13 August 2022 11:41 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/8 "2022-08-13T11:41:55Z")

</div>

so I hesitate to change my gauges.  
I find this one very readable at a glance

---

<div class="post-metadata">

**Author:** ![JackHenry99](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jackhenry99/32/65160_2.png) [@JackHenry99](https://discourse.nodered.org/u/JackHenry99)\
**Post date:** [14 August 2022 11:29 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/9 "2022-08-14T11:29:01Z")

</div>

Nice. What code change is needed to get the Gauge to function in this way but with the half circle shape that displays when you have 'gauge' rather than 'donut' selected,

Regards  
John

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [14 August 2022 15:12 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/10 "2022-08-14T15:12:20Z")

</div>

It can not be done on gauge. Only works on donut and compass. You can force the donut and compass to do full circle left and rights or 90% of circle or any % you wished.

You could do this with the gauge, going from left to right for positive, and right to left for negative.

```auto
[{"id":"28100460.a4b09c","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":150,"y":2660,"wires":[["7bbe61b3.327768"]]},{"id":"7bbe61b3.327768","type":"function","z":"30af2d3e.d94ea2","name":"","func":"msg.ui_control = {\n \"min\":0,\n \"max\":100, \n \"gtype\":\"gauge\",\n \"options\":{\n \"gaugeColor\":\"#808080\",\n \"pointer\":true,\n \"levelColors\": [\"#00FF00\",\"#00FF00\",\"#00FF00\"]\n }\n}\nif(msg.payload < 0) {\n msg.ui_control.options.min = -100;\n msg.ui_control.options.max = 0;\n msg.ui_control.options.gaugeColor = \"#ff0000\";\n msg.ui_control.options.levelColors = [\"#808080\",\"#808080\",\"#808080\"];\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":2740,"wires":[["52b6d283.4a8ff4","38e75ce6.317f3c"]]},{"id":"3f8bf1b4.674f9e","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":130,"y":2740,"wires":[["7bbe61b3.327768"]]},{"id":"63673ae9.530344","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-15","payloadType":"num","x":110,"y":2800,"wires":[["7bbe61b3.327768"]]},{"id":"e90e283f.5e234","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-48","payloadType":"num","x":110,"y":2840,"wires":[["7bbe61b3.327768"]]},{"id":"f3569b41.944de8","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-100","payloadType":"num","x":130,"y":2880,"wires":[["7bbe61b3.327768"]]},{"id":"aaf2f9c0.686bb","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55","payloadType":"num","x":130,"y":2700,"wires":[["7bbe61b3.327768"]]},{"id":"52b6d283.4a8ff4","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"ui_control","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":2580,"wires":[]},{"id":"38e75ce6.317f3c","type":"ui_gauge","z":"30af2d3e.d94ea2","name":"","group":"2d4fe667.28f8ba","order":9,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"","format":"{{value}}","min":"0","max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":640,"y":2740,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

The same gauge receiving 55 and -48.

 ![chrome_screenshot_1660496317358](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/ed8d56328ed773fc2b9f47177e4712d6dfc6a4af.png)

 ![chrome_screenshot_1660496105811](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/89a4b41e274e61849027a2a75257043ad3310b7e.png)

Or you can do this

```auto
[{"id":"28100460.a4b09c","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":150,"y":2660,"wires":[["7bbe61b3.327768"]]},{"id":"7bbe61b3.327768","type":"function","z":"30af2d3e.d94ea2","name":"","func":"msg.ui_control = {\n \"min\":-100,\n \"max\":100, \n \"gtype\":\"gauge\",\n \"options\":{\n \"gaugeColor\":\"#808080\",\n \"pointer\":true,\n \"levelColors\": [\"#00FF00\",\"#00FF00\",\"#00FF00\"]\n }\n}\nif(msg.payload < 0) {\n msg.ui_control.options.gaugeColor = \"#ff0000\";\n msg.ui_control.options.levelColors = [\"#808080\",\"#808080\",\"#808080\"];\n}else if(msg.payload === 0){\n msg.ui_control.options.gaugeColor = \"#808080\";\n msg.ui_control.options.levelColors = [\"#808080\",\"#808080\",\"#808080\"];\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":2740,"wires":[["52b6d283.4a8ff4","38e75ce6.317f3c"]]},{"id":"3f8bf1b4.674f9e","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":130,"y":2740,"wires":[["7bbe61b3.327768"]]},{"id":"63673ae9.530344","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-15","payloadType":"num","x":110,"y":2800,"wires":[["7bbe61b3.327768"]]},{"id":"e90e283f.5e234","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-48","payloadType":"num","x":110,"y":2840,"wires":[["7bbe61b3.327768"]]},{"id":"f3569b41.944de8","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"-100","payloadType":"num","x":130,"y":2880,"wires":[["7bbe61b3.327768"]]},{"id":"aaf2f9c0.686bb","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55","payloadType":"num","x":130,"y":2700,"wires":[["7bbe61b3.327768"]]},{"id":"52b6d283.4a8ff4","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"ui_control","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":2580,"wires":[]},{"id":"38e75ce6.317f3c","type":"ui_gauge","z":"30af2d3e.d94ea2","name":"","group":"2d4fe667.28f8ba","order":9,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"","format":"{{value}}","min":"0","max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":640,"y":2740,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

 ![chrome_screenshot_1660567807930](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/997c447985c4ec08786c3102681434716e18c73d.png)

 ![chrome_screenshot_1660567896450](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/8585f13443caf0f86567e17e6ed8f87a6ad3a2cc.png)

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

---

<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:** [13 October 2022 15:13 UTC](https://discourse.nodered.org/t/gauge-with-pointer-centred/66375/11 "2022-10-13T15:13:17Z")

</div>

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