patrykandpatrick / vico

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

Not able to see x-axis and y-axis labels in some devices. #541

Closed JainSaloni4 closed 8 months ago

JainSaloni4 commented 8 months ago

How to reproduce

On some devices the x-axis and y-axis labels are not visible in the chart. This is device specific, the labels are getting passed into the chart yet the labels are not visible for both the axis. (Devices: Realme GT2, Samsung S22 ultra)

Observed behavior

The x-axis and y-axis labels are being passed, but not visible on some on specific devices.

Expected behavior

The labels for both the devices should be visible in the screen

Vico version(s)

Latest stable version, Latest unstable version

Android version(s)

13

Additional information

Current Version of vico charts used on my end is: 1.6.4

patrickmichalik commented 8 months ago

Hello! Thanks for the report. For “Vico version(s),” you’ve selected “Latest stable version” and “Latest unstable version,” but under “Additional information,” you’ve mentioned that you’re using Vico 1.6.4. Just to confirm, have you checked if this issue occurs in Vico 1.13.1, Vico 1.14.0 Alpha 2, or Vico 2.0.0 Alpha 6?

JainSaloni4 commented 8 months ago

Hello! Thanks for the report. For “Vico version(s),” you’ve selected “Latest stable version” and “Latest unstable version,” but under “Additional information,” you’ve mentioned that you’re using Vico 1.6.4. Just to confirm, have you checked if this issue occurs in Vico 1.13.1, Vico 1.14.0 Alpha 2, or Vico 2.0.0 Alpha 6?

Not checked on another versions yet.

patrickmichalik commented 8 months ago

I’m afraid we’re unable to accept bug reports for outdated Vico versions—the issue may no longer occur in the latest versions, and only if a bug still exists is a report of it actionable. As per the note in the issue template, we’d ask you to check if the problem affects one of the versions listed above. If it does, please reopen this issue.

TatjanaDjurdjevic commented 5 months ago

This happens for me too.

I am using Vico 1.14.0 (views and core libraries).

On pixel phone everything works as expected.

On device Samsung S21, with Android 14 and One UI version 6.0, neither x or y labels are showed.

patrickmichalik commented 5 months ago

Hello, @TatjanaDjurdjevic! Could you please share a minimal reproducible example?

TatjanaDjurdjevic commented 5 months ago

I have just tried it out on Pixel 7A with Android 14 (device), and also the x and y axes are not showing, but however on emulator on my laptop which is pixel 7A with Android 14 everything works fine.

Minimal reproducible example:

    val data = listOf("2022-07-01" to 2f, "2022-07-02" to 6f, "2022-07-04" to 4f).associate { (dateString, yValue) ->
        LocalDate.parse(dateString) to yValue
    }
    val xValuesToDates = data.keys.associateBy { it.toEpochDay().toFloat() }
    val chartEntryModel = entryModelOf(xValuesToDates.keys.zip(data.values, ::entryOf))
    val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("d MMM")
    val horizontalAxisValueFormatter = AxisValueFormatter<AxisPosition.Horizontal.Bottom> { value, _ ->
        (xValuesToDates[value] ?: LocalDate.ofEpochDay(value.toLong())).format(dateTimeFormatter)
    }

    binding.chartViewTest.setModel(chartEntryModel)
    with(binding.chartViewTest) {
        with(bottomAxis as HorizontalAxis) {
            valueFormatter = horizontalAxisValueFormatter
            isZoomEnabled = true
        }
        with(startAxis as VerticalAxis) {
            title = "Test"
            isZoomEnabled = true
            titleComponent = TextComponent.Builder().build()
        }
    }
TatjanaDjurdjevic commented 5 months ago

It was my bad. Actually the problem was dark mode. When device is in dark mode, label color is white, and my background is white (app does not support dark mode, and labels were not visible).

patrickmichalik commented 5 months ago

Got it, @TatjanaDjurdjevic. I’m glad you’ve found the cause of the issue. Cheers!