com.github.mikephil.charting.formatter.DefaultValueFormatter Java Examples

The following examples show how to use com.github.mikephil.charting.formatter.DefaultValueFormatter. 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: Chart.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * calculates the required number of digits for the values that might be
 * drawn in the chart (if enabled), and creates the default-value-formatter
 */
protected void calculateFormatter(float min, float max) {

    float reference = 0f;

    if (mData == null || mData.getXValCount() < 2) {

        reference = Math.max(Math.abs(min), Math.abs(max));
    } else {
        reference = Math.abs(max - min);
    }

    int digits = Utils.getDecimals(reference);
    mDefaultFormatter = new DefaultValueFormatter(digits);
}
 
Example #2
Source File: DataSet.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * If this component has no ValueFormatter or is only equipped with the
 * default one (no custom set), return true.
 *
 * @return
 */
public boolean needsDefaultFormatter() {
    if (mValueFormatter == null)
        return true;
    if (mValueFormatter instanceof DefaultValueFormatter)
        return true;

    return false;
}
 
Example #3
Source File: YAxis.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * If this component has no YAxisValueFormatter or is only equipped with the default one (no custom set), return true.
 * 
 * @return
 */
public boolean needsDefaultFormatter() {
	if (mYAxisValueFormatter == null)
		return true;
	if (mYAxisValueFormatter instanceof DefaultValueFormatter)
		return true;

	return false;
}
 
Example #4
Source File: Chart.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * calculates the required number of digits for the values that might be
 * drawn in the chart (if enabled), and creates the default-value-formatter
 */
protected void calculateFormatter(float min, float max) {

    float reference = 0f;

    if (mData == null || mData.getXValCount() < 2) {

        reference = Math.max(Math.abs(min), Math.abs(max));
    } else {
        reference = Math.abs(max - min);
    }

    int digits = Utils.getDecimals(reference);
    mDefaultFormatter = new DefaultValueFormatter(digits);
}
 
Example #5
Source File: Utils.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * If this component has no ValueFormatter or is only equipped with the
 * default one (no custom set), return true.
 *
 * @return
 */
public static boolean needsDefaultFormatter(ValueFormatter formatter) {
    if (formatter == null)
        return true;
    if (formatter instanceof DefaultValueFormatter)
        return true;

    return false;
}
 
Example #6
Source File: YAxis.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * If this component has no YAxisValueFormatter or is only equipped with the default one (no custom set), return true.
 *
 * @return
 */
public boolean needsDefaultFormatter() {
    if (mYAxisValueFormatter == null)
        return true;
    if (mYAxisValueFormatter instanceof DefaultValueFormatter)
        return true;

    return false;
}
 
Example #7
Source File: Chart.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * calculates the required number of digits for the values that might be
 * drawn in the chart (if enabled), and creates the default-value-formatter
 */
protected void calculateFormatter(float min, float max) {

    float reference = 0f;

    if (mData == null || mData.getXValCount() < 2) {

        reference = Math.max(Math.abs(min), Math.abs(max));
    } else {
        reference = Math.abs(max - min);
    }

    int digits = Utils.getDecimals(reference);
    mDefaultFormatter = new DefaultValueFormatter(digits);
}
 
Example #8
Source File: Utils.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * If this component has no ValueFormatter or is only equipped with the
 * default one (no custom set), return true.
 *
 * @return
 */
public static boolean needsDefaultFormatter(ValueFormatter formatter) {
    if (formatter == null)
        return true;
    if (formatter instanceof DefaultValueFormatter)
        return true;

    return false;
}
 
Example #9
Source File: YAxis.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * If this component has no YAxisValueFormatter or is only equipped with the default one (no
 * custom set), return true.
 *
 * @return
 */
public boolean needsDefaultFormatter() {
    if (mYAxisValueFormatter == null)
        return true;
    if (mYAxisValueFormatter instanceof DefaultValueFormatter)
        return true;

    return false;
}
 
Example #10
Source File: Utils.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
private static ValueFormatter generateDefaultValueFormatter() {
    return new DefaultValueFormatter(1);
}
 
Example #11
Source File: Utils.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
private static IValueFormatter generateDefaultValueFormatter() {
    final DefaultValueFormatter formatter = new DefaultValueFormatter(1);
    return formatter;
}
 
Example #12
Source File: Utils.java    From android-kline with Apache License 2.0 4 votes vote down vote up
private static IValueFormatter generateDefaultValueFormatter() {
    final DefaultValueFormatter formatter = new DefaultValueFormatter(1);
    return formatter;
}
 
Example #13
Source File: StatsActivity.java    From android with MIT License 4 votes vote down vote up
private void createPieChart(List<Long> contacts, List<Long> voicemails, List<Long> unavailables, long firstTimestamp) {
    Date date = new Date(firstTimestamp);

    ArrayList<Integer> colorsList = new ArrayList<>();
    // Create pie pieChart data entries and add correct colors.
    ArrayList<PieEntry> entries = new ArrayList<>();
    if (contacts.size() > 0) {
        entries.add(new PieEntry(contacts.size(), getResources().getString(R.string.contact_n)));
        colorsList.add(getResources().getColor(R.color.contacted_color));
    }
    if (voicemails.size() > 0) {
        entries.add(new PieEntry(voicemails.size(),  getResources().getString(R.string.voicemail_n)));
        colorsList.add(getResources().getColor(R.color.voicemail_color));
    }
    if (unavailables.size() > 0) {
        entries.add(new PieEntry(unavailables.size(),  getResources().getString(R.string.unavailable_n)));
        colorsList.add(getResources().getColor(R.color.unavailable_color));
    }

    PieDataSet dataSet = new PieDataSet(entries, getResources().getString(R.string.menu_stats));

    // Add colors and set visual properties for pie pieChart.
    dataSet.setColors(colorsList);
    dataSet.setSliceSpace(3f);
    dataSet.setSelectionShift(5f);
    dataSet.setValueLinePart1OffsetPercentage(80.f);
    dataSet.setValueLinePart1Length(.1f);
    dataSet.setValueLinePart2Length(.5f);
    dataSet.setValueLineColor(getResources().getColor(R.color.colorPrimaryDark));
    dataSet.setYValuePosition(PieDataSet.ValuePosition.INSIDE_SLICE);
    dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);

    PieData data = new PieData(dataSet);
    data.setValueTextSize(18f);
    data.setValueFormatter(new DefaultValueFormatter(0));
    data.setValueTextColor(Color.WHITE);

    SpannableString insideCircleText = new SpannableString(getResources().getString(R.string.stats_summary_total)
            +"\n"
            + Integer.toString(voicemails.size()+contacts.size()+unavailables.size())
            + "\n"
            + this.dateFormat.format(date)
            + "-"
            + this.dateFormat.format(new Date(System.currentTimeMillis()))
    );
    insideCircleText.setSpan(new RelativeSizeSpan(2f), 0, insideCircleText.length() - 17, 0);

    pieChart.setData(data);
    pieChart.setCenterText(insideCircleText);
    pieChart.setCenterTextColor(getResources().getColor(R.color.colorPrimaryDark));
    pieChart.setCenterTextSize(11f);
    pieChart.setHoleRadius(70);
    pieChart.setEntryLabelColor(getResources().getColor(R.color.colorPrimaryDark));
    pieChart.getLegend().setEnabled(false);
    pieChart.setDescription(new Description());
    pieChart.getDescription().setText("");
    pieChart.invalidate();
}
 
Example #14
Source File: DataSet.java    From iMoney with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the formatter used for drawing the values inside the chart.
 *
 * @return
 */
public ValueFormatter getValueFormatter() {
    if (mValueFormatter == null)
        return new DefaultValueFormatter(1);
    return mValueFormatter;
}
 
Example #15
Source File: BaseDataSet.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public ValueFormatter getValueFormatter() {
    if (mValueFormatter == null)
        return new DefaultValueFormatter(1);
    return mValueFormatter;
}
 
Example #16
Source File: BaseDataSet.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@Override
public ValueFormatter getValueFormatter() {
    if (mValueFormatter == null)
        return new DefaultValueFormatter(1);
    return mValueFormatter;
}