Java Code Examples for com.github.mikephil.charting.data.CandleDataSet#setAxisDependency()

The following examples show how to use com.github.mikephil.charting.data.CandleDataSet#setAxisDependency() . 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: KLineDataManage.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private CandleDataSet setACandle(ArrayList<CandleEntry> candleEntries) {
    CandleDataSet candleDataSet = new CandleDataSet(candleEntries, "蜡烛线");
    candleDataSet.setDrawHorizontalHighlightIndicator(true);
    candleDataSet.setHighlightEnabled(true);
    candleDataSet.setHighLightColor(ContextCompat.getColor(mContext, R.color.highLight_Color));
    candleDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    candleDataSet.setDecreasingColor(ContextCompat.getColor(mContext, R.color.down_color));
    candleDataSet.setDecreasingPaintStyle(Paint.Style.FILL);
    candleDataSet.setIncreasingColor(ContextCompat.getColor(mContext, R.color.up_color));
    candleDataSet.setIncreasingPaintStyle(Paint.Style.FILL);
    candleDataSet.setNeutralColor(ContextCompat.getColor(mContext, R.color.equal_color));
    candleDataSet.setShadowColorSameAsCandle(true);
    candleDataSet.setValueTextSize(10);
    candleDataSet.setDrawValues(true);

    return candleDataSet;
}
 
Example 3
Source File: KLineDataManage.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private CandleDataSet setBOLLCandle(ArrayList<CandleEntry> candleEntries) {
    CandleDataSet candleDataSet = new CandleDataSet(candleEntries, "BOLL叠加蜡烛线");
    candleDataSet.setDrawHorizontalHighlightIndicator(false);
    candleDataSet.setHighlightEnabled(true);
    candleDataSet.setHighLightColor(ContextCompat.getColor(mContext, R.color.highLight_Color));
    candleDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    candleDataSet.setDecreasingColor(ContextCompat.getColor(mContext, R.color.down_color));
    candleDataSet.setDecreasingPaintStyle(Paint.Style.FILL);
    candleDataSet.setIncreasingColor(ContextCompat.getColor(mContext, R.color.up_color));
    candleDataSet.setIncreasingPaintStyle(Paint.Style.FILL);
    candleDataSet.setNeutralColor(ContextCompat.getColor(mContext, R.color.equal_color));
    candleDataSet.setDrawValues(false);
    candleDataSet.setDrawIcons(false);
    candleDataSet.setShowCandleBar(false);
    return candleDataSet;
}
 
Example 4
Source File: KLineView.java    From android-kline with Apache License 2.0 6 votes vote down vote up
@android.support.annotation.NonNull
public CandleDataSet setKLine(int type, ArrayList<CandleEntry> lineEntries) {
    CandleDataSet set = new CandleDataSet(lineEntries, "KLine" + type);
    set.setDrawIcons(false);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setShadowColor(Color.DKGRAY);
    set.setShadowWidth(0.75f);
    set.setDecreasingColor(mDecreasingColor);
    set.setDecreasingPaintStyle(Paint.Style.FILL);
    set.setShadowColorSameAsCandle(true);
    set.setIncreasingColor(mIncreasingColor);
    set.setIncreasingPaintStyle(Paint.Style.FILL);
    set.setNeutralColor(ContextCompat.getColor(getContext(), R.color.increasing_color));
    set.setDrawValues(true);
    set.setValueTextSize(10);
    set.setHighlightEnabled(true);
    if (type != NORMAL_LINE) {
        set.setVisible(false);
    }
    return set;
}
 
Example 5
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 6
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();
    }