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

The following examples show how to use com.github.mikephil.charting.data.CandleDataSet#setShadowColor() . 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: 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 2
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 3
Source File: CandleStickChartManager.java    From react-native-mp-android-chart with MIT License 5 votes vote down vote up
@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()));
    }
}
 
Example 4
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 5
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();
    }