cancel
Showing results for 
Search instead for 
Did you mean: 

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

EWqqr.1
Associate II

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?

8 REPLIES 8
ktrofimo
Senior III

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 );

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:

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 Employee

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

Osman SOYKURT
ST Software Developer | TouchGFX
EWqqr.1
Associate II

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

0693W00000Ka4siQAB.jpg

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

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.

Osman SOYKURT
ST Software Developer | TouchGFX

So its still not possible to add multiple lines into single data graph. Instead of that, you have to create N data graphs and allocate way more RAM?