Java 类com.github.mikephil.charting.data.CandleEntry 实例源码

项目:GitHub    文件:CombinedChartActivity.java   
protected CandleData generateCandleData() {

        CandleData d = new CandleData();

        ArrayList<CandleEntry> entries = new ArrayList<CandleEntry>();

        for (int index = 0; index < itemcount; index += 2)
            entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f));

        CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
        set.setDecreasingColor(Color.rgb(142, 150, 175));
        set.setShadowColor(Color.DKGRAY);
        set.setBarSpace(0.3f);
        set.setValueTextSize(10f);
        set.setDrawValues(false);
        d.addDataSet(set);

        return d;
    }
项目:DOUSalaries    文件:ExperienceMarker.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    if (e instanceof CandleEntry) {
        CandleEntry ce = (CandleEntry) e;
        tvContent.setText(getContext().getString(R.string.salaries_format_salary,
                (int) ce.getHigh()));
    } else {
        EntryMarkerData data = (EntryMarkerData) e.getData();
        tvContent.setText(getContext().getString(R.string.exp_format_marker,
                String.valueOf(data.getValue()),
                String.valueOf(data.getCount())
                )
        );
    }
    super.refreshContent(e, highlight);
}
项目:igrow-android    文件:EnvironmentalSensorDetailFragment.java   
protected CandleData generateCandleData() {

        CandleData d = new CandleData();

        ArrayList<CandleEntry> entries = new ArrayList<CandleEntry>();

        for (int index = 0; index < itemcount; index += 2)
            entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f));

        CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
        set.setDecreasingColor(Color.rgb(142, 150, 175));
        set.setShadowColor(Color.DKGRAY);
        set.setBarSpace(0.3f);
        set.setValueTextSize(10f);
        set.setDrawValues(false);
        d.addDataSet(set);

        return d;
    }
项目:Liapp    文件:MyMarkerView.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    SharedPreferences sharedPrefs = PreferenceManager
            .getDefaultSharedPreferences(tvContent.getContext().getApplicationContext());

    if (e instanceof CandleEntry) {

        CandleEntry ce = (CandleEntry) e;

        tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
    } else {
        if(sharedPrefs.getString("pref_unit", "mg/dl").equals("mg/dl")) {
            tvContent.setText("" + Utils.formatNumber(e.getVal(), 0, true));
        }else{
            tvContent.setText("" + Utils.formatNumber(e.getVal(), 1, true));
        }
    }
}
项目:Stayfit    文件:CombinedChartActivity.java   
protected CandleData generateCandleData() {

        CandleData d = new CandleData();

        ArrayList<CandleEntry> entries = new ArrayList<CandleEntry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new CandleEntry(index, 20f, 10f, 13f, 17f));

        CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
        set.setColor(Color.rgb(80, 80, 80));
        set.setBarSpace(0.3f);
        set.setValueTextSize(10f);
        set.setDrawValues(false);
        d.addDataSet(set);

        return d;
    }
项目:ecological-marine-unit-android    文件:SummaryChartPresenter.java   
/**
 * Prepare CandleData for candlestick chart
 * @param xIndex - float
 * @param shadowH - float
 * @param shadowL - float
 * @param open - float
 * @param close - float
 * @param seriesName - String
 * @return CandleData
 */
private CandleData generateCandleData(float xIndex, float shadowH, float shadowL, float open, float close, String seriesName){
  CandleData d = new CandleData();
  ArrayList<CandleEntry> entries = new ArrayList<>();
  entries.add(new CandleEntry(xIndex, shadowH, shadowL, open, close));
  CandleDataSet set = new CandleDataSet(entries, seriesName);
  set.setDecreasingColor(Color.rgb(142, 150, 175));
  set.setShadowColor(Color.DKGRAY);
  set.setDecreasingColor(Color.parseColor("#2196F3"));
  set.setBarSpace(0.3f);
  set.setValueTextSize(10f);
  set.setShadowWidth(2f);
  set.setDrawValues(false);
  d.addDataSet(set);
  return d;
}
项目:react-native-mp-android-chart    文件:CandleStickChartManager.java   
@Override
CandleEntry createEntry(ReadableArray yValues, int index) {
    if (!ReadableType.Map.equals(yValues.getType(index))) {
        throw new IllegalArgumentException();
    }

    ReadableMap entryData = yValues.getMap(index);
    if (!BridgeUtils.validate(entryData, ReadableType.Number, "shadowH") ||
            !BridgeUtils.validate(entryData, ReadableType.Number, "shadowL") ||
            !BridgeUtils.validate(entryData, ReadableType.Number, "open") ||
            !BridgeUtils.validate(entryData, ReadableType.Number, "close")) {
        throw new IllegalArgumentException("CandleStick data must contain: shadowH, shadowL, open and close values");
    }

    float shadowH = (float) entryData.getDouble("shadowH");
    float shadowL = (float) entryData.getDouble("shadowL");
    float open = (float) entryData.getDouble("open");
    float close = (float) entryData.getDouble("close");

    return new CandleEntry(index, shadowH, shadowL, open, close);
}
项目:xs-android-architecture    文件:CombinedChartActivity.java   
protected CandleData generateCandleData() {

        CandleData d = new CandleData();

        ArrayList<CandleEntry> entries = new ArrayList<CandleEntry>();

        for (int index = 0; index < itemcount; index += 2)
            entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f));

        CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
        set.setDecreasingColor(Color.rgb(142, 150, 175));
        set.setShadowColor(Color.DKGRAY);
        set.setBarSpace(0.3f);
        set.setValueTextSize(10f);
        set.setDrawValues(false);
        d.addDataSet(set);

        return d;
    }
项目:MPAndroidChart    文件:CombinedChartActivity.java   
protected CandleData generateCandleData() {

        CandleData d = new CandleData();

        ArrayList<CandleEntry> entries = new ArrayList<CandleEntry>();

        for (int index = 0; index < itemcount; index += 2)
            entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f));

        CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
        set.setDecreasingColor(Color.rgb(142, 150, 175));
        set.setShadowColor(Color.DKGRAY);
        set.setBarSpace(0.3f);
        set.setValueTextSize(10f);
        set.setDrawValues(false);
        d.addDataSet(set);

        return d;
    }
项目:GitHub    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesCandle(ICandleDataSet data,
                                               float phaseX, float phaseY, int from, int to) {

    final int count = (int) ((to - from) * phaseX + 1) * 2;

    if (valuePointsForGenerateTransformedValuesCandle.length != count) {
        valuePointsForGenerateTransformedValuesCandle = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesCandle;

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
项目:DOUSalaries    文件:SalaryMarker.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    if (e instanceof CandleEntry) {
        CandleEntry ce = (CandleEntry) e;
        tvContent.setText(getContext().getString(R.string.salaries_format_salary,
                (int) ce.getHigh()));
    } else {
        SalaryData salary = (SalaryData) e.getData();
        if (salary != null) {
                tvContent.setText(getContext().getString(R.string.salaries_format_marker_short,
                        salary.getDate(), salary.getSalariesCount(), (int) e.getY()));
        }
    }
    super.refreshContent(e, highlight);
}
项目:Stayfit    文件:RealmCandleDataSet.java   
@Override
public void calcMinMax(int start, int end) {

    if (mValues == null)
        return;

    if (mValues.size() == 0)
        return;

    int endValue;

    if (end == 0 || end >= mValues.size())
        endValue = mValues.size() - 1;
    else
        endValue = end;

    mYMin = Float.MAX_VALUE;
    mYMax = -Float.MAX_VALUE;

    for (int i = start; i <= endValue; i++) {

        CandleEntry e = mValues.get(i);

        if (e.getLow() < mYMin)
            mYMin = e.getLow();

        if (e.getHigh() > mYMax)
            mYMax = e.getHigh();
    }
}
项目:SecretBrand    文件:GraphMarkerView.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    if (e instanceof CandleEntry) {

        CandleEntry ce = (CandleEntry) e;

        tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, true));
    } else {

        tvContent.setText(String.valueOf((int)e.getVal()));
    }
}
项目:NetKnight    文件:RealmCandleDataSet.java   
public CandleEntry buildEntryFromResultObject(T realmObject, int xIndex) {
    DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);

    return new CandleEntry(
            mIndexField == null ? xIndex : dynamicObject.getInt(mIndexField),
            dynamicObject.getFloat(mHighField),
            dynamicObject.getFloat(mLowField),
            dynamicObject.getFloat(mOpenField),
            dynamicObject.getFloat(mCloseField));
}
项目:NetKnight    文件:RealmCandleDataSet.java   
@Override
public void calcMinMax(int start, int end) {

    if (mValues == null)
        return;

    if (mValues.size() == 0)
        return;

    int endValue;

    if (end == 0 || end >= mValues.size())
        endValue = mValues.size() - 1;
    else
        endValue = end;

    mYMin = Float.MAX_VALUE;
    mYMax = -Float.MAX_VALUE;

    for (int i = start; i <= endValue; i++) {

        CandleEntry e = mValues.get(i);

        if (e.getLow() < mYMin)
            mYMin = e.getLow();

        if (e.getHigh() > mYMax)
            mYMax = e.getHigh();
    }
}
项目:MarketBot    文件:MarketHistoryTab.java   
private CandleData generateMarginCandleData(List<MarketHistory> historyEntries) {

        SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());

        int size = historyEntries.size();
        List<CandleEntry> entries = new ArrayList<>(size);
        List<String> xAxis = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            MarketHistory history = historyEntries.get(i);
            Date recordDate = new Date(history.getRecordDate());

            xAxis.add(format.format(recordDate));
            entries.add(new CandleEntry(i,
                (float) history.getHighPrice(),
                (float) history.getLowPrice(),
                (float) history.getAveragePrice(),
                (float) history.getAveragePrice()
            ));
        }

        CandleDataSet set = new CandleDataSet(entries, "Price Margins");
        set.setShadowColor(Color.DKGRAY);
        set.setShadowWidth(2.0f);
        set.setShowCandleBar(true);
        set.setBarSpace(0.35f);
        set.setNeutralColor(Color.DKGRAY);
        set.setDrawValues(false);

        set.setDrawHighlightIndicators(false);
        set.setDrawVerticalHighlightIndicator(false);

        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        return new CandleData(xAxis, set);

    }
