com.github.mikephil.charting.data.CandleData Java Examples

The following examples show how to use com.github.mikephil.charting.data.CandleData. 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: KlineFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * date: 7/9/17
 * author: chenli
 * description: 生成蜡烛图数据
 */
private CandleData generateCandleData(List<CandleEntry> candleEntries) {
    CandleDataSet set = new CandleDataSet(candleEntries, "");
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setShadowWidth(0.7f);
    set.setDecreasingColor(mDecreasingColor);
    set.setDecreasingPaintStyle(Paint.Style.FILL);
    set.setIncreasingColor(mIncreasingColor);
    set.setIncreasingPaintStyle(Paint.Style.STROKE);
    set.setNeutralColor(mHighlightColor);
    set.setShadowColorSameAsCandle(true);
    set.setHighlightLineWidth(0.7f);
    set.setHighLightColor(mHighlightColor);
    set.setDrawValues(true);
    set.setValueTextColor(Color.RED);
    set.setValueTextSize(9f);
    set.setDrawIcons(false);
    set.setValueFormatter(new TopChartLeftYAxisValueFormatter());
    CandleData candleData = new CandleData();
    candleData.addDataSet(set);
    return candleData;
}
 
Example #2
Source File: CombinedChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
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;
    }
 
Example #3
Source File: CombinedChartActivity.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private CandleData generateCandleData() {

        CandleData d = new CandleData();

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

        for (int index = 0; index < count; 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;
    }
 
Example #4
Source File: KLineChart.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * 动态更新最后一点数据 最新数据集
 *
 * @param kLineData
 */
public void dynamicsUpdateOne(KLineDataManage kLineData) {
    int size = kLineData.getKLineDatas().size();
    int i = size - 1;
    CombinedData candleChartData = candleChart.getData();
    CandleData candleData = candleChartData.getCandleData();
    ICandleDataSet candleDataSet = candleData.getDataSetByIndex(0);
    candleDataSet.removeEntry(i);

    candleDataSet.addEntry(new CandleEntry(i + kLineData.getOffSet(), (float) kLineData.getKLineDatas().get(i).getHigh(), (float) kLineData.getKLineDatas().get(i).getLow(), (float) kLineData.getKLineDatas().get(i).getOpen(), (float) kLineData.getKLineDatas().get(i).getClose()));
    if (chartType1 == 1) {//副图是成交量
        CombinedData barChartData = barChart.getData();
        IBarDataSet barDataSet = barChartData.getBarData().getDataSetByIndex(0);
        barDataSet.removeEntry(i);
        float color = kLineData.getKLineDatas().get(i).getOpen() == kLineData.getKLineDatas().get(i).getClose()?0f:kLineData.getKLineDatas().get(i).getOpen() > kLineData.getKLineDatas().get(i).getClose() ? -1f : 1f;
        BarEntry barEntry = new BarEntry(i + kLineData.getOffSet(), (float) kLineData.getKLineDatas().get(i).getVolume(), color);
        barDataSet.addEntry(barEntry);
    } else {//副图是其他技术指标
        doBarChartSwitch(chartType1);
    }

    candleChart.notifyDataSetChanged();
    barChart.notifyDataSetChanged();
    candleChart.invalidate();
    barChart.invalidate();
}
 
Example #5
Source File: CandleStickChartRenderer.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible()) {
            drawDataSet(c, set);
        }
    }
}
 
Example #6
Source File: CandleStickChartRenderer.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
 
Example #7
Source File: KLineChart.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * 副图指标BOLL
 */
public void setBOLLToChart() {
    if (barChart != null) {
        if (barChart.getBarData() != null) {
            barChart.getBarData().clearValues();
        }
        if (barChart.getLineData() != null) {
            barChart.getLineData().clearValues();
        }
        if (barChart.getCandleData() != null) {
            barChart.getCandleData().clearValues();
        }

        axisLeftBar.resetAxisMaximum();
        axisLeftBar.resetAxisMinimum();
        axisLeftBar.setValueFormatter(new ValueFormatter() {
            @Override
            public String getAxisLabel(float value, AxisBase axis) {
                return NumberUtils.keepPrecision(value, precision);
            }
        });

        CombinedData combinedData = barChart.getData();
        combinedData.setData(new CandleData(kLineData.getBollCandleDataSet()));
        combinedData.setData(new LineData(kLineData.getLineDataBOLL()));
        barChart.notifyDataSetChanged();
        barChart.invalidate();
    }
}
 
