Closed seyone22 closed 1 month ago
Hello! This behavior is expected. The label spacing is set to 3, so a label is shown for every third column. From your code:
HorizontalAxis.ItemPlacer.default(spacing = 3, addExtremeLabelPadding = true)
To obtain the desired behavior, please ensure that spacing
is set to 1, which is the default value:
HorizontalAxis.ItemPlacer.default(addExtremeLabelPadding = true)
Each column will then be labeled.
By the way, in your code, a new ExtraStore.Key
is created whenever ReportCard
is recomposed. As described here, this is an error. To avoid exceptions, please use remember
, as shown below, or move labelListKey
to the file level or a singleton. I’d also suggest ensuring that the CartesianValueFormatter
isn’t recreated more often than needed.
val labelListKey = remember { ExtraStore.Key<List<String>>() }
How to reproduce
@Composable fun ReportCard( modifier: Modifier = Modifier, category: Int, viewModel: ReportViewModel ) { val categoryName = remember { mutableStateOf("") } val values = remember { mutableStateOf<Map<Int?, Double>>(emptyMap()) }
}
Observed behavior
Here, only the label for the first bar (A) is shown. I tried just hardcoding two lists to see if my incoming data was faulty, but even in that case, only the first bar's label is shown.
Expected behavior
Labels for the second, third, and other bars should also be visible.
Vico version(s)
2.0.0-alpha.27
Android version(s)
Pixel 7 API 34
Additional information
No response