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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/com/jjoe64/graphview/series/PointsGraphSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ private final class Styles {
Shape shape;
}

/**
* Sets the limit for highest value to turn red
*/
private double LIMIT;

/**
* wrapped styles
*/
Expand Down Expand Up @@ -222,7 +227,13 @@ public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) {
if (mCustomShape != null) {
mCustomShape.draw(canvas, mPaint, endX, endY, value);
} else if (mStyles.shape == Shape.POINT) {
canvas.drawCircle(endX, endY, mStyles.size, mPaint);
if (value.getY() >= LIMIT) {
mPaint.setColor(Color.RED);
canvas.drawCircle(endX, endY, mStyles.size, mPaint);
mPaint.setColor(getColor());
} else {
canvas.drawCircle(endX, endY, mStyles.size, mPaint);
}
} else if (mStyles.shape == Shape.RECTANGLE) {
canvas.drawRect(endX-mStyles.size, endY-mStyles.size, endX+mStyles.size, endY+mStyles.size, mPaint);
} else if (mStyles.shape == Shape.TRIANGLE) {
Expand Down Expand Up @@ -301,6 +312,16 @@ public void setShape(Shape s) {
mStyles.shape = s;
}

/**
* This sets the limit of the data points,
* changing data points above the LIMIT to red.
*
* @param limitIn limit to be set
*/
public void setLimit(double limitIn) {
LIMIT = limitIn;
}

/**
* Use a custom handler to draw your own
* drawing for each data point.
Expand Down