Example #8
Source File: KLineChart.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * 动态增加一个点数据
 *
 * @param kLineData 最新数据集
 */
public void dynamicsAddOne(KLineDataManage kLineData) {
    int size = kLineData.getKLineDatas().size();
    CombinedData candleChartData = candleChart.getData();
    CandleData candleData = candleChartData.getCandleData();
    ICandleDataSet candleDataSet = candleData.getDataSetByIndex(0);
    int i = size - 1;
    candleDataSet.addEntry(new CandleEntry(i + kLineData.getOffSet(), (float) kLineData.getKLineDatas().get(i).getHigh(), (float) kLineData.getKLineDatas().get(i).getLow(), (float) kLineData.getKLineDatas().get(i).getOpen(), (float) kLineData.getKLineDatas().get(i).getClose()));
    kLineData.getxVals().add(DataTimeUtil.secToDate(kLineData.getKLineDatas().get(i).getDateMills()));
    candleChart.getXAxis().setAxisMaximum(kLineData.getKLineDatas().size() < 70 ? 70 : candleChartData.getXMax() + kLineData.getOffSet());

    if (chartType1 == 1) {//副图是成交量
        CombinedData barChartData = barChart.getData();
        IBarDataSet barDataSet = barChartData.getBarData().getDataSetByIndex(0);
        if (barDataSet == null) {//当没有数据时
            return;
        }
        float color = kLineData.getKLineDatas().get(i).getOpen() == kLineData.getKLineDatas().get(i).getClose()?0f:kLineData.getKLineDatas().get(i).getOpen() > kLineData.getKLineDatas().get(i).getClose() ? -1f : 1f;
        BarEntry barEntry = new BarEntry(i + kLineData.getOffSet(), (float) kLineData.getKLineDatas().get(i).getVolume(), color);

        barDataSet.addEntry(barEntry);
        barChart.getXAxis().setAxisMaximum(kLineData.getKLineDatas().size() < 70 ? 70 : barChartData.getXMax() + kLineData.getOffSet());
    } else {//副图是其他技术指标
        doBarChartSwitch(chartType1);
    }

    candleChart.notifyDataSetChanged();
    barChart.notifyDataSetChanged();
    if (kLineData.getKLineDatas().size() > 70) {
        //moveViewTo(...) 方法会自动调用 invalidate()
        candleChart.moveViewToX(kLineData.getKLineDatas().size() - 1);
        barChart.moveViewToX(kLineData.getKLineDatas().size() - 1);
    } else {
        candleChart.invalidate();
        barChart.invalidate();
    }
}
 
Example #9
Source File: CombinedChart.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
@Override
public CandleData getCandleData() {
    if (mData == null) {
        return null;
    }
    return mData.getCandleData();
}
 
Example #10
Source File: MyCandleStickChartRenderer.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    CandleData candleData = mChart.getCandleData();

    for (Highlight high : indices) {

        ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex());

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

        CandleEntry e = set.getEntryForXValue(high.getX(), high.getY());

        if (!isInBoundsX(e, set))
            continue;


        float lowValue = e.getLow() * mAnimator.getPhaseY();
        float highValue = e.getHigh() * mAnimator.getPhaseY();
        MPPointD pix = mChart.getTransformer(set.getAxisDependency())
                .getPixelForValues(e.getX(), (lowValue + highValue) / 2f);
        float xp = (float) pix.x;

        mHighlightPaint.setColor(set.getHighLightColor());
        mHighlightPaint.setStrokeWidth(set.getHighlightLineWidth());

        float xMax = mViewPortHandler.contentRight();
        float contentBottom = mViewPortHandler.contentBottom();
        //绘制竖线
        c.drawLine(xp, 1, xp, mChart.getHeight(), mHighlightPaint);

        //判断是否画横线
        float y = high.getDrawY();
        if (y >= 0 && y <= contentBottom) {//在区域内即绘制横线
            //绘制横线
            c.drawLine(0, y, xMax, y, mHighlightPaint);
        }
    }
}
 
