Skip to content

Gradient / alpha fill produces vertical stripes in LineChart #489

@turtleandr

Description

@turtleandr

Summary

When rendering a filled LineDataSet using a semi-transparent fillDrawable (e.g., a vertical gradient), the filled area shows visible vertical bands/stripes at regular intervals. The artifacts align with the internal chunk boundaries used in drawLinearFill(...).

The root cause is the current logic that expands each chunk by one entry on both sides when a drawable is used:

if (drawable != null) {
    startIndex = max(0.0, (currentStartIndex - 1).toDouble()).toInt()
    endIndex = min(endingIndex.toDouble(), (currentEndIndex + 1).toDouble()).toInt()
}

This makes adjacent chunks overlap, which causes the overlapped region to be drawn twice. With semi-transparent drawables, that doubles alpha locally and produces visible seams (bands).

Affected code

Class: com.github.mikephil.charting.renderer.LineChartRenderer
Method: drawLinearFill(...)
Problematic block: chunk index expansion for fillDrawable != null (shown above)

drawLinearFill renders the fill in chunks (indexInterval = 128) to avoid OOM on large datasets.
When fillDrawable != null, each chunk is expanded by +-1 entry to avoid gaps (“space between adjacent drawables”). That introduces overlap between chunks. Looks like overlap is harmless for opaque fills, but it seems that with semi-transparent drawables it causes alpha accumulation and visible bands.

Image

If we remove the logic above, gradient filling works fine

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions