Java Code Examples for com.github.mikephil.charting.data.Entry#getData()

The following examples show how to use com.github.mikephil.charting.data.Entry#getData() . 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: FragmentBarChart.java    From fingen with Apache License 2.0 6 votes vote down vote up
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
    ReportBuilder reportBuilder = ReportBuilder.getInstance(getActivity());
            IAbstractModel model = (IAbstractModel) e.getData();
            if (reportBuilder.getParentID() != model.getID() && AbstractModelManager.getAllChildren(model, getActivity()).size() > 0) {
                reportBuilder.setParentID(model.getID());
                updateChart();
                return;
            }
    CabbageFormatter cabbageFormatter = null;
    try {
        cabbageFormatter = new CabbageFormatter(reportBuilder.getActiveCabbage());
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    String s = String.format("%s %s", e.getData().toString(), cabbageFormatter.format(new BigDecimal(e.getVal())));
    Toast.makeText(getActivity(), s, Toast.LENGTH_SHORT).show();
    mFabLayout.setVisibility(View.VISIBLE);
}
 
Example 2
Source File: FragmentPieChart.java    From fingen with Apache License 2.0 6 votes vote down vote up
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
    ReportBuilder reportBuilder = ReportBuilder.getInstance(getActivity());
    IAbstractModel model = (IAbstractModel) e.getData();
    if (reportBuilder.getParentID() != model.getID() && AbstractModelManager.getAllChildren(model, getActivity()).size() > 0) {
        reportBuilder.setParentID(model.getID());
        updateChart(true);
        return;
    }
    CabbageFormatter cabbageFormatter = null;
    try {
        cabbageFormatter = new CabbageFormatter(reportBuilder.getActiveCabbage());
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    String s = String.format("%s %s", e.getData().toString(), cabbageFormatter.format(new BigDecimal(e.getVal())));
    GradientDrawable bgShape = (GradientDrawable) mImageViewColor.getBackground();
    IPieDataSet dataSet = mPieChart.getData().getDataSet();
    bgShape.setColor(dataSet.getColor(dataSet.getEntryIndex(e)));
    mTextViewSelected.setText(s);

    mFabLayout.setVisibility(View.VISIBLE);
    mImageViewColor.setVisibility(View.VISIBLE);
    mTextViewSelected.setVisibility(View.VISIBLE);
}
 
Example 3
Source File: OverviewFragment.java    From openScale with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onValueSelected(Entry e, Highlight h) {
    Object[] extraData = (Object[])e.getData();

    markedMeasurement = (ScaleMeasurement)extraData[0];
    //MeasurementView measurementView = (MeasurementView)extraData[1];

    showEntry.setEnabled(true);
    editEntry.setEnabled(true);
    deleteEntry.setEnabled(true);

    showEntry.setColorFilter(ColorUtil.COLOR_BLUE);
    editEntry.setColorFilter(ColorUtil.COLOR_GREEN);
    deleteEntry.setColorFilter(ColorUtil.COLOR_RED);

    updateMesurementViews(markedMeasurement);
}
 
Example 4
Source File: GeneralDialogCreation.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public String getFormattedValue(float value, Entry entry, int dataSetIndex,
                                    ViewPortHandler viewPortHandler) {
        String prefix = entry.getData()!=null&&entry.getData() instanceof String?
(String) entry.getData():"";

        return prefix+Formatter.formatFileSize(context, (long) value);
    }
 
Example 5
Source File: FragmentTimeBarChart.java    From fingen with Apache License 2.0 5 votes vote down vote up
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {CabbageFormatter cabbageFormatter = null;
    try {
        cabbageFormatter = new CabbageFormatter(ReportBuilder.getInstance(getActivity()).getActiveCabbage());
        DateRangeSum rangeSum = (DateRangeSum) e.getData();
        String s = String.format("%s", cabbageFormatter.format(rangeSum.getSum()));
        Toast.makeText(getActivity(), s, Toast.LENGTH_SHORT).show();
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    mFabLayout.setVisibility(View.VISIBLE);
}
 
Example 6
Source File: ChartMarkerView.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void refreshContent(Entry e, Highlight highlight) {
    Object[] extraData = (Object[])e.getData();
    ScaleMeasurement measurement = (ScaleMeasurement)extraData[0];
    ScaleMeasurement prevMeasurement = (ScaleMeasurement)extraData[1];
    FloatMeasurementView measurementView = (FloatMeasurementView)extraData[2];

    SpannableStringBuilder markerText = new SpannableStringBuilder();

    if (measurement != null) {
        measurementView.loadFrom(measurement, prevMeasurement);
        DateFormat dateFormat = DateFormat.getDateInstance();
        markerText.append(dateFormat.format(measurement.getDateTime()));
        markerText.setSpan(new RelativeSizeSpan(0.8f), 0, markerText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        markerText.append("\n");

        if (measurement.isAverageValue()) {
            markerText.append("Ø ");
        }
    }

    markerText.append(measurementView.getValueAsString(true));

    if (prevMeasurement != null) {
        markerText.append("\n");
        int textPosAfterSymbol = markerText.length() + 1;

        measurementView.appendDiffValue(markerText, false);

        // set color diff value to text color
        if (markerText.length() > textPosAfterSymbol) {
            markerText.setSpan(new ForegroundColorSpan(ColorUtil.COLOR_WHITE), textPosAfterSymbol, markerText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }

    markerText.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER),0, markerText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    markerTextField.setText(markerText);

    super.refreshContent(e, highlight);
}
 
Example 7
Source File: GraphFragment.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onValueSelected(Entry e, Highlight h) {
    Object[] extraData = (Object[])e.getData();

    if (extraData == null) {
        return;
    }

    markedMeasurement = (ScaleMeasurement)extraData[0];
    //MeasurementView measurementView = (MeasurementView)extraData[1];

    showMenu.setVisibility(View.VISIBLE);
    editMenu.setVisibility(View.VISIBLE);
    deleteMenu.setVisibility(View.VISIBLE);
}