Example #11
Source File: CandleStickChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
 
Example #12
Source File: CandleStickChartRenderer.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #13
Source File: CandleStickChartRenderer.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
 
Example #14
Source File: CandleStickChartRenderer.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
 
Example #15
Source File: CandleStickChartRenderer.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
 
Example #16
Source File: CandleStickChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    CandleData candleData = mChart.getCandleData();

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

        if (set.isVisible())
            drawDataSet(c, set);
    }
}
 
Example #17
Source File: CandleStickChartManager.java    From react-native-mp-android-chart with MIT License 4 votes vote down vote up
@Override
ChartData createData(String[] xValues) {
    return new CandleData(xValues);
}
 
Example #18
Source File: CombinedChart.java    From iMoney with Apache License 2.0 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
 
Example #19
Source File: CandleStickChart.java    From iMoney with Apache License 2.0 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    return mData;
}
 
Example #20
Source File: CandleStickChart.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    return mData;
}
 
Example #21
Source File: CombinedChart.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
 
Example #22
Source File: CandleStickChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@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();
    }
 
Example #23
Source File: CandleStickChart.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    return mData;
}
 
Example #24
Source File: CombinedChart.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}
 
Example #25
Source File: CandleStickChartRenderer.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@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);
        }
    }
}
 
