Search in sources :

Example 1 with Entry

use of com.github.mikephil.charting.data.Entry in project MPAndroidChart by PhilJay.

the class CombinedChartActivity method generateScatterData.

protected ScatterData generateScatterData() {
    ScatterData d = new ScatterData();
    ArrayList<Entry> entries = new ArrayList<Entry>();
    for (float index = 0; index < itemcount; index += 0.5f) entries.add(new Entry(index + 0.25f, getRandom(10, 55)));
    ScatterDataSet set = new ScatterDataSet(entries, "Scatter DataSet");
    set.setColors(ColorTemplate.MATERIAL_COLORS);
    set.setScatterShapeSize(7.5f);
    set.setDrawValues(false);
    set.setValueTextSize(10f);
    d.addDataSet(set);
    return d;
}
Also used : CandleEntry(com.github.mikephil.charting.data.CandleEntry) BubbleEntry(com.github.mikephil.charting.data.BubbleEntry) Entry(com.github.mikephil.charting.data.Entry) BarEntry(com.github.mikephil.charting.data.BarEntry) ScatterDataSet(com.github.mikephil.charting.data.ScatterDataSet) ArrayList(java.util.ArrayList) ScatterData(com.github.mikephil.charting.data.ScatterData)

Example 2 with Entry

use of com.github.mikephil.charting.data.Entry in project MPAndroidChart by PhilJay.

the class DrawChartActivity method initWithDummyData.

private void initWithDummyData() {
    ArrayList<Entry> yVals = new ArrayList<Entry>();
    // create a dataset and give it a type (0)
    LineDataSet set1 = new LineDataSet(yVals, "DataSet");
    set1.setLineWidth(3f);
    set1.setCircleRadius(5f);
    // create a data object with the datasets
    LineData data = new LineData(set1);
    mChart.setData(data);
}
Also used : Entry(com.github.mikephil.charting.data.Entry) LineData(com.github.mikephil.charting.data.LineData) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Example 3 with Entry

use of com.github.mikephil.charting.data.Entry in project MPAndroidChart by PhilJay.

the class DynamicalAddingActivity method addDataSet.

private void addDataSet() {
    LineData data = mChart.getData();
    if (data != null) {
        int count = (data.getDataSetCount() + 1);
        ArrayList<Entry> yVals = new ArrayList<Entry>();
        for (int i = 0; i < data.getEntryCount(); i++) {
            yVals.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count));
        }
        LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
        set.setLineWidth(2.5f);
        set.setCircleRadius(4.5f);
        int color = mColors[count % mColors.length];
        set.setColor(color);
        set.setCircleColor(color);
        set.setHighLightColor(color);
        set.setValueTextSize(10f);
        set.setValueTextColor(color);
        data.addDataSet(set);
        data.notifyDataChanged();
        mChart.notifyDataSetChanged();
        mChart.invalidate();
    }
}
Also used : LineData(com.github.mikephil.charting.data.LineData) Entry(com.github.mikephil.charting.data.Entry) ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) LineDataSet(com.github.mikephil.charting.data.LineDataSet) ArrayList(java.util.ArrayList)

Example 4 with Entry

use of com.github.mikephil.charting.data.Entry in project MPAndroidChart by PhilJay.

the class Chart method highlightValue.

/**
     * Highlights the value selected by touch gesture. Unlike
     * highlightValues(...), this generates a callback to the
     * OnChartValueSelectedListener.
     *
     * @param high         - the highlight object
     * @param callListener - call the listener
     */
public void highlightValue(Highlight high, boolean callListener) {
    Entry e = null;
    if (high == null)
        mIndicesToHighlight = null;
    else {
        if (mLogEnabled)
            Log.i(LOG_TAG, "Highlighted: " + high.toString());
        e = mData.getEntryForHighlight(high);
        if (e == null) {
            mIndicesToHighlight = null;
            high = null;
        } else {
            // set the indices to highlight
            mIndicesToHighlight = new Highlight[] { high };
        }
    }
    setLastHighlighted(mIndicesToHighlight);
    if (callListener && mSelectionListener != null) {
        if (!valuesToHighlight())
            mSelectionListener.onNothingSelected();
        else {
            // notify the listener
            mSelectionListener.onValueSelected(e, high);
        }
    }
    // redraw the chart
    invalidate();
}
Also used : Entry(com.github.mikephil.charting.data.Entry)

Example 5 with Entry

use of com.github.mikephil.charting.data.Entry in project MPAndroidChart by PhilJay.

the class Chart method drawMarkers.

/**
     * draws all MarkerViews on the highlighted positions
     */
protected void drawMarkers(Canvas canvas) {
    // if there is no marker view or drawing marker is disabled
    if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight())
        return;
    for (int i = 0; i < mIndicesToHighlight.length; i++) {
        Highlight highlight = mIndicesToHighlight[i];
        IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex());
        Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);
        int entryIndex = set.getEntryIndex(e);
        // make sure entry not null
        if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
            continue;
        float[] pos = getMarkerPosition(highlight);
        // check bounds
        if (!mViewPortHandler.isInBounds(pos[0], pos[1]))
            continue;
        // callbacks to update the content
        mMarker.refreshContent(e, highlight);
        // draw the marker
        mMarker.draw(canvas, pos[0], pos[1]);
    }
}
Also used : Entry(com.github.mikephil.charting.data.Entry) Highlight(com.github.mikephil.charting.highlight.Highlight) IDataSet(com.github.mikephil.charting.interfaces.datasets.IDataSet) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Aggregations

Entry (com.github.mikephil.charting.data.Entry)82 ArrayList (java.util.ArrayList)33 Paint (android.graphics.Paint)26 LineData (com.github.mikephil.charting.data.LineData)19 LineDataSet (com.github.mikephil.charting.data.LineDataSet)18 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)16 BarEntry (com.github.mikephil.charting.data.BarEntry)13 ScatterDataSet (com.github.mikephil.charting.data.ScatterDataSet)10 Path (android.graphics.Path)7 PieEntry (com.github.mikephil.charting.data.PieEntry)7 IOException (java.io.IOException)6 PointF (android.graphics.PointF)5 CandleEntry (com.github.mikephil.charting.data.CandleEntry)5 PieDataSet (com.github.mikephil.charting.data.PieDataSet)5 ScatterData (com.github.mikephil.charting.data.ScatterData)5 Highlight (com.github.mikephil.charting.highlight.Highlight)5 Transformer (com.github.mikephil.charting.utils.Transformer)5 Test (org.junit.Test)5 MPPointF (com.github.mikephil.charting.utils.MPPointF)4 SuppressLint (android.annotation.SuppressLint)3