Skip to content

#441 Fill not working #2837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,24 @@ private void generateFilledPath(final ILineDataSet dataSet, final int startIndex
final Path filled = outputPath;
filled.reset();

final Entry entry = dataSet.getEntryForIndex(startIndex);
// Semirke: we must skip Float.NaNs first
int sIdx = startIndex;
while(Float.isNaN(dataSet.getEntryForIndex(sIdx).getY())
&& sIdx < endIndex ) sIdx++;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could've added a check for success.

final Entry entry = dataSet.getEntryForIndex(sIdx);

filled.moveTo(entry.getX(), fillMin);
filled.lineTo(entry.getX(), entry.getY() * phaseY);

// create a new path
Entry currentEntry = null;
Entry previousEntry = null;
for (int x = startIndex + 1; x <= endIndex; x++) {
for (int x = sIdx + 1; x <= endIndex; x++) {
// Leave float.NaNs out
if(Float.isNaN(dataSet.getEntryForIndex(x).getY())) continue;

currentEntry = dataSet.getEntryForIndex(x);

if (isDrawSteppedEnabled && previousEntry != null) {
filled.lineTo(currentEntry.getX(), previousEntry.getY() * phaseY);
}
Expand All @@ -510,7 +516,7 @@ private void generateFilledPath(final ILineDataSet dataSet, final int startIndex
}

// close up
if (currentEntry != null) {
if (currentEntry != null && !Float.isNaN(currentEntry.getY())) {
filled.lineTo(currentEntry.getX(), fillMin);
}

Expand Down