How to use HorizontalAxis.ItemPlacer to format values in CartesianValueFormatter in beta 2 #990
Replies: 1 comment
-
Hello, @virtualpathum. First, regardless of the version, this positioning of the x-axis labels should be achieved via Setting that aside:
As per the error message, the problem is that you're using if (index % 2 == 0) xAxisData[index] + space else "" This is incorrect because an empty label differs from no label. Even if it's empty, it's still a component, limiting the width of neighboring labels and potentially truncating them. This has always been the case, but we recently added a check for this as a safeguard against the unwanted truncation it may cause. Instead of using the workaround with empty strings, you should achieve the desired spacing via Also note that the solution where the x values are directly passed to the formatter via |
Beta Was this translation helpful? Give feedback.
-
Question
Hi, I upgraded my vico version from 2.0.0.alpha-19 to 2.0.0-beta.2 and have made the changes as per the release notes.
I have a requirement to move the bottom axis label to the beginning of the column as per the attached image.
I had to implement the getBottomAxisValueFormatterImports function below to handle this due to a real estate issue showing the chart and moving the labels.
Everything works fine in alpha-19.
Now, when I change the code for beta 2, it gives me the following error.
java.lang.IllegalStateException: CartesianValueFormatter.format returned an empty string. Use HorizontalAxis.ItemPlacer and VerticalAxis.ItemPlacer, not empty strings, to control which x and y values are labeled.
at com.patrykandpatrick.vico.core.cartesian.data.CartesianValueFormatterKt.formatForAxis(CartesianValueFormatter.kt:86)
I appreciate your guidance on this.
Thanks
Vico version(s)
2.0.0-beta.2
UI framework(s)
Jetpack Compose
Beta Was this translation helpful? Give feedback.
All reactions