Home

Awesome

gauge-hotnipi

A nice looking gauge W3C component gifted by hotnipi for use with Node-RED, uibuilder and other uses

HTML Attributes

Overridable CSS

The following CSS variables can be used to override the defaults.

--needle-color
--zone-color-high
--zone-color-warn
--zone-color-normal
--zone-color-low

Also - originally from the UIBUILDER uib-brand.css:

/* Background colours */
--surface1, --surface2, --surface3, --surface4, --surface5
/* Text colour */
--text3

Example - Change attributes in JavaScript

Forces a redraw.

document.getElementById('gauge').setAttribute('digits',JSON.stringify({size:80,distance:15}))
document.getElementById('gauge').setAttribute('max',1200)

Example - Node-RED Dashboard

Add this to a ui_template node:

<script src="/js/gauge-hotnipi.js"></script>
<template>
    <gauge-hotnipi ref="hotgauge" min="0" max="100" size="180px" platehue="220" digits='{"size":80,"distance":14}'></gauge-hotnipi>
</template>

<script>
    export default {
        methods: {
            getElement: function(name,base){
                if(base){
                    return this.$refs[name][0]                    
                }
                return this.$refs[name]                
            }
        },
        
        watch: {
            msg: function(){
                if(this.msg.payload != undefined){
                    this.getElement("hotgauge").update(this.msg.payload)                    
                }
            }
        }
    }
</script>

References