Java Code Examples for com.github.mikephil.charting.interfaces.datasets.IDataSet#setDrawValues()

The following examples show how to use com.github.mikephil.charting.interfaces.datasets.IDataSet#setDrawValues() . 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: GraphsActivity.java    From your-local-weather with GNU General Public License v3.0 5 votes vote down vote up
private void toggleValuesForGraph(LineData lineData) {
    if (lineData == null) {
        return;
    }
    for (IDataSet set : lineData.getDataSets()) {
        set.setDrawValues(!set.isDrawValuesEnabled());
    }
}
 
Example 2
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;
}
 
Example 3
Source File: BarChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.actionToggleValues: {
            for (IDataSet set : mChart.getData().getDataSets())
                set.setDrawValues(!set.isDrawValuesEnabled());

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleHighlight: {
            if(mChart.getData() != null) {
                mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
                mChart.invalidate();
            }
            break;
        }
        case R.id.actionTogglePinch: {
            if (mChart.isPinchZoomEnabled())
                mChart.setPinchZoom(false);
            else
                mChart.setPinchZoom(true);

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleAutoScaleMinMax: {
            mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
            mChart.notifyDataSetChanged();
            break;
        }
        case R.id.actionToggleHighlightArrow: {
            if (mChart.isDrawHighlightArrowEnabled())
                mChart.setDrawHighlightArrow(false);
            else
                mChart.setDrawHighlightArrow(true);
            mChart.invalidate();
            break;
        }
        case R.id.animateX: {
            mChart.animateX(3000);
            break;
        }
        case R.id.animateY: {
            mChart.animateY(3000);
            break;
        }
        case R.id.animateXY: {

            mChart.animateXY(3000, 3000);
            break;
        }
        case R.id.actionSave: {
            if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
                Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
                        Toast.LENGTH_SHORT).show();
            } else
                Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
                        .show();
            break;
        }
    }
    return true;
}
 
Example 4
Source File: BubbleChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.actionToggleValues: {
            for (IDataSet set : mChart.getData().getDataSets())
                set.setDrawValues(!set.isDrawValuesEnabled());

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleHighlight: {
            if(mChart.getData() != null) {
                mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
                mChart.invalidate();
            }
            break;
        }
        case R.id.actionTogglePinch: {
            if (mChart.isPinchZoomEnabled())
                mChart.setPinchZoom(false);
            else
                mChart.setPinchZoom(true);

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleAutoScaleMinMax: {
            mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
            mChart.notifyDataSetChanged();
            break;
        }
        case R.id.actionSave: {
            // mChart.saveToGallery("title"+System.currentTimeMillis());
            mChart.saveToPath("title" + System.currentTimeMillis(), "");
            break;
        }
        case R.id.animateX: {
            mChart.animateX(3000);
            break;
        }
        case R.id.animateY: {
            mChart.animateY(3000);
            break;
        }
        case R.id.animateXY: {

            mChart.animateXY(3000, 3000);
            break;
        }
    }
    return true;
}
 
Example 5
Source File: AnotherBarActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.actionToggleValues: {

            for (IDataSet set : mChart.getData().getDataSets())
                set.setDrawValues(!set.isDrawValuesEnabled());

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleHighlight: {

            if(mChart.getData() != null) {
                mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
                mChart.invalidate();
            }
            break;
        }
        case R.id.actionTogglePinch: {
            if (mChart.isPinchZoomEnabled())
                mChart.setPinchZoom(false);
            else
                mChart.setPinchZoom(true);

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleAutoScaleMinMax: {
            mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
            mChart.notifyDataSetChanged();
            break;
        }
        case R.id.actionToggleHighlightArrow: {
            if (mChart.isDrawHighlightArrowEnabled())
                mChart.setDrawHighlightArrow(false);
            else
                mChart.setDrawHighlightArrow(true);
            mChart.invalidate();
            break;
        }
        case R.id.animateX: {
            mChart.animateX(3000);
            break;
        }
        case R.id.animateY: {
            mChart.animateY(3000);
            break;
        }
        case R.id.animateXY: {

            mChart.animateXY(3000, 3000);
            break;
        }
        case R.id.actionSave: {
            if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
                Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
                        Toast.LENGTH_SHORT).show();
            } else
                Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
                        .show();
            break;
        }
    }
    return true;
}
 
