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

[TopBottomShader] with negative values splits the line color into two #784

Closed mak1nt0sh closed 1 month ago

mak1nt0sh commented 2 months ago

How to reproduce

Use LineSpec with

shader = TopBottomShader(
topShader = DynamicShader.color(MaterialTheme.colorScheme.primary),
bottomShader = DynamicShader.color(MaterialTheme.customColors.negative)
)

and have postive, negative and zero values in ySeries

Observed behavior

Zero,Positive & Negative

Screenshot 2024-07-03 at 13 29 18

Zero & Negative

Screenshot 2024-07-03 at 13 34 32

Zero & Positive

Screenshot 2024-07-03 at 13 50 52

Expected behavior

Zero values should be treated as positive and be drawn using topShader.

Vico version(s)

2.0.0-alpha.21

Android version(s)

Any

Additional information

No response

patrickmichalik commented 2 months ago

Hello! Thanks for the report. We’ll look into it.

patrickmichalik commented 1 month ago

Vico 2.0.0 Alpha 26 resolves this. Cheers!

patrickmichalik commented 1 month ago

I’m reopening this issue because, as reported here, the problem now occurs under different circumstances—when the split’s y value is equal or very close to the LineCartesianLayer’s minimum y value. We overlooked this edge case while developing the fix, for which we apologize. We’ll look into it.

patrickmichalik commented 1 month ago

Vico 2.0.0 Alpha 27 addresses the aforementioned oversight. Thanks again!

mak1nt0sh commented 1 month ago

Still experiencing same issue on Vico 2.0.0 Alpha 27.

lineissue

OLD ISSUE: Line colors are split. NEW ISSUE: Default marker mixes the colors of both fill colors:

fill = LineCartesianLayer.LineFill.double(
                            topFill = fill(MaterialTheme.colorScheme.primary),
                            bottomFill = fill(MaterialTheme.customColors.negative)
                        )

Data for this view:

xSeries = [19936, 19937, 19938, 19939, 19940, 19941, 19942]
ySeries = [500.00, -5, -5, -5, -5, -25, -25]
Gowsky commented 1 month ago

Hi @mak1nt0sh, it’s related, but it’s not the same problem. The split position is now calculated correctly, but there seems to be an issue with color extraction, probably due to antialiasing. Please open a new issue that can be a copy of your last comment, or just a link to the comment.