patrykandpatrick / vico

A light and extensible chart library for Android.
https://patrykandpatrick.com/vico/wiki
Apache License 2.0
2.07k stars 125 forks source link

[BUG] Bottom axis item placer spacing doesn't affect ticks #826

Open tien opened 1 month ago

tien commented 1 month ago

How to reproduce

Use bottom axis item placer with custom spacing.

Observed behavior

Tick appeared for all steps while label correctly respect spacing value.

Expected behavior

Tick should only appear every n spacing.

Vico version(s)

1.15.0

Android version(s)

VanillaIceCream

Screenshot

image
patrickmichalik commented 1 month ago

Hello! This behavior is expected. As described here, with HorizontalLayout.Segmented—which is the default—ticks are displayed at the edges of the segments. Since the ticks aren’t tied to the labels, they’re unaffected by the label spacing. The tick positioning depends on the segment count, which in turn is influenced by the x step.

To achieve the result you’re looking for, please apply HorizontalLayout.FullWidth. As per its documentation, there will then be as many ticks as there are labels, and each tick will be directly above its label.

The AxisItemPlacer.Horizontal.default documentation appears to describe spacing somewhat imprecisely. The HorizontalLayout dependence should be mentioned. This will be corrected.

tien commented 1 month ago

Thanks for the quick response @patrickmichalik, please close this issue or use it to track documentation around spacing, which ever make sense to you 🙏.

patrickmichalik commented 1 month ago

You’re welcome! We plan on using it to track the documentation update—I’ve applied the “documentation error” label. Cheers!

tien commented 1 month ago

Thank you sir, just bought you a ☕️. Keep up the great work!

patrickmichalik commented 1 month ago

Thanks a lot for your support, @tien!