Skip to content

Add QtGraphs-based analysis page to AdvancedPy example#39

Open
AndrewSazonov wants to merge 11 commits intodevelopfrom
qtgraphs
Open

Add QtGraphs-based analysis page to AdvancedPy example#39
AndrewSazonov wants to merge 11 commits intodevelopfrom
qtgraphs

Conversation

@AndrewSazonov
Copy link
Copy Markdown
Member

This PR adds a new Analysis page to the AdvancedPy example and connects it to both mock QML and real Python backends.

Analysis page includes:

  • a QtGraphs chart page for generated analysis data
  • sidebar controls for point count and regenerating data

@AndrewSazonov AndrewSazonov added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels Mar 23, 2026
@AndrewSazonov AndrewSazonov marked this pull request as ready for review March 24, 2026 15:35
@AndrewSazonov AndrewSazonov requested a review from rozyczko March 25, 2026 08:02
Copy link
Copy Markdown
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor issues found. Please consider before merging.


QtObject {

property int dataSize: 50
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default dataSize in corresponding analysis.py is set to 10000. Why the difference?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mismatch is intentional. In the mock backend I only generate random noise, so I kept the dataset small to keep the chart responsive during QML-side development. In the Python backend the generated data is closer to a real peak pattern, and I chose 10000 to demonstrate that chart updates are still smooth at that size.

Comment on lines +56 to +60
//visible: true
//gridVisible: false
//subGridVisible: true
//labelsVisible: true
//subTickCount: 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of commented-out code in this file. Please either comment on why it needs to stay or remove.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I left those comments there mainly as a reminder of the chart styling properties supported by QtGraphs. My plan is to use this example as a basis for a reusable chart template in EasyApp/Gui/Charts, so we do not have to repeat a large block of theme configuration in each chart. I will remove it once this reusable chart template is implemented.

Comment on lines +62 to +63
labelDelegate: TextEdit {
horizontalAlignment: TextInput.AlignHCenter
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be TextEdit? Are you expected to be able to edit axis labels?
I think you meant labelDelegate: Text

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is supposed to be non-editable text. Thanks for catching that.

Comment on lines +95 to +97
mvx = memoryview(x)
mvy = memoryview(y)
return [QPointF(xi, yi) for xi, yi in zip(mvx, mvy)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memoryview avoids copying indeed, but when you later iterate over it with zip, each element is still converted from the memoryview into a Python float object before being passed to QPointF.
You're still doing float conversion...

>>> a = np.array([1.0, 2.0])
>>> for x in memoryview(a):
...     print(type(x))
<class 'float'>
<class 'float'>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, memoryview does not help here. I removed it and simplified the helper.

Comment on lines +67 to +68
x, y = self._generate_data(n_points=self.dataSize)
console.debug(" Data generation completed.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No exception handling on results from _generate_data, which might throw.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added exception handling in generateData() so failures are logged instead of propagating into the UI.

@AndrewSazonov AndrewSazonov self-assigned this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants