Skip to main content
Shree
Associate III
October 28, 2020
Question

How to add timestamp as a label on X-axis for dynamic graph in TouchGFX?

  • October 28, 2020
  • 3 replies
  • 3906 views

Hi,

I am working on implementing the graph using Dynamic graph widget which was recently introduced in latest TouchGFX release. In our application we collect data points after regular time interval e.g We may collect 144 data points for 12 hours. So, I want to plot the chart for parameters values Vs Time. To do that I need to show a time as X-axis label.

As I am selecting the number of data points as 144 here, it by default configure the label according to number of data points. So, how can I show time on X-axis and parameter value on Y-axis?

BR,

Shree

This topic has been closed for replies.

3 replies

GPa.1
Associate II
December 8, 2020

Hi Shree,

Did you find a way to add the timestamp?

JureL
Associate III
January 11, 2021

I have a similar need to display temperature over time. I would like to display the timestamp on X axis and temperature on Y. @Martin KJELDSEN​ any suggestion or perhaps example of that?  

Romain DIELEMAN
ST Employee
January 11, 2021

Hi,

I am a little bit confused by what the issue is. The UI template " Dynamic graph example" in TouchGFX Designer displays random values over time: at every second tick of the system a random point is displayed as you can see in the following code in mainscreen.cpp

void MainView::handleTickEvent()
{
 tickCounter++;
 
 // Insert each second tick
 if (tickCounter % 2 == 0)
 {
 float yMax = graph.getGraphRangeYMaxAsFloat();
 
 // Insert "random" points along a sine wave
 graph.addDataPoint((int)((sinf(tickCounter * .02f) + 1) * (yMax / 2.2f)) + randomish(tickCounter) % (int)(yMax / 10.f));
 }
}

To my understanding for your project you just need to replace the random value by the temperature and plot it whenever you want (so every 5 minutes for example instead of every two ticks like in the demo). If you want a timestamp like 1970-01-01 00:00:01 you can write it by yourself in the label section of a dynamic graph property setting or you can add an extra textArea widget under the x axis.

Please correct me and guide me if I am completely out of topic.

Best regards,

Romain

JureL
Associate III
January 12, 2021

Hey @Romain DIELEMAN​ ​ ,

I apologize for the unclear question.  I want to know how to add label like you said : 1970-01-01 00:00:01. For example: we measure temperature every  15 seconds so when temperature is measured i want to add point in graph with corresponding timestamp which is shown on x axis. Is there any example on how to do that ?

Here is a example of what I want:

0693W000007ArCSQA0.png

Paulo Rego
Associate II
December 4, 2023

Yes, I also ask the same please