Search in sources :

Example 1 with Tooltip

use of com.db.chart.tooltip.Tooltip 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 2 with Tooltip

use of com.db.chart.tooltip.Tooltip 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)

Example 3 with Tooltip

use of com.db.chart.tooltip.Tooltip in project WilliamChart by diogobernardino.

the class BarCardOne method showTooltip.

private void showTooltip() {
    // Tooltip
    Tooltip tip = new Tooltip(mContext, R.layout.square_tooltip);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        tip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1), PropertyValuesHolder.ofFloat(View.SCALE_X, 1f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f)).setDuration(200);
        tip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f)).setDuration(200);
    }
    tip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP);
    tip.setDimensions((int) Tools.fromDpToPx(25), (int) Tools.fromDpToPx(25));
    tip.setMargins(0, 0, 0, (int) Tools.fromDpToPx(10));
    tip.prepare(mChart.getEntriesArea(0).get(2), 0);
    mChart.showTooltip(tip, true);
}
Also used : Tooltip(com.db.chart.tooltip.Tooltip)

Example 4 with Tooltip

use of com.db.chart.tooltip.Tooltip in project WilliamChart by diogobernardino.

the class LineCardOne method show.

@Override
public void show(Runnable action) {
    super.show(action);
    // Tooltip
    mTip = new Tooltip(mContext, R.layout.linechart_three_tooltip, R.id.value);
    ((TextView) mTip.findViewById(R.id.value)).setTypeface(Typeface.createFromAsset(mContext.getAssets(), "OpenSans-Semibold.ttf"));
    mTip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP);
    mTip.setDimensions((int) Tools.fromDpToPx(58), (int) Tools.fromDpToPx(25));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mTip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 1f)).setDuration(200);
        mTip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f)).setDuration(200);
        mTip.setPivotX(Tools.fromDpToPx(65) / 2);
        mTip.setPivotY(Tools.fromDpToPx(25));
    }
    mChart.setTooltips(mTip);
    // Data
    LineSet dataset = new LineSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#758cbb")).setFill(Color.parseColor("#2d374c")).setDotsColor(Color.parseColor("#758cbb")).setThickness(4).setDashed(new float[] { 10f, 10f }).beginAt(5);
    mChart.addData(dataset);
    dataset = new LineSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#b3b5bb")).setFill(Color.parseColor("#2d374c")).setDotsColor(Color.parseColor("#ffc755")).setThickness(4).endAt(6);
    mChart.addData(dataset);
    // Chart
    mChart.setBorderSpacing(Tools.fromDpToPx(15)).setAxisBorderValues(0, 20).setYLabels(AxisRenderer.LabelPosition.NONE).setLabelsColor(Color.parseColor("#6a84c3")).setXAxis(false).setYAxis(false);
    mBaseAction = action;
    Runnable chartAction = new Runnable() {

        @Override
        public void run() {
            mBaseAction.run();
            mTip.prepare(mChart.getEntriesArea(0).get(3), mValues[0][3]);
            mChart.showTooltip(mTip, true);
        }
    };
    Animation anim = new Animation().setEasing(new BounceInterpolator()).setEndAction(chartAction);
    mChart.show(anim);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Tooltip(com.db.chart.tooltip.Tooltip) Animation(com.db.chart.animation.Animation) TextView(android.widget.TextView) LineSet(com.db.chart.model.LineSet)

Aggregations

Tooltip (com.db.chart.tooltip.Tooltip)4 Animation (com.db.chart.animation.Animation)3 TextView (android.widget.TextView)2 BarSet (com.db.chart.model.BarSet)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)1 Rect (android.graphics.Rect)1 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 BounceInterpolator (android.view.animation.BounceInterpolator)1 OnEntryClickListener (com.db.chart.listener.OnEntryClickListener)1 Bar (com.db.chart.model.Bar)1 LineSet (com.db.chart.model.LineSet)1 HorizontalBarChartView (com.db.chart.view.HorizontalBarChartView)1