com.github.mikephil.charting.animation.Easing Java Examples

The following examples show how to use com.github.mikephil.charting.animation.Easing. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PieRadarChartBase.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #2
Source File: RealmDatabaseActivityCandle.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "high", "low", "open", "close", "xIndex");
        set.setLabel("Realm Realm CandleDataSet");
        set.setShadowColor(Color.DKGRAY);
        set.setShadowWidth(0.7f);
        set.setDecreasingColor(Color.RED);
        set.setDecreasingPaintStyle(Paint.Style.FILL);
        set.setIncreasingColor(Color.rgb(122, 242, 84));
        set.setIncreasingPaintStyle(Paint.Style.STROKE);
        set.setNeutralColor(Color.BLUE);

        ArrayList<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmCandleData data = new RealmCandleData(result, "xValue", dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #3
Source File: PieRadarChartBase.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #4
Source File: TimerGraphFragment.java    From TwistyTimer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called when the chart statistics loader has completed loading the chart data. The loader
 * listens for changes to the data and this method will be called each time the display of the
 * chart needs to be refreshed. If this fragment has no view, no update will be attempted.
 *
 * @param chartStats The chart statistics populated by the loader.
 */
private void updateChart(ChartStatistics chartStats) {
    if (DEBUG_ME) Log.d(TAG, "updateChart()");

    if (getView() == null) {
        // Must have arrived after "onDestroyView" was called, so do nothing.
        return;
    }

    // Add all times line, best times line, average-of-N times lines (with highlighted
    // best AoN times) and mean limit line and identify them all using a custom legend.
    chartStats.applyTo(lineChartView);

    // Animate and refresh the chart.
    lineChartView.animateY(700, Easing.EasingOption.EaseInOutSine);
}
 
Example #5
Source File: RealmDatabaseActivityScatter.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<RealmDemoData>(result, "value", "xIndex");
        set.setLabel("Realm ScatterDataSet");
        set.setScatterShapeSize(9f);
        set.setColor(ColorTemplate.rgb("#CDDC39"));
        set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);

        ArrayList<IScatterDataSet> dataSets = new ArrayList<IScatterDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmScatterData data = new RealmScatterData(result, "xValue", dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #6
Source File: RealmDatabaseActivityBar.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "value", "xIndex"); // stacked entries
        set.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
        set.setLabel("Realm BarDataSet");

        ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmBarData data = new RealmBarData(result, "xValue", dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #7
Source File: PieRadarChartBase.java    From android-kline with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 *
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #8
Source File: RealmDatabaseActivityHorizontalBar.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex", "floatValue"); // stacked entries
        set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
        set.setLabel("Mobile OS distribution");
        set.setStackLabels(new String[]{"iOS", "Android", "Other"});

        ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmBarData data = new RealmBarData(result, "xValue", dataSets);
        styleData(data);
        data.setValueTextColor(Color.WHITE);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #9
Source File: PieRadarChartBase.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #10
Source File: PieRadarChartBase.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 *
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #11
Source File: RealmDatabaseActivityBubble.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        RealmBubbleDataSet<RealmDemoData> set = new RealmBubbleDataSet<RealmDemoData>(result, "value", "xIndex", "bubbleSize");
        set.setLabel("Realm BubbleDataSet");
        set.setColors(ColorTemplate.COLORFUL_COLORS, 110);

        ArrayList<IBubbleDataSet> dataSets = new ArrayList<IBubbleDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmBubbleData data = new RealmBubbleData(result, "xValue", dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #12
Source File: RealmDatabaseActivityLine.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "value", "xIndex");
        set.setDrawCubic(false);
        set.setLabel("Realm LineDataSet");
        set.setDrawCircleHole(false);
        set.setColor(ColorTemplate.rgb("#FF5722"));
        set.setCircleColor(ColorTemplate.rgb("#FF5722"));
        set.setLineWidth(1.8f);
        set.setCircleSize(3.6f);

        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RealmLineData data = new RealmLineData(result, "xValue", dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #13
Source File: StatisticsFragment.java    From Expense-Tracker-App with MIT License 6 votes vote down vote up
private void setupCharts() {

        // set up pie chart
        pcCategories.setCenterText("");
        pcCategories.setCenterTextSize(10f);
        pcCategories.setHoleRadius(50f);
        pcCategories.setTransparentCircleRadius(55f);
        pcCategories.setUsePercentValues(true);
        pcCategories.setDescription("");
        pcCategories.setNoDataText("");

        Legend l = pcCategories.getLegend();
        l.setPosition(Legend.LegendPosition.BELOW_CHART_RIGHT);
        pcCategories.animateY(1500, Easing.EasingOption.EaseInOutQuad);

    }
 
Example #14
Source File: ColorDetectionActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
private void seteffect(PieChart colorPie) {

        colorPie.animateXY(2000, 2000, Easing.EasingOption.EaseInBounce, Easing.EasingOption.EaseInBounce);
        colorPie.invalidate();
        colorPie.setDrawHoleEnabled(true);
        colorPie.setExtraOffsets(10, 10, 10, 10);

        colorPie.setContentDescription("");
        colorPie.setDragDecelerationFrictionCoef(0.95f);
        colorPie.setDrawCenterText(true);

        colorPie.setRotationAngle(0);
        // enable rotation of the chart by touch
        colorPie.setRotationEnabled(true);
        colorPie.setHighlightPerTapEnabled(true);
        colorPie.setDrawHoleEnabled(true);
        colorPie.setHoleColor(Color.WHITE);

        //disable the label and description
        colorPie.getDescription().setEnabled(false);
        colorPie.getLegend().setEnabled(false);

        colorPie.setTransparentCircleColor(Color.WHITE);
        colorPie.setTransparentCircleAlpha(80);
        colorPie.setElevation(10f);
        colorPie.setHoleRadius(60f);
        colorPie.setTransparentCircleRadius(61f);

        // add a selection listener
        colorPie.setOnChartValueSelectedListener(this);

    }
 
Example #15
Source File: RealmWikiExample.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
private void setData() {

        // LINE-CHART
        RealmResults<Score> results = mRealm.allObjects(Score.class);

        RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(results, "totalScore", "scoreNr");
        lineDataSet.setDrawCubic(false);
        lineDataSet.setLabel("Realm LineDataSet");
        lineDataSet.setDrawCircleHole(false);
        lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
        lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
        lineDataSet.setLineWidth(1.8f);
        lineDataSet.setCircleSize(3.6f);

        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        dataSets.add(lineDataSet);

        RealmLineData lineData = new RealmLineData(results, "playerName", dataSets);
        styleData(lineData);

        // set data
        lineChart.setData(lineData);
        lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);


        // BAR-CHART
        RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<Score>(results, "totalScore", "scoreNr");
        barDataSet.setColors(new int[]{ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
        barDataSet.setLabel("Realm BarDataSet");

        ArrayList<IBarDataSet> barDataSets = new ArrayList<IBarDataSet>();
        barDataSets.add(barDataSet);

        RealmBarData barData = new RealmBarData(results, "playerName", barDataSets);
        styleData(barData);

        barChart.setData(barData);
        barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #16
Source File: ProductDetailActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
private void setEffectPieChart(PieChart colorPie) {

        colorPie.animateXY(1500, 1500, Easing.EasingOption.EaseInBounce, Easing.EasingOption.EaseInBounce);
        colorPie.invalidate();
        colorPie.setDrawHoleEnabled(true);
        colorPie.setExtraOffsets(10, 10, 10, 10);

        colorPie.setContentDescription("");
        colorPie.setDragDecelerationFrictionCoef(0.95f);
        colorPie.setDrawCenterText(true);

        colorPie.setRotationAngle(0);
        // enable rotation of the chart by touch
        colorPie.setRotationEnabled(true);
        colorPie.setHighlightPerTapEnabled(true);
        colorPie.setDrawHoleEnabled(true);
        colorPie.setHoleColor(Color.WHITE);
        colorPie.getLegend().setFormSize(10f);
        colorPie.getLegend().setFormToTextSpace(5f);

        //disable the label and description
        colorPie.getDescription().setEnabled(false);
        colorPie.getLegend().setEnabled(false);

        colorPie.setTransparentCircleColor(Color.WHITE);
        colorPie.setTransparentCircleAlpha(80);
        colorPie.setElevation(10f);
        colorPie.setHoleRadius(90f);
        colorPie.setTransparentCircleRadius(61f);

        // add a selection listener
        colorPie.setOnChartValueSelectedListener(this);

    }
 
Example #17
Source File: PlayActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
@MainThread
private void renderChart(@NonNull final Model model, @NonNull List<Entry> entries) {
    resetDigit();
    renderModelInfo(model);
    refreshData(entries);
    changeStyle(model.getId(), mChart, mLineData);

    mChart.getData().notifyDataChanged();
    mChart.notifyDataSetChanged();
    mChart.animateY(500, Easing.EasingOption.EaseOutCubic);
}
 
Example #18
Source File: PredictionsFragment.java    From SEAL-Demo with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_predictions_layout, container, false);
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.title_fragment_predictions);
    mChart = (PieChart) v.findViewById(R.id.chart);
    mHighPercentage = (TextView) v.findViewById(R.id.highClassificationValue);
    mMediumPercentage = (TextView) v.findViewById(R.id.mediumClassificationValue);
    mLowPercentage = (TextView) v.findViewById(R.id.lowClassificationValue);
    mProgressBar = (ProgressBar) v.findViewById(R.id.predictionProgress);
    // chart settings
    mChart.setUsePercentValues(true);
    mChart.getDescription().setEnabled(false);
    mChart.setExtraOffsets(10, 10, 10, 10);
    mChart.setDragDecelerationFrictionCoef(0.95f);
    mChart.setDrawHoleEnabled(false);
    mChart.setDrawCenterText(false);
    mChart.setRotationAngle(0);
    mChart.animateY(400, Easing.EasingOption.EaseInOutQuad);
    // enable rotation of the mChart by touch
    mChart.setRotationEnabled(true);
    mChart.setHighlightPerTapEnabled(true);
    mChart.getLegend().setEnabled(false);
    asyncGetIntensities();
    return v;
}
 
Example #19
Source File: ListViewBarChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
        public View getView(int position, View convertView, ViewGroup parent) {

            BarData data = getItem(position);

            ViewHolder holder = null;

            if (convertView == null) {

                holder = new ViewHolder();

                convertView = LayoutInflater.from(getContext()).inflate(
                        R.layout.list_item_barchart, null);
                holder.chart = (BarChart) convertView.findViewById(R.id.chart);

                convertView.setTag(holder);

            } else {
                holder = (ViewHolder) convertView.getTag();
            }

            // apply styling
            data.setValueTypeface(mTf);
            data.setValueTextColor(Color.BLACK);
            holder.chart.setDescription("");
            holder.chart.setDrawGridBackground(false);

            XAxis xAxis = holder.chart.getXAxis();
            xAxis.setPosition(XAxisPosition.BOTTOM);
            xAxis.setTypeface(mTf);
            xAxis.setDrawGridLines(false);
            
            YAxis leftAxis = holder.chart.getAxisLeft();
            leftAxis.setTypeface(mTf);
            leftAxis.setLabelCount(5, false);
            leftAxis.setSpaceTop(15f);
            
            YAxis rightAxis = holder.chart.getAxisRight();
            rightAxis.setTypeface(mTf);
            rightAxis.setLabelCount(5, false);
            rightAxis.setSpaceTop(15f);

            // set data
            holder.chart.setData(data);
            
            // do not forget to refresh the chart
//            holder.chart.invalidate();
            holder.chart.animateY(700, Easing.EasingOption.EaseInCubic);

            return convertView;
        }
 
Example #20
Source File: InventoryReportFragment.java    From mobikul-standalone-pos with MIT License 4 votes vote down vote up
private void setSalesProductChart(List<SalesProductReportModel> soldProducts) {
        binding.productChart.setUsePercentValues(true);
        binding.productChart.getDescription().setEnabled(false);
//        binding.productChart.setExtraOffsets(5, 10, 10, 5);
//        holder.chart.setExtraOffsets(5, 10, 50, 10);

        binding.productChart.setDragDecelerationFrictionCoef(0.95f);

        binding.productChart.setCenterText(generateCenterSpannableText());

        binding.productChart.setDrawHoleEnabled(true);
        binding.productChart.setHoleColor(Color.WHITE);

        binding.productChart.setTransparentCircleColor(Color.WHITE);
        binding.productChart.setTransparentCircleAlpha(90);

        binding.productChart.setHoleRadius(50f);
        binding.productChart.setTransparentCircleRadius(55f);

        binding.productChart.setDrawCenterText(true);

        binding.productChart.setRotationAngle(0);
        // enable rotation of the chart by touch
        binding.productChart.setRotationEnabled(true);
        binding.productChart.setHighlightPerTapEnabled(true);

        // binding.productChart.setUnit(" €");
        // binding.productChart.setDrawUnitsInChart(true);

        // add a selection listener
//        binding.productChart.setOnChartValueSelectedListener(this);

        setData(soldProducts, 10);

        binding.productChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
        // binding.productChart.spin(2000, 0, 360);

        Legend l = binding.productChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
        l.setOrientation(Legend.LegendOrientation.VERTICAL);
        l.setDrawInside(false);
//        l.setXEntrySpace(7f);
        l.setYEntrySpace(0f);
        l.setYOffset(0f);

        // entry label styling
        binding.productChart.setEntryLabelColor(Color.WHITE);
        binding.productChart.setEntryLabelTextSize(12f);
    }
 
Example #21
Source File: RadarChartActivitry.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_radarchart);

    mChart = (RadarChart) findViewById(R.id.chart1);

    tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    mChart.setDescription("");

    mChart.setWebLineWidth(1.5f);
    mChart.setWebLineWidthInner(0.75f);
    mChart.setWebAlpha(100);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);

    // set the marker to the chart
    mChart.setMarkerView(mv);

    setData();

    mChart.animateXY(
            1400, 1400,
            Easing.EasingOption.EaseInOutQuad,
            Easing.EasingOption.EaseInOutQuad);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setTypeface(tf);
    xAxis.setTextSize(9f);

    YAxis yAxis = mChart.getYAxis();
    yAxis.setTypeface(tf);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinValue(0f);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
}
 