Example #26
Source File: KLineView.java    From android-kline with Apache License 2.0 4 votes vote down vote up
public void addData(HisData hisData) {
    hisData = DataUtils.calculateHisData(hisData, mData);
    CombinedData combinedData = mChartPrice.getData();
    LineData priceData = combinedData.getLineData();
    ILineDataSet ma5Set = priceData.getDataSetByIndex(1);
    ILineDataSet ma10Set = priceData.getDataSetByIndex(2);
    ILineDataSet ma20Set = priceData.getDataSetByIndex(3);
    ILineDataSet ma30Set = priceData.getDataSetByIndex(4);
    CandleData kData = combinedData.getCandleData();
    ICandleDataSet klineSet = kData.getDataSetByIndex(0);
    IBarDataSet volSet = mChartVolume.getData().getBarData().getDataSetByIndex(0);
    IBarDataSet macdSet = mChartMacd.getData().getBarData().getDataSetByIndex(0);
    ILineDataSet difSet = mChartMacd.getData().getLineData().getDataSetByIndex(0);
    ILineDataSet deaSet = mChartMacd.getData().getLineData().getDataSetByIndex(1);
    LineData kdjData = mChartKdj.getData().getLineData();
    ILineDataSet kSet = kdjData.getDataSetByIndex(0);
    ILineDataSet dSet = kdjData.getDataSetByIndex(1);
    ILineDataSet jSet = kdjData.getDataSetByIndex(2);

    if (mData.contains(hisData)) {
        int index = mData.indexOf(hisData);
        klineSet.removeEntry(index);
        // ma比较特殊,entry数量和k线的不一致,移除最后一个
        ma5Set.removeLast();
        ma10Set.removeLast();
        ma20Set.removeLast();
        ma30Set.removeLast();
        volSet.removeEntry(index);
        macdSet.removeEntry(index);
        difSet.removeEntry(index);
        deaSet.removeEntry(index);
        kSet.removeEntry(index);
        dSet.removeEntry(index);
        jSet.removeEntry(index);
        mData.remove(index);
    }
    mData.add(hisData);
    int klineCount = klineSet.getEntryCount();
    klineSet.addEntry(new CandleEntry(klineCount, (float) hisData.getHigh(), (float) hisData.getLow(), (float) hisData.getOpen(), (float) hisData.getClose()));
    volSet.addEntry(new BarEntry(volSet.getEntryCount(), hisData.getVol(), hisData));

    macdSet.addEntry(new BarEntry(macdSet.getEntryCount(), (float) hisData.getMacd()));
    difSet.addEntry(new Entry(difSet.getEntryCount(), (float) hisData.getDif()));
    deaSet.addEntry(new Entry(deaSet.getEntryCount(), (float) hisData.getDea()));

    kSet.addEntry(new Entry(kSet.getEntryCount(), (float) hisData.getK()));
    dSet.addEntry(new Entry(dSet.getEntryCount(), (float) hisData.getD()));
    jSet.addEntry(new Entry(jSet.getEntryCount(), (float) hisData.getJ()));

    // 因为ma的数量会少,所以这里用kline的set数量作为x
    if (!Double.isNaN(hisData.getMa5())) {
        ma5Set.addEntry(new Entry(klineCount, (float) hisData.getMa5()));
    }
    if (!Double.isNaN(hisData.getMa10())) {
        ma10Set.addEntry(new Entry(klineCount, (float) hisData.getMa10()));
    }
    if (!Double.isNaN(hisData.getMa20())) {
        ma20Set.addEntry(new Entry(klineCount, (float) hisData.getMa20()));
    }
    if (!Double.isNaN(hisData.getMa30())) {
        ma30Set.addEntry(new Entry(klineCount, (float) hisData.getMa30()));
    }


    mChartPrice.getXAxis().setAxisMaximum(combinedData.getXMax() + 1.5f);
    mChartVolume.getXAxis().setAxisMaximum(mChartVolume.getData().getXMax() + 1.5f);
    mChartMacd.getXAxis().setAxisMaximum(mChartMacd.getData().getXMax() + 1.5f);
    mChartKdj.getXAxis().setAxisMaximum(mChartKdj.getData().getXMax() + 1.5f);


    mChartPrice.setVisibleXRange(MAX_COUNT, MIN_COUNT);
    mChartVolume.setVisibleXRange(MAX_COUNT, MIN_COUNT);
    mChartMacd.setVisibleXRange(MAX_COUNT, MIN_COUNT);
    mChartKdj.setVisibleXRange(MAX_COUNT, MIN_COUNT);

    mChartPrice.notifyDataSetChanged();
    mChartPrice.invalidate();
    mChartVolume.notifyDataSetChanged();
    mChartVolume.invalidate();
    mChartMacd.notifyDataSetChanged();
    mChartMacd.invalidate();
    mChartKdj.notifyDataSetChanged();
    mChartKdj.invalidate();


    setDescription(mChartPrice, String.format(Locale.getDefault(), "MA5:%.2f  MA10:%.2f  MA20:%.2f  MA30:%.2f",
            hisData.getMa5(), hisData.getMa10(), hisData.getMa20(), hisData.getMa30()));
    setDescription(mChartVolume, "成交量 " + hisData.getVol());
    setDescription(mChartMacd, String.format(Locale.getDefault(), "MACD:%.2f  DEA:%.2f  DIF:%.2f",
            hisData.getMacd(), hisData.getDea(), hisData.getDif()));
    setDescription(mChartKdj, String.format(Locale.getDefault(), "K:%.2f  D:%.2f  J:%.2f",
            hisData.getK(), hisData.getD(), hisData.getJ()));

}
 
Example #27
Source File: CandleStickChart.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    return mData;
}
 
Example #28
Source File: CandleStickChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

        progress = (seekBarX.getProgress());

        tvX.setText(String.valueOf(progress));
        tvY.setText(String.valueOf(seekBarY.getProgress()));

        chart.resetTracking();

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

        for (int i = 0; i < progress; i++) {
            float multi = (seekBarY.getProgress() + 1);
            float val = (float) (Math.random() * 40) + multi;

            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;

            values.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(values, "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);

        chart.setData(data);
        chart.invalidate();
    }
 
Example #29
Source File: CandleStickChart.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    return mData;
}
 
Example #30
Source File: CombinedChart.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@Override
public CandleData getCandleData() {
    if (mData == null)
        return null;
    return mData.getCandleData();
}