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.
💪 don't let anyone get you down 💪
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.
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).
-
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.
Distributed under the MIT License. See LICENSE.txt for more information.