The received data is not displayed by ngx-gauge

Currently, I am working on a project that involves displaying real-time data from a server. During the testing phase using MQTT client WebSocket tools like HiveMQ, I encountered an issue. While I can see the value of the data in the Chrome console, I'm struggling to visualize this value graphically using NGX-GAUGE.

When attempting to retrieve the value from an MQTT broker, the ngx-gauge component fails to update the gauge's green line in real time as expected.

import { Component, OnInit } from '@angular/core';
import { Paho } from 'ng2-mqtt/mqttws31';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {


  valore:String;    

  gaugeType = "semi";
  gaugeValue=this.valore;
  gaugeLabel = "Valore";
  gaugeAppendText = "km/hr";s
  animate=true;
  duration=1500;

  private client;
  mqttbroker = 'broker.mqttdashboard.com';

  ngOnInit() {
    this.client = new Paho.MQTT.Client(this.mqttbroker, Number(8000), 'client1');
    this.client.onMessageArrived=this.onMessageArrived.bind(this);
    this.client.onConnectionLost=this.onConnectionLost.bind(this);
    this.client.connect({onSuccess: this.onConnect.bind(this)});
   }

  onConnect() {
    console.log('onConnect');
    this.client.subscribe('testtopic/40/xxx');
  }

  onConnectionLost(responseObject) {
    if (responseObject.errorCode !== 0) {
      console.log('onConnectionLost:' + responseObject.errorMessage);
    }
  }

  onMessageArrived(message) {
    console.log('onMessageArrived: ' + message.destinationName + ': ' + message.payloadString);

    if (message.destinationName.indexOf('xxx') !== -1) {
      this.valore = (message.payloadString);
    }
  }
}

The goal is to display the value and have the ngx-gauge's line respond in real time according to that value.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for moving a texture horizontally across a sphere using threejs

I have a 360 degree viewer tool. Is there a way to load a texture in a specific position that will rotate the original image by a certain number of degrees or units around the Y-axis without altering anything else about how the picture is displayed? If s ...

What is the optimal resolution for a background image in a Cordova app?

Currently working on a Cordova application that requires different background images for various screens. Despite using media queries to provide the background image in different resolutions, we are facing an issue where the background image is not displ ...

The issue of Chrome not updating when resizing the window in jQuery

I've encountered an issue while using jQuery to obtain the height of a specific element, as this measurement changes when someone resizes their browser window. Below is the code snippet I am currently using: $(function() { var wheight = $('. ...

What is the best way to iterate through one level at a time?

Imagine a scenario where the structure below cannot be changed: <xml> <element name="breakfast" type="sandwich" /> <element name="lunch"> <complexType> <element name="meat" type="string" /> <element name="vegetab ...

Tips for positioning a DOM element in the top right corner

I have a piece of code that currently works, but I'm curious to find out if there is a better way to position a DOM element on the top right of a container. Here are the prerequisites: 1) The structure of the DOM cannot be altered. 2) The CSS cod ...

What steps do I need to take to implement AJAX form authentication?

I have set up a login screen that validates username and password credentials through a php script. When a user enters their information and submits the form, the authenticate.php file executes an LDAP bind. If the credentials are correct, the user is redi ...

Tips to prevent the @click event from firing on a specific child component

When I click on any v-card, it redirects me to a different link. However, if I click on the title "World of the Day", I don't want anything to happen. How can I prevent being redirected when clicking on the title? https://i.sstatic.net/BM1gf.png tem ...

Picked (chosen-js): Steps to deselect options using a variety of selectors

I am currently using the Chosen library on Vue and Webpack for my project. I have a scenario where I need to cancel a selection when multiple options are selected, but I am struggling to achieve this. Can anyone guide me on how to cancel a selected optio ...

Leverage Jquery within the div element to manipulate the data retrieved from a post ajax request

On my one.jsp page, I have the following post code: $.post("<%=request.getContextPath()%>/two.jsp", { vaedre: fullDate} ,function(result){ $("#theresult").append(result); }); This code generates the followi ...

Iterating through elements with JavaScript and dynamically replacing them in the HTML code

I'm struggling with the code I found on CodePen and need some help with it since I'm not very good with JS. How can I prevent the items from repeating endlessly? Currently, they scroll indefinitely with 20 items per 'page' before the ...

The custom error handling middleware in Express.js appears to be ineffective for certain error cases

The custom error handler code snippet provided below: export const errorHandler: ErrorRequestHandler = (err, _, res) => { if (err instanceof HttpError) { res.status(err.statusCode).json({ message: err.message }); return; } res.st ...

What is the most effective method for flipping a THREE.Sprite in r84?

After updating my game engine from r69 to r84, I encountered a few issues. One of them is related to flipping sprites. In the past, I could easily flip sprites using the following code: sprite.scale.x = -1; Unfortunately, this method no longer works in ...

Transmitting data for a PHP variable within Wordpress.org

I am a newbie when it comes to PHP programming. Currently, I am working on a WordPress web page where selecting an option from a drop-down menu and clicking a button labeled "Consultar" in a form should display the queried data in a table below. However, ...

The content within the hyperlinked text

<ul class="Buttons"> <li><a href="#" onclick="myFunc(); return false;">Accept</a></li> <li><a href="#" onclick="myFunc(); return false;">Reject</a></li> <li><a href="#" onclick="myF ...

An unexpected 'foo' key was discovered in the current state being processed by the reducer when using redux-toolkit's configure store and a customized store enhancer

I've been working on developing a custom store enhancer to add new values to my root state. However, I've encountered an unexpected key error after delving into the complexities of custom enhancers. While I can see the new state part in devtools ...

Phantom.js callback Reference error experienced while optimizing Phantom.js on Node.js/Express.js to eliminate the problem of excessive callbacks

I've been working on this extensive block of code that works, but I'm looking to refactor it properly. Following the principles outlined in Callback Hell, I attempted to break it down into non-anonymous functions and separate them from the main c ...

Step-by-step guide for sending data using module.exports in a node.js application

Currently, I am working on implementing a feature that will allow users to input data and store it in a database collection. The technologies I am using for this project are Node.js, MongoDB, Mongoose, Express.js, and AJAX. My goal is to capture user inpu ...

Connecting buttons to JavaScript functions that interact with MySQL database entries

I am working on a task involving rendering a database table using XMLHttpRequest in JavaScript to a PHP page. My goal is to display each entry from the table as an HTML row/cell with two buttons within each "entry". These buttons should trigger specific Ja ...

Choose an XPath selector that targets a list item within a specific div element

Currently, I am using selenium to conduct testing on a website. I have employed an XPath selector in order to locate a specific item within the HTML structure: <div id="boundlist-1051" class="x-boundlist list_cfg_cls x-boundlist-floating x-layer x-boun ...

Control click events using a counter and add stylish transitions to both disable and re-enable them

I’m looking for some assistance with the code snippets on my webpage - check it out here. HTML: <button class="wrong-answer" onclick="showResult(this)">42</button> <button class="right-answer" onclick="showResult(this)">43</button& ...