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

The following examples show how to use com.github.mikephil.charting.data.CandleDataSet#setIncreasingPaintStyle() . 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: 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 6
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 7
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();
    }