use of com.db.chart.listener.OnEntryClickListener in project WilliamChart by diogobernardino.
the class StackedCardOne method show.
@Override
public void show(Runnable action) {
super.show(action);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
mChart.setOnEntryClickListener(new OnEntryClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(int setIndex, int entryIndex, Rect rect) {
if (setIndex == 2)
mLegendOneRed.animate().scaleY(1.3f).scaleX(1.3f).setDuration(100).withEndAction(new Runnable() {
@Override
public void run() {
mLegendOneRed.animate().scaleY(1.0f).scaleX(1.0f).setDuration(100);
}
});
else if (setIndex == 1) {
mLegendOneYellow.animate().scaleY(1.3f).scaleX(1.3f).setDuration(100).withEndAction(new Runnable() {
@Override
public void run() {
mLegendOneYellow.animate().scaleY(1.0f).scaleX(1.0f).setDuration(100);
}
});
} else {
mLegendOneGreen.animate().scaleY(1.3f).scaleX(1.3f).setDuration(100).withEndAction(new Runnable() {
@Override
public void run() {
mLegendOneGreen.animate().scaleY(1.0f).scaleX(1.0f).setDuration(100);
}
});
}
}
});
Paint thresPaint = new Paint();
thresPaint.setColor(Color.parseColor("#dad8d6"));
thresPaint.setPathEffect(new DashPathEffect(new float[] { 10, 20 }, 0));
thresPaint.setStyle(Paint.Style.STROKE);
thresPaint.setAntiAlias(true);
thresPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
BarSet stackBarSet = new BarSet(mLabels, mValuesOne[0]);
stackBarSet.setColor(Color.parseColor("#a1d949"));
mChart.addData(stackBarSet);
stackBarSet = new BarSet(mLabels, mValuesOne[1]);
stackBarSet.setColor(Color.parseColor("#ffcc6a"));
mChart.addData(stackBarSet);
stackBarSet = new BarSet(mLabels, mValuesOne[2]);
stackBarSet.setColor(Color.parseColor("#ff7a57"));
mChart.addData(stackBarSet);
mChart.setBarSpacing(Tools.fromDpToPx(15));
mChart.setRoundCorners(Tools.fromDpToPx(1));
mChart.setXAxis(false).setXLabels(XRenderer.LabelPosition.OUTSIDE).setYAxis(false).setYLabels(YRenderer.LabelPosition.NONE).setValueThreshold(89.f, 89.f, thresPaint);
int[] order = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
mChart.show(new Animation().setOverlap(.5f, order).setEndAction(action));
}
use of com.db.chart.listener.OnEntryClickListener in project WilliamChart by diogobernardino.
the class BarCardTwo method show.
@Override
public void show(Runnable action) {
super.show(action);
Tooltip tip = new Tooltip(mContext);
tip.setBackgroundColor(Color.parseColor("#f39c12"));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
tip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1)).setDuration(150);
tip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0)).setDuration(150);
}
mChart.setTooltips(tip);
mChart.setOnEntryClickListener(new OnEntryClickListener() {
@Override
public void onClick(int setIndex, int entryIndex, Rect rect) {
mTextViewValue.setText(Integer.toString((int) mValues[0][entryIndex]));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1)
mTextViewValue.animate().alpha(1).setDuration(200);
else
mTextViewValue.setVisibility(View.VISIBLE);
}
});
mChart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1)
mTextViewValue.animate().alpha(0).setDuration(100);
else
mTextViewValue.setVisibility(View.INVISIBLE);
}
});
BarSet barSet = new BarSet();
Bar bar;
for (int i = 0; i < mLabels.length; i++) {
bar = new Bar(mLabels[i], mValues[0][i]);
switch(i) {
case 0:
bar.setColor(Color.parseColor("#77c63d"));
break;
case 1:
bar.setColor(Color.parseColor("#27ae60"));
break;
case 2:
bar.setColor(Color.parseColor("#47bac1"));
break;
case 3:
bar.setColor(Color.parseColor("#16a085"));
break;
case 4:
bar.setColor(Color.parseColor("#3498db"));
break;
default:
break;
}
barSet.addBar(bar);
}
mChart.addData(barSet);
mChart.setBarSpacing(Tools.fromDpToPx(4));
mChart.setBorderSpacing(0).setXAxis(false).setYAxis(false).setLabelsColor(Color.parseColor("#FF8E8A84")).setXLabels(XRenderer.LabelPosition.NONE);
int[] order = { 4, 3, 2, 1, 0 };
mChart.show(new Animation().setOverlap(.5f, order).setEndAction(action));
}
Aggregations