Example #22
Source File: PieChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_piechart);

    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);

    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);

    mSeekBarY.setProgress(10);

    mSeekBarX.setOnSeekBarChangeListener(this);
    mSeekBarY.setOnSeekBarChangeListener(this);

    mChart = (PieChart) findViewById(R.id.chart1);
    mChart.setUsePercentValues(true);
    mChart.setDescription("");
    mChart.setExtraOffsets(5, 10, 5, 5);

    mChart.setDragDecelerationFrictionCoef(0.95f);

    tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
    mChart.setCenterText(generateCenterSpannableText());

    mChart.setDrawHoleEnabled(true);
    mChart.setHoleColor(Color.WHITE);

    mChart.setTransparentCircleColor(Color.WHITE);
    mChart.setTransparentCircleAlpha(110);

    mChart.setHoleRadius(58f);
    mChart.setTransparentCircleRadius(61f);

    mChart.setDrawCenterText(true);

    mChart.setRotationAngle(0);
    // enable rotation of the chart by touch
    mChart.setRotationEnabled(true);
    mChart.setHighlightPerTapEnabled(true);

    // mChart.setUnit(" €");
    // mChart.setDrawUnitsInChart(true);

    // add a selection listener
    mChart.setOnChartValueSelectedListener(this);

    setData(3, 100);

    mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
    // mChart.spin(2000, 0, 360);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(0f);
    l.setYOffset(0f);
}
 
