Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions hellocharts-library/src/lecho/lib/hellocharts/model/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public boolean isCubic() {

public Line setCubic(boolean isCubic) {
this.isCubic = isCubic;
if (isSquare)
if (isSquare && isCubic)
setSquare(false);
return this;
}
Expand All @@ -236,7 +236,7 @@ public boolean isSquare() {

public Line setSquare(boolean isSquare) {
this.isSquare = isSquare;
if (isCubic)
if (isCubic && isSquare)
setCubic(false);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,21 @@ private void drawPath(Canvas canvas, final Line line) {
prepareLinePaint(line);

int valueIndex = 0;
boolean invalidYValue = false;
for (PointValue pointValue : line.getValues()) {

final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());

if (valueIndex == 0) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, rawY);
if (Float.isNaN(rawY))
invalidYValue = true;
else {
if (valueIndex == 0 || invalidYValue) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, rawY);
}
invalidYValue = false;
}

++valueIndex;
Expand All @@ -243,17 +249,19 @@ private void drawSquarePath(Canvas canvas, final Line line) {
prepareLinePaint(line);

int valueIndex = 0;
float previousRawY = 0;
float previousRawY = Float.NaN;
for (PointValue pointValue : line.getValues()) {

final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());

if (valueIndex == 0) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, previousRawY);
path.lineTo(rawX, rawY);
if (! Float.isNaN(rawY)) {
if (Float.isNaN(previousRawY)) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, previousRawY);
path.lineTo(rawX, rawY);
}
}

previousRawY = rawY;
Expand Down