🧮 StorageBar
Overview
A composable function that displays a storage bar. This type of chart is typically used to visualize proportions of a whole, such as disk space usage where different categories (e.g., photos, apps, documents) consume parts of the total storage. The segments are laid out horizontally, and their widths are proportional to their values.
Usage
Key parameters for using this chart:
data
: A lambda function that returns a list ofStorageData
. EachStorageData
object represents a segment in the bar and should contain:value
: AFloat
representing the proportion or amount of this segment relative to others. The actual width will be calculated based on the sum of all values.color
: AChartColor
for this segment.
trackColor
: TheChartColor
for the unfilled portion of the bar, displayed if the sum of thevalue
properties indata
does not fill the entire available width. (Optional, defaults toColor(0xD3D3D3DE)
)modifier
: AModifier
for customizing the layout or drawing behavior of the chart, typically used to set its height, as the width is oftenfillMaxWidth
. (Optional)onClick
: A lambda function that is invoked when a segment of the bar is clicked. It receives theStorageData
of the clicked segment. (Optional)
The corners of the first and last segments can be rounded. Clicking a segment can also slightly increase its height for emphasis.