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

项目: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;
    }
项目:GitHub    文件:RealmDatabaseActivityCandle.java   
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "xValue", "high", "low", "open", "close");
        set.setLabel("Realm CandleDataSet");
        set.setShadowColor(Color.DKGRAY);
        set.setShadowWidth(0.7f);
        set.setDecreasingColor(Color.RED);
        set.setDecreasingPaintStyle(Paint.Style.FILL);
        set.setIncreasingColor(Color.rgb(122, 242, 84));
        set.setIncreasingPaintStyle(Paint.Style.STROKE);
        set.setNeutralColor(Color.BLUE);

        ArrayList<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        CandleData data = new CandleData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目: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;
    }
项目: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   
/**
 * Create dataset to be displayed in chart legend
 * @return CombinedData representing dummy data for a legend
 */
private CombinedData buildDummyDataForLegend(){
  CombinedData combinedData = new CombinedData();
  float xIndex = 1.5f;
  float close = 13;
  float open = 26f;
  float shadowH = 30.33f;
  float shadowL = -2.05f;
  float average = 20f;
  CandleData candleData = generateCandleData(xIndex, shadowH, shadowL, open, close, "EMU HI/LO" );
  ScatterData scatterData = generateScatterData(average, "EMU Mean");

  LineData s1 = generateOceanHiLo(close, open, "Ocean HI/LO");
  combinedData.setData(s1);
  combinedData.setData(candleData);
  combinedData.setData(scatterData);
  return combinedData;
}
项目: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;
}
项目: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;
    }
项目:xs-android-architecture    文件:RealmDatabaseActivityCandle.java   
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "xValue", "high", "low", "open", "close");
        set.setLabel("Realm CandleDataSet");
        set.setShadowColor(Color.DKGRAY);
        set.setShadowWidth(0.7f);
        set.setDecreasingColor(Color.RED);
        set.setDecreasingPaintStyle(Paint.Style.FILL);
        set.setIncreasingColor(Color.rgb(122, 242, 84));
        set.setIncreasingPaintStyle(Paint.Style.STROKE);
        set.setNeutralColor(Color.BLUE);

        ArrayList<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        CandleData data = new CandleData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目: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;
    }
项目:MPAndroidChart    文件:RealmDatabaseActivityCandle.java   
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();

        RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "xValue", "high", "low", "open", "close");
        set.setLabel("Realm CandleDataSet");
        set.setShadowColor(Color.DKGRAY);
        set.setShadowWidth(0.7f);
        set.setDecreasingColor(Color.RED);
        set.setDecreasingPaintStyle(Paint.Style.FILL);
        set.setIncreasingColor(Color.rgb(122, 242, 84));
        set.setIncreasingPaintStyle(Paint.Style.STROKE);
        set.setNeutralColor(Color.BLUE);

        ArrayList<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        CandleData data = new CandleData(dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
    }
项目:GitHub    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (ICandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
项目:Stayfit    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (ICandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
项目:NetKnight    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (ICandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
项目: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);

    }
项目:P2P    文件:CandleStickChartRenderer.java   
@Override
public void initBuffers() {
    CandleData candleData = mChart.getCandleData();
    mShadowBuffers = new CandleShadowBuffer[candleData.getDataSetCount()];
    mBodyBuffers = new CandleBodyBuffer[candleData.getDataSetCount()];

    for (int i = 0; i < mShadowBuffers.length; i++) {
        CandleDataSet set = candleData.getDataSetByIndex(i);
        mShadowBuffers[i] = new CandleShadowBuffer(set.getValueCount() * 4);
        mBodyBuffers[i] = new CandleBodyBuffer(set.getValueCount() * 4);
    }
}
项目:P2P    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (CandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
项目:xs-android-architecture    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (ICandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
项目:LETO-Toggl_Android    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    ICandleDataSet set;
    List<ICandleDataSet> dataSets = candleData.getDataSets();
    int setCount = dataSets.size();
    for (int i = 0; i < setCount; i++) {
        set = dataSets.get(i);

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
项目:QuShuChe    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (ICandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
项目:MPAndroidChart    文件:CandleStickChartRenderer.java   
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

    for (ICandleDataSet set : candleData.getDataSets()) {

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
项目:GitHub    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:GitHub    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目: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();
    }
项目:Stayfit    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:Stayfit    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目: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    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:NetKnight    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目: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);
        }
    }
}
项目:P2P    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:P2P    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目:react-native-mp-android-chart    文件:CandleStickChartManager.java   
@Override
ChartData createData(String[] xValues) {
    return new CandleData(xValues);
}
项目:xs-android-architecture    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:xs-android-architecture    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目:xs-android-architecture    文件: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));
        }

        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(set1);

        mChart.setData(data);
        mChart.invalidate();
    }
项目:LETO-Toggl_Android    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:LETO-Toggl_Android    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目:QuShuChe    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}
项目:QuShuChe    文件:CombinedChart.java   
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
项目:MPAndroidChart    文件:CandleStickChart.java   
@Override
public CandleData getCandleData() {
    return mData;
}