Skip to main content
EWqqr.1
Associate
Feb 22, 2022 7:59 AM UTC
Question

How to add different data for two lines in one dynamic graph?

Hi,i want to make a oscilloscope to show two data curve.I found the dynamicgraph can add many lines with different color.BUT i can only use the "addDataPoint" fuction to add one data at one time.So I set the two lines the different LineWidth.

Just like this.

0693W00000Ka2OqQAJ.jpgThese two lines show the same data,becuse the addDataPoint function can just input one variate.0693W00000Ka2RBQAZ.pngI want to know how can i draw multiple lines that show the different data in one dynamic graph?

This topic has been closed for replies.

9 replies

ktrofimo
Senior III
Feb 22, 2022 8:32 AM UTC

Every line on the graph will be presented as dynamicGraphX (or whatever you have named it) class.

Then you should add all data at the same time:

dynamicGraph1.addDataPoint( value1 );
dynamicGraph2.addDataPoint( value2 );
dynamicGraph3.addDataPoint( value3 );

EWqqr.1
EWqqr.1Author
Associate
Feb 22, 2022 8:44 AM UTC

0693W00000Ka2e5QAB.pngI just create one dynamicgraph widget,it will be error.

0693W00000Ka2guQAB.pngI want to show these two lines which in the right just in dynamicgraph1.:persevering_face:

ktrofimo
Senior III
Feb 22, 2022 9:52 AM UTC

Check your Screen1ViewBase.hpp header for correct names. They should be of type touchgfx::GraphScroll<NNN> like:

touchgfx::GraphScroll<100> dynamicGraph1;
touchgfx::GraphScroll<100> graph2;
touchgfx::GraphScroll<100> graph3;

Then use those classes.

Osman SOYKURT
ST Technical Moderator
Feb 22, 2022 11:29 AM UTC

Hello EWqqr.1,

I wouldn't recommend you to use 2 lines elements for a single dynamic graph widget. The easiest way would be to use 2 different widgets like this :

0693W00000Ka4XQQAZ.png 

Be careful to uncheck the boxes on "Vertical Grid Lines", "Horizontal Grid Lines", "X-Axis Labels" and "Y-Axis Labels". That way, you will have 2 independent graph lines in the same view.

0693W00000Ka4W4QAJ.png 

I attached a basic project if you need an example.

/Osman

ST Software Developer | TouchGFX
ktrofimo
Senior III
Feb 22, 2022 12:34 PM UTC

It would be nice if you could explain why you do not recommend to use multiple lines with single dynamicGraph object.​

Osman SOYKURT
ST Technical Moderator
Feb 22, 2022 2:02 PM UTC

It's not the easiest way to do. Indeed the lines are instances of GraphElementLines class, and you can't use addDataPoint() function with them.

ST Software Developer | TouchGFX
EWqqr.1
EWqqr.1Author
Associate
Feb 22, 2022 11:48 AM UTC

Thank you all.I create two dynamic graph and align them.The program ran successfully now.

0693W00000Ka4siQAB.jpg

GMeur
Associate III
Aug 29, 2025 11:49 AM UTC

Yeah, it should definitely be improved