Search in sources :

Example 6 with Animation

use of com.db.chart.animation.Animation in project WilliamChart by diogobernardino.

the class BarFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.fragment_bar, container, false);
    mChart = (BarChartView) layout.findViewById(R.id.chart);
    mFirstStage = true;
    layout.setOnClickListener(this);
    mChart.setOnClickListener(this);
    BarSet dataset = new BarSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#eb993b"));
    mChart.addData(dataset);
    mChart.setBarSpacing(Tools.fromDpToPx(3));
    mChart.setXLabels(AxisRenderer.LabelPosition.NONE).setYLabels(AxisRenderer.LabelPosition.NONE).setXAxis(false).setYAxis(false);
    mChart.show(new Animation().setEasing(new BounceInterpolator()));
    return layout;
}
Also used : BarSet(com.db.chart.model.BarSet) BounceInterpolator(android.view.animation.BounceInterpolator) Animation(com.db.chart.animation.Animation) BarChartView(com.db.chart.view.BarChartView) View(android.view.View)

Example 7 with Animation

use of com.db.chart.animation.Animation in project WilliamChart by diogobernardino.

the class BarCardOne method show.

@Override
public void show(Runnable action) {
    super.show(action);
    // Data
    BarSet barSet = new BarSet(mLabels, mValues[0]);
    barSet.setColor(Color.parseColor("#fc2a53"));
    mChart.addData(barSet);
    mChart.setBarSpacing(Tools.fromDpToPx(20));
    mChart.setRoundCorners(Tools.fromDpToPx(2));
    mChart.setBarBackgroundColor(Color.parseColor("#592932"));
    // Chart
    mChart.setXAxis(false).setYAxis(false).setXLabels(XRenderer.LabelPosition.OUTSIDE).setYLabels(YRenderer.LabelPosition.NONE).setLabelsColor(Color.parseColor("#86705c")).setAxisColor(Color.parseColor("#86705c"));
    int[] order = { 1, 0, 2, 3 };
    final Runnable auxAction = action;
    Runnable chartOneAction = new Runnable() {

        @Override
        public void run() {
            auxAction.run();
            showTooltip();
        }
    };
    mChart.show(new Animation().setOverlap(.7f, order).setEndAction(chartOneAction));
}
Also used : BarSet(com.db.chart.model.BarSet) Animation(com.db.chart.animation.Animation)

Example 8 with Animation

use of com.db.chart.animation.Animation in project WilliamChart by diogobernardino.

the class BarCardThree method show.

@Override
public void show(Runnable action) {
    super.show(action);
    Tooltip tip = new Tooltip(mContext);
    tip.setBackgroundColor(Color.parseColor("#CC7B1F"));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1);
        tip.setEnterAnimation(alpha).setDuration(150);
        alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0);
        tip.setExitAnimation(alpha).setDuration(150);
    }
    mChart.setTooltips(tip);
    BarSet dataset = new BarSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#eb993b"));
    mChart.addData(dataset);
    mChart.setBarSpacing(Tools.fromDpToPx(1.5f));
    mChart.setXLabels(AxisRenderer.LabelPosition.NONE).setYLabels(AxisRenderer.LabelPosition.NONE).setXAxis(false).setYAxis(false);
    Animation anim = new Animation().setEasing(new AccelerateDecelerateInterpolator()).setEndAction(action);
    mChart.show(anim);
}
Also used : BarSet(com.db.chart.model.BarSet) Tooltip(com.db.chart.tooltip.Tooltip) PropertyValuesHolder(android.animation.PropertyValuesHolder) Animation(com.db.chart.animation.Animation) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

Example 9 with Animation

use of com.db.chart.animation.Animation in project WilliamChart by diogobernardino.

the class BarCardTwo method dismiss.

@Override
public void dismiss(Runnable action) {
    super.dismiss(action);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1)
        mTextViewValue.animate().alpha(0).setDuration(100);
    else
        mTextViewValue.setVisibility(View.INVISIBLE);
    mChart.dismissAllTooltips();
    int[] order = { 0, 1, 2, 3, 4 };
    mChart.dismiss(new Animation().setOverlap(.5f, order).setEndAction(action));
}
Also used : Animation(com.db.chart.animation.Animation)

Example 10 with Animation

use of com.db.chart.animation.Animation 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));
}
Also used : Rect(android.graphics.Rect) Bar(com.db.chart.model.Bar) OnEntryClickListener(com.db.chart.listener.OnEntryClickListener) BarSet(com.db.chart.model.BarSet) Tooltip(com.db.chart.tooltip.Tooltip) Animation(com.db.chart.animation.Animation) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) HorizontalBarChartView(com.db.chart.view.HorizontalBarChartView) View(android.view.View)

Aggregations

Animation (com.db.chart.animation.Animation)19 BarSet (com.db.chart.model.BarSet)8 Paint (android.graphics.Paint)5 DashPathEffect (android.graphics.DashPathEffect)4 View (android.view.View)4 LineSet (com.db.chart.model.LineSet)4 BounceInterpolator (android.view.animation.BounceInterpolator)3 Tooltip (com.db.chart.tooltip.Tooltip)3 Rect (android.graphics.Rect)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 TextView (android.widget.TextView)2 OnEntryClickListener (com.db.chart.listener.OnEntryClickListener)2 Point (com.db.chart.model.Point)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)1 CardView (android.support.v7.widget.CardView)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 Bar (com.db.chart.model.Bar)1 BarChartView (com.db.chart.view.BarChartView)1 ChartView (com.db.chart.view.ChartView)1