|
|
@ -94,12 +94,8 @@ public class BarChart extends ScrollableChart
|
|
|
|
|
|
|
|
|
|
|
|
private double maxValue;
|
|
|
|
private double maxValue;
|
|
|
|
|
|
|
|
|
|
|
|
private double target;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int primaryColor;
|
|
|
|
private int primaryColor;
|
|
|
|
|
|
|
|
|
|
|
|
private int darkerPrimaryColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BarChart(Context context)
|
|
|
|
public BarChart(Context context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super(context);
|
|
|
|
super(context);
|
|
|
@ -126,7 +122,6 @@ public class BarChart extends ScrollableChart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setEntries(entries);
|
|
|
|
setEntries(entries);
|
|
|
|
setTarget(0.5);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setBucketSize(int bucketSize)
|
|
|
|
public void setBucketSize(int bucketSize)
|
|
|
@ -150,9 +145,7 @@ public class BarChart extends ScrollableChart
|
|
|
|
public void setColor(int primaryColor)
|
|
|
|
public void setColor(int primaryColor)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
StyledResources res = new StyledResources(getContext());
|
|
|
|
StyledResources res = new StyledResources(getContext());
|
|
|
|
int backgroundColor = res.getColor(R.attr.cardBgColor);
|
|
|
|
|
|
|
|
this.primaryColor = primaryColor;
|
|
|
|
this.primaryColor = primaryColor;
|
|
|
|
this.darkerPrimaryColor = ColorUtils.mixColors(primaryColor, backgroundColor, 0.6f);
|
|
|
|
|
|
|
|
postInvalidate();
|
|
|
|
postInvalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -162,12 +155,6 @@ public class BarChart extends ScrollableChart
|
|
|
|
postInvalidate();
|
|
|
|
postInvalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setTarget(double target)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.target = target;
|
|
|
|
|
|
|
|
postInvalidate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas)
|
|
|
|
protected void onDraw(Canvas canvas)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -275,8 +262,7 @@ public class BarChart extends ScrollableChart
|
|
|
|
float margin = baseSize * 0.225f;
|
|
|
|
float margin = baseSize * 0.225f;
|
|
|
|
float round = dpToPixels(getContext(), 2);
|
|
|
|
float round = dpToPixels(getContext(), 2);
|
|
|
|
|
|
|
|
|
|
|
|
int color = darkerPrimaryColor;
|
|
|
|
int color = primaryColor;
|
|
|
|
if (value / 1000 >= target) color = primaryColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rect.inset(-margin, 0);
|
|
|
|
rect.inset(-margin, 0);
|
|
|
|
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
|
|
|
|
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
|
|
|
@ -367,10 +353,7 @@ public class BarChart extends ScrollableChart
|
|
|
|
private void drawValue(Canvas canvas, RectF rect, double value)
|
|
|
|
private void drawValue(Canvas canvas, RectF rect, double value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (value == 0) return;
|
|
|
|
if (value == 0) return;
|
|
|
|
|
|
|
|
int activeColor = primaryColor;
|
|
|
|
int activeColor = darkerPrimaryColor;
|
|
|
|
|
|
|
|
if (value / 1000 >= target)
|
|
|
|
|
|
|
|
activeColor = primaryColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String label = NumberButtonViewKt.toShortString(value / 1000);
|
|
|
|
String label = NumberButtonViewKt.toShortString(value / 1000);
|
|
|
|
Rect rText = new Rect();
|
|
|
|
Rect rText = new Rect();
|
|
|
|