Charty Documentation

repository·main·Indexed 23 days ago

https://github.com/hi-manshu/charty

A 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.

Tokens
427
Snippets
1
Records
4
Agent score
29%

What's inside Charty

  1. Overview of Charty

    main
    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.
  2. Use TooltipManager to manage chart tooltips

    main

    The TooltipManager class provides a centralized way to manage tooltip display state and track the spatial bounds of data points (e.g., Offset for points or Rect for bars) during chart interactions.

    Key functionalities include:

    • State Tracking: Maintains tooltipState which is null when no tooltip is visible.
    • Bounds Management: Stores a list of bounds (the geometry) paired with T (the associated data). Use clearBounds() at the start of each draw cycle to reset the tracked items.
    • Interaction Control: Use updateTooltip(state) to show a tooltip or dismiss() to hide it.

    In a Compose environment, use rememberTooltipManager<B, T>() to create and persist the manager instance across recompositions.

  3. rememberTooltipManager

    main

    A Composable function that creates and remembers a TooltipManager instance. 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., Offset for points, Rect for bars).
    • T: The type of data associated with each tracked item (e.g., PointData, BarData).
    @Composable
    fun <B, T> rememberTooltipManager(): TooltipManager<B, T>