patrykandpatrick / vico

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

Marker text is not show when data size is one #910

Open chaeeunDev opened 3 weeks ago

chaeeunDev commented 3 weeks ago

How to reproduce

There is only one data size, and the text inside the marker is not displayed when the marker is used in the line graph using the point provider.

Additionally, I'm using a basic marker and a persistent marker at the same time, and when I click it, the basic marker detects the event first and remembers the index to display the persistent mark.

897

Observed behavior

When the data size is large, the text inside the marker pops up well, but strangely, the text doesn't pop up when it's 1 size

Expected behavior

I hope the text on the marker will pop up well even when there is 1 data.

Vico version(s)

2.0.0-beta.1

Android version(s)

minSdk is 28, comple and target sdk is 34

Additional information

marker = rememberMarker(MaterialTheme.colorScheme.surfaceVariant), markerVisibilityListener = object : CartesianMarkerVisibilityListener { override fun onHidden(marker: CartesianMarker) { // TODO("Not yet implemented") }

            override fun onShown(
                marker: CartesianMarker,
                targets: List<CartesianMarker.Target>
            ) {
                clickIndex(targets.first().x.toFloat())
            }
        },
        getXStep = { 1.0 },
        horizontalLayout = HorizontalLayout.FullWidth(),
        persistentMarkers = rememberExtraLambda( marker) { marker at selectedIndex },
Gowsky commented 2 weeks ago

Hello, @chaeeunDev. Thanks for the report. We'll look into it.

The problem lies in color extraction. If you have only one series (or multiple series with the same line color), you can temporarily solve this by updating your CartesianMarker so that the appropriate color is defined statically and not extracted. See the color parameter of rememberTextComponent and the colorCode property of DefaultCartesianMarkerValueFormatter.

chaeeunDev commented 2 weeks ago

Oh thank you @Gowsky! I will fix the bug according to the method you told me! And did you succeed in recreating the bug I presented? I will attach more codes and photos if necessary!

patrickmichalik commented 2 weeks ago

We have been able to reproduce this, @chaeeunDev. Cheers!

chaeeunDev commented 1 week ago

That's good news! I'll be waiting for you to solve the problem! Thank you! @patrickmichalik