Example 6
Source File: PieChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.actionToggleValues: {
            for (IDataSet<?> set : mChart.getData().getDataSets())
                set.setDrawValues(!set.isDrawValuesEnabled());

            mChart.invalidate();
            break;
        }
        case R.id.actionToggleHole: {
            if (mChart.isDrawHoleEnabled())
                mChart.setDrawHoleEnabled(false);
            else
                mChart.setDrawHoleEnabled(true);
            mChart.invalidate();
            break;
        }
        case R.id.actionDrawCenter: {
            if (mChart.isDrawCenterTextEnabled())
                mChart.setDrawCenterText(false);
            else
                mChart.setDrawCenterText(true);
            mChart.invalidate();
            break;
        }
        case R.id.actionToggleXVals: {

            mChart.setDrawSliceText(!mChart.isDrawSliceTextEnabled());
            mChart.invalidate();
            break;
        }
        case R.id.actionSave: {
            // mChart.saveToGallery("title"+System.currentTimeMillis());
            mChart.saveToPath("title" + System.currentTimeMillis(), "");
            break;
        }
        case R.id.actionTogglePercent:
            mChart.setUsePercentValues(!mChart.isUsePercentValuesEnabled());
            mChart.invalidate();
            break;
        case R.id.animateX: {
            mChart.animateX(1400);
            break;
        }
        case R.id.animateY: {
            mChart.animateY(1400);
            break;
        }
        case R.id.animateXY: {
            mChart.animateXY(1400, 1400);
            break;
        }
    }
    return true;
}
 
Example 7
Source File: ChartData.java    From StockChart-MPAndroidChart with MIT License 2 votes vote down vote up
/**
 * Enables / disables drawing values (value-text) for all DataSets this data
 * object contains.
 *
 * @param enabled
 */
public void setDrawValues(boolean enabled) {
    for (IDataSet set : mDataSets) {
        set.setDrawValues(enabled);
    }
}
 
Example 8
Source File: ChartData.java    From Ticket-Analysis with MIT License 2 votes vote down vote up
/**
 * Enables / disables drawing values (value-text) for all DataSets this data
 * object contains.
 *
 * @param enabled
 */
public void setDrawValues(boolean enabled) {
    for (IDataSet set : mDataSets) {
        set.setDrawValues(enabled);
    }
}
 
Example 9
Source File: ChartData.java    From android-kline with Apache License 2.0 2 votes vote down vote up
/**
 * Enables / disables drawing values (value-text) for all DataSets this data
 * object contains.
 *
 * @param enabled
 */
public void setDrawValues(boolean enabled) {
    for (IDataSet set : mDataSets) {
        set.setDrawValues(enabled);
    }
}
 
Example 10
Source File: ChartData.java    From Stayfit with Apache License 2.0 2 votes vote down vote up
/**
 * Enables / disables drawing values (value-text) for all DataSets this data
 * object contains.
 *
 * @param enabled
 */
public void setDrawValues(boolean enabled) {
    for (IDataSet set : mDataSets) {
        set.setDrawValues(enabled);
    }
}
 
Example 11
Source File: ChartData.java    From NetKnight with Apache License 2.0 2 votes vote down vote up
/**
 * Enables / disables drawing values (value-text) for all DataSets this data
 * object contains.
 *
 * @param enabled
 */
public void setDrawValues(boolean enabled) {
    for (IDataSet set : mDataSets) {
        set.setDrawValues(enabled);
    }
}