Example #23
Source File: MiniDateGraph.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public MiniDateGraph(Context context, LineChart chart, String name) {
    mChart = chart;
    mChartName = name;
    mChart.getDescription().setEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setHorizontalScrollBarEnabled(false);
    mChart.setVerticalScrollBarEnabled(false);
    mChart.setAutoScaleMinMaxEnabled(false);
    mChart.setDrawBorders(false);
    mChart.setViewPortOffsets(6f, 6f, 6f, 6f);
    mChart.animateY(1000, Easing.EaseInOutBack); // animate horizontal 3000 milliseconds
    mChart.setClickable(false);

    mChart.getAxisRight().setDrawLabels(false);
    mChart.getAxisLeft().setDrawLabels(false);
    mChart.getLegend().setEnabled(false);
    mChart.setPinchZoom(false);
    mChart.setDescription(null);
    mChart.setTouchEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setNoDataText(context.getString(R.string.no_chart_data_available));

    mContext = context;
    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();
    l.setEnabled(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setDrawLabels(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(ColorTemplate.getHoloBlue());
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(false);
    xAxis.setCenterAxisLabels(false);
    xAxis.setGranularity(1); // 1 jour

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setEnabled(false);
    leftAxis.setDrawZeroLine(false);
    leftAxis.setDrawLabels(false);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
    leftAxis.setTextColor(ColorTemplate.getHoloBlue());
    leftAxis.setDrawGridLines(false);
    leftAxis.setGranularityEnabled(false);

    mChart.getAxisRight().setEnabled(false);
}
 
Example #24
Source File: NodeInfoFragment.java    From android-wallet-app with GNU General Public License v3.0 4 votes vote down vote up
private void updateChart(long tips, long transactionsToRequest) {
    chart.setVisibility(View.VISIBLE);
    setData(tips, transactionsToRequest);
    chart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
}
 
Example #25
Source File: ProductDetailActivity.java    From FaceT with Mozilla Public License 2.0 4 votes vote down vote up
private void setEffectBarChart(HorizontalBarChart barChart) {

        barChart.animateXY(1500, 1500, Easing.EasingOption.EaseInBounce, Easing.EasingOption.EaseInBounce);

        barChart.setContentDescription("");
        barChart.setDragDecelerationFrictionCoef(0.5f);

        barChart.setHighlightPerTapEnabled(false);

        //disable the label and description
        barChart.getDescription().setEnabled(false);
        barChart.getLegend().setEnabled(false);

        barChart.setElevation(10f);
        barChart.setFitBars(true);

        // enable touch gestures
        barChart.setTouchEnabled(false);

        // enable scaling and dragging
        barChart.setDragEnabled(true);
        barChart.setScaleEnabled(true);

        barChart.getAxisLeft().setEnabled(false);
        barChart.getAxisLeft().setDrawLabels(false); // no axis labels
        barChart.getAxisLeft().setDrawAxisLine(false); // no axis line
        barChart.getAxisLeft().setDrawGridLines(false); // no grid lines
//        barChart.getAxisLeft().setSpaceTop(0);
//        barChart.getAxisLeft().setSpaceBottom(0);
//        barChart.getAxisRight().setAxisMinimum(0);
        barChart.getXAxis().setEnabled(false);

        barChart.getAxisRight().setEnabled(false);

        barChart.setPinchZoom(false);
        barChart.setDoubleTapToZoomEnabled(false);

        barChart.highlightValues(null);
        barChart.getAxisRight().setAxisLineWidth(0);
        barChart.getAxisRight().setSpaceMax(0f);
        barChart.invalidate();
    }
 
Example #26
Source File: ActivitiesChartActivity.java    From Mi-Band with GNU General Public License v2.0 4 votes vote down vote up
private void populateChart() {
        Calendar before = Calendar.getInstance();
        before.add(Calendar.DAY_OF_WEEK, -7);

        Calendar today = Calendar.getInstance();
        today.setTimeInMillis(System.currentTimeMillis());

        //Log.i(TAG, "data from " + DateUtils.convertString(before) + " to " + DateUtils.convertString(today));

        ArrayList<ActivityData> allActivities = ActivitySQLite.getInstance(ActivitiesChartActivity.this)
                .getActivitySamples(before.getTimeInMillis(), today.getTimeInMillis());
        //.getAllActivities();

        ArrayList<String> xVals = new ArrayList<String>();

        ArrayList<BarEntry> unknown = new ArrayList<BarEntry>();

        int i = 0;

        Calendar cal = Calendar.getInstance();
        cal.clear();
        Date date;
        String dateStringFrom = "";
        String dateStringTo = "";

        SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
        SimpleDateFormat annotationDateFormat = new SimpleDateFormat("HH:mm");

        float movementDivisor = 180.0f;

        float value;

        for (ActivityData ad : allActivities) {

            // determine start and end dates
            if (i == 0) {
                cal.setTimeInMillis(ad.getTimestamp() * 1000L); // make sure it's converted to long
                date = cal.getTime();
                dateStringFrom = dateFormat.format(date);
            } else if (i == allActivities.size() - 1) {
                cal.setTimeInMillis(ad.getTimestamp() * 1000L); // same here
                date = cal.getTime();
                dateStringTo = dateFormat.format(date);
            }

            String xLabel = "";
            cal.setTimeInMillis(ad.getTimestamp() * 1000L);
            date = cal.getTime();
            String dateString = annotationDateFormat.format(date);
            xLabel = dateString;

            xVals.add(xLabel);

            Log.i(TAG, "date " + dateString);
            Log.i(TAG, "steps " + ad.getSteps());

            value = ((float) ad.getIntensity() / movementDivisor);

            unknown.add(new BarEntry(value, i));

            i++;
        }

        //BarDataSet set1 = new BarDataSet(deep, "Deep Sleep");
        //set1.setColor(Color.BLUE);
        //BarDataSet set2 = new BarDataSet(light, "Light Sleep");
        //set2.setColor(Color.CYAN);
        BarDataSet set3 = new BarDataSet(unknown, "Activity");
        set3.setColor(Color.RED);

        ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
        //dataSets.add(set1);
        //dataSets.add(set2);
        dataSets.add(set3);

        BarData data = new BarData(xVals, dataSets);
//        data.setValueFormatter(new LargeValueFormatter());

        // add space between the dataset groups in percent of bar-width
        data.setGroupSpace(0);

        mChart.setDescription(String.format("From %1$s to %2$s",
                dateStringFrom, dateStringTo));
        mChart.setData(data);
        mChart.invalidate();

        mChart.animateY(2000, Easing.EasingOption.EaseInOutQuart);
    }
 
Example #27
Source File: FreeHandView.java    From Machine-Learning-Projects-for-Mobile-Applications with MIT License 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();
    BarData exampleData;

    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN :
            touchStart(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE :
            touchMove(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP :
            touchUp();
            //toGrayscale(mBitmap);
            Bitmap scaledBitmap = Bitmap.createScaledBitmap(mBitmap, mClassifier.getImageSizeX(), mClassifier.getImageSizeY(), true);
            Random rng = new Random();

            try {
                File mFile;
                mFile = this.getContext().getExternalFilesDir(String.valueOf(rng.nextLong() + ".png"));
                FileOutputStream pngFile = new FileOutputStream(mFile);
            }
            catch (Exception e){
            }
            //scaledBitmap.compress(Bitmap.CompressFormat.PNG, 90, pngFile);
            Float prediction = mClassifier.classifyFrame(scaledBitmap);
            exampleData = updateBarEntry();
            barChart.animateY(1000, Easing.EasingOption.EaseOutQuad);
            XAxis xAxis = barChart.getXAxis();
            xAxis.setValueFormatter(new IAxisValueFormatter() {
                @Override
                public String getFormattedValue(float value, AxisBase axis) {
                    return xAxisLabel.get((int) value);
                }
            });
            barChart.setData(exampleData);
            exampleData.notifyDataChanged(); // let the data know a dataSet changed
            barChart.notifyDataSetChanged(); // let the chart know it's data changed
            break;
    }

    return true;
}
 
Example #28
Source File: RadarChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_radarchart);

    setTitle("RadarChartActivity");

    chart = findViewById(R.id.chart1);
    chart.setBackgroundColor(Color.rgb(60, 65, 82));

    chart.getDescription().setEnabled(false);

    chart.setWebLineWidth(1f);
    chart.setWebColor(Color.LTGRAY);
    chart.setWebLineWidthInner(1f);
    chart.setWebColorInner(Color.LTGRAY);
    chart.setWebAlpha(100);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview);
    mv.setChartView(chart); // For bounds control
    chart.setMarker(mv); // Set the marker to the chart

    setData();

    chart.animateXY(1400, 1400, Easing.EaseInOutQuad);

    XAxis xAxis = chart.getXAxis();
    xAxis.setTypeface(tfLight);
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(new ValueFormatter() {

        private final String[] mActivities = new String[]{"Burger", "Steak", "Salad", "Pasta", "Pizza"};

        @Override
        public String getFormattedValue(float value) {
            return mActivities[(int) value % mActivities.length];
        }
    });
    xAxis.setTextColor(Color.WHITE);

    YAxis yAxis = chart.getYAxis();
    yAxis.setTypeface(tfLight);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(80f);
    yAxis.setDrawLabels(false);

    Legend l = chart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setTypeface(tfLight);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
 