项目:react-native-mp-android-chart    文件:CandleStickChartManager.java   
@Override
void dataSetConfig(IDataSet<CandleEntry> dataSet, ReadableMap config) {
    CandleDataSet candleDataSet = (CandleDataSet) dataSet;

    ChartDataSetConfigUtils.commonConfig(candleDataSet, config);
    ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(candleDataSet, config);
    ChartDataSetConfigUtils.commonLineScatterCandleRadarConfig(candleDataSet, config);

    // CandleDataSet only config
    if (BridgeUtils.validate(config, ReadableType.Number, "barSpace")) {
        candleDataSet.setBarSpace((float) config.getDouble("barSpace"));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "shadowWidth")) {
        candleDataSet.setShadowWidth((float) config.getDouble("shadowWidth"));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "shadowColor")) {
        candleDataSet.setShadowColor(Color.parseColor(config.getString("shadowColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "shadowColorSameAsCandle")) {
        candleDataSet.setShadowColorSameAsCandle(config.getBoolean("shadowColorSameAsCandle"));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "neutralColor")) {
        candleDataSet.setNeutralColor(Color.parseColor(config.getString("neutralColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "decreasingColor")) {
        candleDataSet.setDecreasingColor(Color.parseColor(config.getString("decreasingColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "decreasingPaintStyle")) {
        candleDataSet.setDecreasingPaintStyle(Paint.Style.valueOf(config.getString("decreasingPaintStyle").toUpperCase()));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "increasingColor")) {
        candleDataSet.setIncreasingColor(Color.parseColor(config.getString("increasingColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "increasingPaintStyle")) {
        candleDataSet.setIncreasingPaintStyle(Paint.Style.valueOf(config.getString("increasingPaintStyle").toUpperCase()));
    }
}
项目:react-native-mp-android-chart    文件:RNMarkerView.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    if (e instanceof CandleEntry) {
        CandleEntry ce = (CandleEntry) e;
        tvContent.setText(Utils.formatNumber(ce.getClose(), 2, true));
    } else {
        tvContent.setText(Utils.formatNumber(e.getVal(), 0, true));
    }
}
项目:xs-android-architecture    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesCandle(ICandleDataSet data,
                                               float phaseX, float phaseY, int from, int to) {

    final int count = (int) ((to - from) * phaseX + 1) * 2;

    if (valuePointsForGenerateTransformedValuesCandle.length != count) {
        valuePointsForGenerateTransformedValuesCandle = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesCandle;

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
项目:go-bees    文件:BeesMarkerView.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    if (e instanceof CandleEntry) {
        CandleEntry ce = (CandleEntry) e;
        tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
    } else {
        tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
    }
    super.refreshContent(e, highlight);
}
项目:LETO-Toggl_Android    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesCandle(ICandleDataSet data,
                                               float phaseX, float phaseY, int from, int to) {

    final int count = (int) ((to - from) * phaseX + 1) * 2;

    if (valuePointsForGenerateTransformedValuesCandle.length != count) {
        valuePointsForGenerateTransformedValuesCandle = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesCandle;

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
项目:QuShuChe    文件:RealmCandleDataSet.java   
@Override
public void calcMinMax(int start, int end) {

    if (mValues == null)
        return;

    if (mValues.size() == 0)
        return;

    int endValue;

    if (end == 0 || end >= mValues.size())
        endValue = mValues.size() - 1;
    else
        endValue = end;

    mYMin = Float.MAX_VALUE;
    mYMax = -Float.MAX_VALUE;

    for (int i = start; i <= endValue; i++) {

        CandleEntry e = mValues.get(i);

        if (e.getLow() < mYMin)
            mYMin = e.getLow();

        if (e.getHigh() > mYMax)
            mYMax = e.getHigh();
    }
}
项目:MPAndroidChart-Realm    文件:RealmCandleDataSet.java   
@Override
public CandleEntry buildEntryFromResultObject(T realmObject, float x) {
    DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);

    return new CandleEntry(
            mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField),
            dynamicObject.getFloat(mHighField),
            dynamicObject.getFloat(mLowField),
            dynamicObject.getFloat(mOpenField),
            dynamicObject.getFloat(mCloseField));
}
项目:MPAndroidChart-Realm    文件:RealmCandleDataSet.java   
@Override
protected void calcMinMax(CandleEntry e) {

    if (e.getLow() < mYMin)
        mYMin = e.getLow();

    if (e.getHigh() > mYMax)
        mYMax = e.getHigh();

    calcMinMaxX(e);
}
项目:MPAndroidChart-Realm    文件:RealmCandleDataSet.java   
@Override
protected void calcMinMaxY(CandleEntry e) {

    if (e.getHigh() < mYMin)
        mYMin = e.getHigh();

    if (e.getHigh() > mYMax)
        mYMax = e.getHigh();

    if (e.getLow() < mYMin)
        mYMin = e.getLow();

    if (e.getLow() > mYMax)
        mYMax = e.getLow();
}
项目:mobile-manager-for-cloudflare    文件:CandleStickChart.java   
/**
 * Transforms the values of an entry in order to draw the candle-body.
 * 
 * @param bodyPoints
 * @param e
 * @param bodySpace
 */
private void transformBody(float[] bodyPoints, CandleEntry e, float bodySpace) {

    bodyPoints[0] = e.getXIndex() + bodySpace;
    bodyPoints[1] = e.getClose() * mPhaseY;
    bodyPoints[2] = e.getXIndex() + (1f - bodySpace);
    bodyPoints[3] = e.getOpen() * mPhaseY;

    mTrans.pointValuesToPixel(bodyPoints);
}
项目:mobile-manager-for-cloudflare    文件:CandleStickChart.java   
/**
 * Transforms the values of an entry in order to draw the candle-shadow.
 * 
 * @param shadowPoints
 * @param e
 */
private void transformShadow(float[] shadowPoints, CandleEntry e) {

    shadowPoints[0] = e.getXIndex() + 0.5f;
    shadowPoints[1] = e.getHigh() * mPhaseY;
    shadowPoints[2] = e.getXIndex() + 0.5f;
    shadowPoints[3] = e.getLow() * mPhaseY;

    mTrans.pointValuesToPixel(shadowPoints);
}
项目:Infodota    文件:GraphMarkerView.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {
    if (e instanceof CandleEntry) {

        CandleEntry ce = (CandleEntry) e;

        tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, true));
    } else {

        tvContent.setText(String.valueOf((int)e.getVal()));
    }
}
项目:MPAndroidChart    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesCandle(ICandleDataSet data,
                                               float phaseX, float phaseY, int from, int to) {

    final int count = (int) ((to - from) * phaseX + 1) * 2;

    if (valuePointsForGenerateTransformedValuesCandle.length != count) {
        valuePointsForGenerateTransformedValuesCandle = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesCandle;

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
项目:braingames    文件:CandleStickChart.java   
/**
 * Transforms the values of an entry in order to draw the candle-body.
 * 
 * @param bodyPoints
 * @param e
 * @param bodySpace
 */
private void transformBody(float[] bodyPoints, CandleEntry e, float bodySpace) {

    bodyPoints[0] = e.getXIndex() + bodySpace;
    bodyPoints[1] = e.getClose() * mPhaseY;
    bodyPoints[2] = e.getXIndex() + (1f - bodySpace);
    bodyPoints[3] = e.getOpen() * mPhaseY;

    mTrans.pointValuesToPixel(bodyPoints);
}
项目:braingames    文件:CandleStickChart.java   
/**
 * Transforms the values of an entry in order to draw the candle-shadow.
 * 
 * @param shadowPoints
 * @param e
 */
private void transformShadow(float[] shadowPoints, CandleEntry e) {

    shadowPoints[0] = e.getXIndex() + 0.5f;
    shadowPoints[1] = e.getHigh() * mPhaseY;
    shadowPoints[2] = e.getXIndex() + 0.5f;
    shadowPoints[3] = e.getLow() * mPhaseY;

    mTrans.pointValuesToPixel(shadowPoints);
}
项目:Notification-Analyser    文件:CandleStickChart.java   
/**
 * Transforms the values of an entry in order to draw the candle-body.
 * 
 * @param bodyPoints
 * @param e
 * @param bodySpace
 */
private void transformBody(float[] bodyPoints, CandleEntry e, float bodySpace) {

    bodyPoints[0] = e.getXIndex() + bodySpace;
    bodyPoints[1] = e.getClose() * mPhaseY;
    bodyPoints[2] = e.getXIndex() + (1f - bodySpace);
    bodyPoints[3] = e.getOpen() * mPhaseY;

    transformPointArray(bodyPoints);
}
项目:Notification-Analyser    文件:CandleStickChart.java   
/**
 * Transforms the values of an entry in order to draw the candle-shadow.
 * 
 * @param shadowPoints
 * @param e
 */
private void transformShadow(float[] shadowPoints, CandleEntry e) {

    shadowPoints[0] = e.getXIndex() + 0.5f;
    shadowPoints[1] = e.getHigh() * mPhaseY;
    shadowPoints[2] = e.getXIndex() + 0.5f;
    shadowPoints[3] = e.getLow() * mPhaseY;

    transformPointArray(shadowPoints);
}
项目:GitHub    文件:CandleStickChartActivity.java   
@Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

        int prog = (mSeekBarX.getProgress() + 1);

        tvX.setText("" + prog);
        tvY.setText("" + (mSeekBarY.getProgress()));

        mChart.resetTracking();

        ArrayList<CandleEntry> yVals1 = new ArrayList<CandleEntry>();

        for (int i = 0; i < prog; i++) {
            float mult = (mSeekBarY.getProgress() + 1);
            float val = (float) (Math.random() * 40) + mult;

            float high = (float) (Math.random() * 9) + 8f;
            float low = (float) (Math.random() * 9) + 8f;

            float open = (float) (Math.random() * 6) + 1f;
            float close = (float) (Math.random() * 6) + 1f;

            boolean even = i % 2 == 0;

            yVals1.add(new CandleEntry(
                    i, val + high,
                    val - low,
                    even ? val + open : val - open,
                    even ? val - close : val + close,
                    getResources().getDrawable(R.drawable.star)
            ));
        }

        CandleDataSet set1 = new CandleDataSet(yVals1, "Data Set");

        set1.setDrawIcons(false);
        set1.setAxisDependency(AxisDependency.LEFT);
//        set1.setColor(Color.rgb(80, 80, 80));
        set1.setShadowColor(Color.DKGRAY);
        set1.setShadowWidth(0.7f);
        set1.setDecreasingColor(Color.RED);
        set1.setDecreasingPaintStyle(Paint.Style.FILL);
        set1.setIncreasingColor(Color.rgb(122, 242, 84));
        set1.setIncreasingPaintStyle(Paint.Style.STROKE);
        set1.setNeutralColor(Color.BLUE);
        //set1.setHighlightLineWidth(1f);

        CandleData data = new CandleData(set1);

        mChart.setData(data);
        mChart.invalidate();
    }
项目:AndiCar    文件:LineChartComponent.java   
@Override
public void refreshContent(Entry e, Highlight highlight) {

    if (e instanceof CandleEntry) {

        CandleEntry ce = (CandleEntry) e;

        tvContent.setText(com.github.mikephil.charting.utils.Utils.formatNumber(ce.getHigh(), 3, true));
    }
    else {

        tvContent.setText(com.github.mikephil.charting.utils.Utils.formatNumber(e.getY(), 3, true));
    }

    super.refreshContent(e, highlight);
}
项目:Stayfit    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesCandle(ICandleDataSet data,
                                               float phaseX, float phaseY, int from, int to) {

    final int count = (int) Math.ceil((to - from) * phaseX) * 2;

    float[] valuePoints = new float[count];

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getXIndex();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
项目:Stayfit    文件:CandleStickChartActivity.java   
@Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

        int prog = (mSeekBarX.getProgress() + 1);

        tvX.setText("" + prog);
        tvY.setText("" + (mSeekBarY.getProgress()));

        mChart.resetTracking();

        ArrayList<CandleEntry> yVals1 = new ArrayList<CandleEntry>();

        for (int i = 0; i < prog; i++) {
            float mult = (mSeekBarY.getProgress() + 1);
            float val = (float) (Math.random() * 40) + mult;

            float high = (float) (Math.random() * 9) + 8f;
            float low = (float) (Math.random() * 9) + 8f;

            float open = (float) (Math.random() * 6) + 1f;
            float close = (float) (Math.random() * 6) + 1f;

            boolean even = i % 2 == 0;

            yVals1.add(new CandleEntry(i, val + high, val - low, even ? val + open : val - open,
                    even ? val - close : val + close));
        }

        ArrayList<String> xVals = new ArrayList<String>();
        for (int i = 0; i < prog; i++) {
            xVals.add("" + (1990 + i));
        }

        CandleDataSet set1 = new CandleDataSet(yVals1, "Data Set");
        set1.setAxisDependency(AxisDependency.LEFT);
//        set1.setColor(Color.rgb(80, 80, 80));
        set1.setShadowColor(Color.DKGRAY);
        set1.setShadowWidth(0.7f);
        set1.setDecreasingColor(Color.RED);
        set1.setDecreasingPaintStyle(Paint.Style.FILL);
        set1.setIncreasingColor(Color.rgb(122, 242, 84));
        set1.setIncreasingPaintStyle(Paint.Style.STROKE);
        set1.setNeutralColor(Color.BLUE);
        //set1.setHighlightLineWidth(1f);

        CandleData data = new CandleData(xVals, set1);

        mChart.setData(data);
        mChart.invalidate();
    }
项目:NetKnight    文件:CandleStickChartRenderer.java   
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    CandleData candleData = mChart.getCandleData();

    for (Highlight high : indices) {

        final int minDataSetIndex = high.getDataSetIndex() == -1
                ? 0
                : high.getDataSetIndex();
        final int maxDataSetIndex = high.getDataSetIndex() == -1
                ? candleData.getDataSetCount()
                : (high.getDataSetIndex() + 1);
        if (maxDataSetIndex - minDataSetIndex < 1) continue;

        for (int dataSetIndex = minDataSetIndex;
             dataSetIndex < maxDataSetIndex;
             dataSetIndex++) {

            int xIndex = high.getXIndex(); // get the
            // x-position

            ICandleDataSet set = mChart.getCandleData().getDataSetByIndex(dataSetIndex);

            if (set == null || !set.isHighlightEnabled())
                continue;

            CandleEntry e = set.getEntryForXIndex(xIndex);

            if (e == null || e.getXIndex() != xIndex)
                continue;

            float lowValue = e.getLow() * mAnimator.getPhaseY();
            float highValue = e.getHigh() * mAnimator.getPhaseY();
            float y = (lowValue + highValue) / 2f;

            float[] pts = new float[]{
                    xIndex, y
            };

            mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);

            // draw the lines
            drawHighlightLines(c, pts, set);
        }
    }
}
项目:NetKnight    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesCandle(ICandleDataSet data,
                                               float phaseX, float phaseY, int from, int to) {

    final int count = (int) Math.ceil((to - from) * phaseX) * 2;

    float[] valuePoints = new float[count];

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getXIndex();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
项目:P2P    文件:Transformer.java   
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the CANDLESTICKCHART.
 * 
 * @param entries
 * @return
 */
public float[] generateTransformedValuesCandle(List<CandleEntry> entries,
       float phaseX, float phaseY, int from, int to) {

    final int count = (int)Math.ceil((to - from) * phaseX) * 2;

    float[] valuePoints = new float[count];

    for (int j = 0; j < count; j += 2) {

        CandleEntry e = entries.get(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getXIndex();
            valuePoints[j + 1] = e.getHigh() * phaseY;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}