https://github.com/criogenox/custom-zooming-and-tracking-for-charts-using-pure-qt
Extending zoom actions and label tracking capabilities to Qt6 chart series.
https://github.com/criogenox/custom-zooming-and-tracking-for-charts-using-pure-qt
cpp-project desktop-app gui-application labeling qt6 qtcharts scrolling tracking zooming
Last synced: 6 months ago
JSON representation
Extending zoom actions and label tracking capabilities to Qt6 chart series.
- Host: GitHub
- URL: https://github.com/criogenox/custom-zooming-and-tracking-for-charts-using-pure-qt
- Owner: criogenox
- License: mit
- Created: 2024-11-29T17:45:39.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-12-05T03:53:28.000Z (10 months ago)
- Last Synced: 2025-02-01T20:46:07.609Z (8 months ago)
- Topics: cpp-project, desktop-app, gui-application, labeling, qt6, qtcharts, scrolling, tracking, zooming
- Language: C++
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![LinkedIn][linkedin-shield]][linkedin-url]
## About the work
> While trying to create and manipulate Qt charts for another project, I realized that the functionalities I needed do not exist freely as I would like it to work. So I started making and testing some code until everything was transformed into this repository. As simple as that, and perhaps it could be helpful for another soul.`Key Features:`
- Complete chart zooming and scrolling capabilities.
- Label-tracking functionalities for individual series.
:muscle: don't let anyone get you down :muscle:
## Background & Details### Custom zoom class
> Zooming and scrolling triggered by mouse wheel movements, press/release mouse events and keyboard toggle actions, allowing an improved data visualization and analysis of large datasets, and providing a more intuitive user experience.
**Implementation:**
Features implemented by overridden event handlers for mouse and keyboard inputs (mousePressEvent, mouseMoveEvent, mouseReleaseEvent ,mouseDoubleClickEvent, wheelEvent, keyPressEvent).
`Functionalities:`
- Wheel zoom focusing on cursor position, enhancing data's on focus experience.
- Support for horizontal panning by x-axis range adjustment (axis clipping)
- Handles double-click events to fit the chart within the view, according to the original axes range.
- Zoom-in by drag/selection rubber band area.
- Handles mouse press events to dragging and panning (warning, inverted mouse buttons).
- Restricted zoom limits/range preventing excessive zooming far beyond the available data range.
### Tracking class
> Two label-tracking functionalities for enhancing the interactivity of the chart by dynamic custom tooltips (labels) creation, displaying relevant data information as points are hovered or intersected by a track line. It improves data comprehension by visual associating, reducing extra needs for navigating or streamlining the data exploration process.
**Implementation:**
- Custom tooltips are created as QLabel widgets and are dynamically positioned based on the mouse cursor's vertical coordinate.
- The mouse movement events are captured by signal/slot mechanism, updating the tooltip content and positioning it accordingly.
- Label displaying duration is controlled by a timer signal/slot mechanism and tooltip visibility is managed through a proper logic flow, preventing overlapping effects and over cluttering the interface.
`Functionalities:`
- Real-Time labeling by mouse hovering or track-line intersection over the chart, reflecting the current position and data point.
- Customizable appearance: custom tooltips styled by series colors, size, borders and padding, line width, shadow effects, text font and alignment, and other Qt flags and attributes.
- Support for data and axes labels, and cursor tooltip.
- Support for QLinesSeries & QSplineSeries.
- Handles crosshair (continuous lines) and truncated track lines (visually emphasizing the intersection effect).
## Built With
![]()
![]()
![]()
### Additional info
- Tested on Ubuntu 22.04 using Qt6.7.2
- Extensive checking of instance deletion to ensure proper and effective resource management, preventing memory leaks.
- For a more in-depth understanding of the implemented method, as many comments as possible have been included.## General view sample
![]()
Tracking functionality in use: series' individual labeling by crosshair.
## License
Distributed under the MIT License. See [LICENSE.txt][license-url] for more information.
[linkedin-shield]: https://user-images.githubusercontent.com/53323058/230575198-fa1acbf4-8f82-4d8e-b245-3979276bc240.png
[linkedin-url]: https://www.linkedin.com/in/criogenox/
[eqsreadme-url]: https://github.com/criogenox/E-Symbolic-Railway-Dynamics-Formulation/tree/master/eqs2latex
[eqssrc-url]: https://github.com/criogenox/E-Symbolic-Railway-Dynamics-Formulation/tree/master/eqs2latex/src
[ginac-url]: https://www.ginac.de/
[license-url]: https://github.com/criogenox/All-in-one-Zoom-and-Tracking-for-Qt-Charts/tree/master?tab=MIT-1-ov-file