Example #29
Source File: PiePolylineChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_piechart);

    setTitle("PiePolylineChartActivity");

    tvX = findViewById(R.id.tvXMax);
    tvY = findViewById(R.id.tvYMax);

    seekBarX = findViewById(R.id.seekBar1);
    seekBarY = findViewById(R.id.seekBar2);

    seekBarX.setOnSeekBarChangeListener(this);
    seekBarY.setOnSeekBarChangeListener(this);

    chart = findViewById(R.id.chart1);
    chart.setUsePercentValues(true);
    chart.getDescription().setEnabled(false);
    chart.setExtraOffsets(5, 10, 5, 5);

    chart.setDragDecelerationFrictionCoef(0.95f);

    tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    chart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
    chart.setCenterText(generateCenterSpannableText());

    chart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);

    chart.setDrawHoleEnabled(true);
    chart.setHoleColor(Color.WHITE);

    chart.setTransparentCircleColor(Color.WHITE);
    chart.setTransparentCircleAlpha(110);

    chart.setHoleRadius(58f);
    chart.setTransparentCircleRadius(61f);

    chart.setDrawCenterText(true);

    chart.setRotationAngle(0);
    // enable rotation of the chart by touch
    chart.setRotationEnabled(true);
    chart.setHighlightPerTapEnabled(true);

    // chart.setUnit(" €");
    // chart.setDrawUnitsInChart(true);

    // add a selection listener
    chart.setOnChartValueSelectedListener(this);

    seekBarX.setProgress(4);
    seekBarY.setProgress(100);

    chart.animateY(1400, Easing.EaseInOutQuad);
    // chart.spin(2000, 0, 360);

    Legend l = chart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
    l.setDrawInside(false);
    l.setEnabled(false);
}
 
