Charty Documentation
repository·main·Indexed 23 days ago
https://github.com/hi-manshu/chartyA lightweight, elementary charting library for Jetpack Compose with Kotlin Multiplatform (KMP) support. Includes tools like TooltipManager and rememberTooltipManager for managing chart tooltip states and data point spatial bounds.
What's inside Charty
- Charty is a sleek and lightweight charting library designed for Jetpack Compose. It features support for Kotlin Multiplatform (KMP), making it suitable for cross-platform development. It is intended for developers looking for an elementary charting solution within the Compose ecosystem.
Use TooltipManager to manage chart tooltips
mainThe
TooltipManagerclass provides a centralized way to manage tooltip display state and track the spatial bounds of data points (e.g.,Offsetfor points orRectfor bars) during chart interactions.Key functionalities include:
- State Tracking: Maintains
tooltipStatewhich is null when no tooltip is visible. - Bounds Management: Stores a list of
bounds(the geometry) paired withT(the associated data). UseclearBounds()at the start of each draw cycle to reset the tracked items. - Interaction Control: Use
updateTooltip(state)to show a tooltip ordismiss()to hide it.
In a Compose environment, use
rememberTooltipManager<B, T>()to create and persist the manager instance across recompositions.- State Tracking: Maintains
TooltipManager API Reference
mainTheTooltipManagerclass provides the following public methods and properties for managing tooltip lifecycle and data point bounds:rememberTooltipManager
mainA Composable function that creates and remembers a
TooltipManagerinstance. This ensures the manager's state (the current tooltip and the list of bounds) is preserved during recompositions.Type Parameters:
B: The type of bounds (e.g.,Offsetfor points,Rectfor bars).T: The type of data associated with each tracked item (e.g.,PointData,BarData).
@Composable fun <B, T> rememberTooltipManager(): TooltipManager<B, T>