Skip to main content
lxw
Associate III
August 19, 2021
Question

How to use graph to create two lines and add data to each.

  • August 19, 2021
  • 12 replies
  • 3509 views

I want to use graph drawing 2 line, in the MainView: : handleTickEvent () used in the graph. addDataPoint () to add data respectively?

Another requirement, line needs to be separated by some pixels, how to set.:face_with_tears_of_joy:

This topic has been closed for replies.

12 replies

ktrofimo
Senior III
August 19, 2021

You need to add second line for DynamicGraph widget. And call addDataPoint() twice:

graph.addDataPoint( Value1 );

graph2.addDataPoint( Value2 );

lxw
lxwAuthor
Associate III
August 19, 2021

  What I want is to draw two lines in a graph. Can only one line be drawn in a graph?

 dynamicGraph1.addGraphElement(dynamicGraph1Line1);

  dynamicGraph1.addGraphElement(dynamicGraph1Line2);

ktrofimo
Senior III
August 19, 2021

You can add many lines on the same DynamicGraph in TouchGFX Designer. Use them like the first one.

Here is my test: the first graph (yellow) is sine with random noise and second one (blue) is slider value (61)

0693W00000DpmyDQAR.jpg

ktrofimo
Senior III
August 19, 2021

Your picture is a SINGLE graph line. This is a method of drawing large amount of data points when new data is overwrites old one in a circular buffer.

Take a note of X axis labels: 1270-1300 is an old data being replaced by new one (1300-1360)

lxw
lxwAuthor
Associate III
August 19, 2021

Yes, how do I make Xnew = (Xold+100), keep the gap equal to 100

ktrofimo
Senior III
August 19, 2021

Can you draw what exactly you need on a sheet of paper?

lxw
lxwAuthor
Associate III
August 20, 2021

Line1 is the current effect, I want to achieve the effect of line2, the middle interval is wider0693W00000Dpsh3QAB.jpg

lxw
lxwAuthor
Associate III
August 20, 2021

Hopefully it can be improved in the future