Example #30
Source File: PiePolylineChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.viewGithub: {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PiePolylineChartActivity.java"));
            startActivity(i);
            break;
        }
        case R.id.actionToggleValues: {
            for (IDataSet<?> set : chart.getData().getDataSets())
                set.setDrawValues(!set.isDrawValuesEnabled());

            chart.invalidate();
            break;
        }
        case R.id.actionToggleHole: {
            if (chart.isDrawHoleEnabled())
                chart.setDrawHoleEnabled(false);
            else
                chart.setDrawHoleEnabled(true);
            chart.invalidate();
            break;
        }
        case R.id.actionToggleMinAngles: {
            if (chart.getMinAngleForSlices() == 0f)
                chart.setMinAngleForSlices(36f);
            else
                chart.setMinAngleForSlices(0f);
            chart.notifyDataSetChanged();
            chart.invalidate();
            break;
        }
        case R.id.actionToggleCurvedSlices: {
            boolean toSet = !chart.isDrawRoundedSlicesEnabled() || !chart.isDrawHoleEnabled();
            chart.setDrawRoundedSlices(toSet);
            if (toSet && !chart.isDrawHoleEnabled()) {
                chart.setDrawHoleEnabled(true);
            }
            if (toSet && chart.isDrawSlicesUnderHoleEnabled()) {
                chart.setDrawSlicesUnderHole(false);
            }
            chart.invalidate();
            break;
        }
        case R.id.actionDrawCenter: {
            if (chart.isDrawCenterTextEnabled())
                chart.setDrawCenterText(false);
            else
                chart.setDrawCenterText(true);
            chart.invalidate();
            break;
        }
        case R.id.actionToggleXValues: {

            chart.setDrawEntryLabels(!chart.isDrawEntryLabelsEnabled());
            chart.invalidate();
            break;
        }
        case R.id.actionTogglePercent:
            chart.setUsePercentValues(!chart.isUsePercentValuesEnabled());
            chart.invalidate();
            break;
        case R.id.animateX: {
            chart.animateX(1400);
            break;
        }
        case R.id.animateY: {
            chart.animateY(1400);
            break;
        }
        case R.id.animateXY: {
            chart.animateXY(1400, 1400);
            break;
        }
        case R.id.actionToggleSpin: {
            chart.spin(1000, chart.getRotationAngle(), chart.getRotationAngle() + 360, Easing.EaseInOutCubic);
            break;
        }
        case R.id.actionSave: {
            if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                saveToGallery();
            } else {
                requestStoragePermission(chart);
            }
            break;
        }
    }
    return true;
}