Skip to main content
BParh.1
Senior III
March 23, 2021
Solved

How to make Fixed X-Label axis

  • March 23, 2021
  • 9 replies
  • 2179 views

I need to make application of pressure measurement across time by using dynamic graph feature. The X axis is time from 0 - 10 s. But as times go by beyond 10s, I want the X axis label remain as 0...10s instead of incremented for every data point added i.e. addDataPoint(float newData)

How to do this?

This topic has been closed for replies.
Best answer by Michael K

Perhaps my forum post on this topic from a few months ago will help you.

9 replies

Alexandre RENOUX
Visitor II
March 24, 2021

Hello BParh.1,

Unfortunately you cannot because it's a Dynamic Graph not a Static graph. Meaning that if the number of points goes above the number that can be shown at once on the screen, the x axis will be incremented.

One way is to modify the Graph widget and prevent it from updating the x axis when the graph is cleared. I'll come back to you when I discover how.

/Alexandre

BParh.1
BParh.1Author
Senior III
March 24, 2021

thank you @Alexandre RENOUX​ , looking forward for it :smiling_face_with_smiling_eyes: .

Soda
Associate II
March 24, 2021

@BParh.1​  This is a good question, I'm looking for the solution too.

Alexandre RENOUX
Visitor II
March 25, 2021

Hello BParh.1,

You will find enclosed a project that does not update the X axis.

Since we need to modify the graph widget, it's mandatory to create your own widget (I put the files in the /common folder). Consequently, you cannot visualize the graph in the Designer anymore.

I had to copy/paste the files AbstractDataGraph.cpp/hpp and GraphWrapAndClear.cpp/hpp rename them to MyAbstractDataGraph and MyGraphWrapAndClear.

And I simply commented the content of invalidateXAxisPointAt(int16_t index) and invalidateAllXAxisPoints().

For simplicity in the initialization of the custom graph, I created a graph in Designer and set it to Visible(false).

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

BParh.1
BParh.1Author
Senior III
March 30, 2021

Thank you @Alexandre RENOUX​ , could you point me where in the code this happens:

"One way is to modify the Graph widget and prevent it from updating the x axis when the graph is cleared"

Alexandre RENOUX
Visitor II
March 31, 2021

Hello BParh.1,

This is exactly what I explained before : "commented the content of invalidateXAxisPointAt(int16_t index) and invalidateAllXAxisPoints()"

/Alexandre

BParh.1
BParh.1Author
Senior III
March 31, 2021

Thank you @Alexandre RENOUX​ , I take a look the implementation, but I would probably explore more with hope a simpler approach exist instead of making a custom behavior change to the platform code (i.e. The code changes remain in user code section).

Basically what I want to achieve is create dynamic graph for real time analog measurement for every 0.1s where the X axis showing normalized value 0 - 10s (i.e for every 1s interval there are actually 10 data points).

Michael K
Michael KBest answer
Senior III
April 1, 2021

Perhaps my forum post on this topic from a few months ago will help you.

Embedded UI/UX Consulting: cadenza.design
BParh.1
BParh.1Author
Senior III
April 6, 2021

thank you @Michael K​ , could you share the code snippet please? I would like to understand how you manage to reset the X-label counter