Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setHighLightColor()

The following examples show how to use com.github.mikephil.charting.data.LineDataSet#setHighLightColor() . 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: TickChart.java    From android-kline with Apache License 2.0 7 votes vote down vote up
private ILineDataSet createSet(int type) {
        LineDataSet set = new LineDataSet(null, String.valueOf(type));
//        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        if (type == TYPE_FULL) {
            set.setHighLightColor(mLineColor);
            set.setDrawHighlightIndicators(true);
//            set.setDrawVerticalHighlightIndicator(false);
            set.setHighlightLineWidth(0.5f);
            set.setCircleColor(mLineColor);
            set.setCircleRadius(1.5f);
            set.setDrawCircleHole(false);
            set.setDrawFilled(true);
            set.setColor(mLineColor);
            set.setLineWidth(1f);
            set.setFillDrawable(new ColorDrawable(transparentColor));
        } else if (type == TYPE_AVE) {
            set.setHighlightEnabled(true);
            set.setColor(ContextCompat.getColor(mContext, R.color.ave_color));
            set.setLineWidth(1f);
            set.setCircleRadius(1.5f);
            set.setDrawCircleHole(false);
            set.setCircleColor(transparentColor);
            set.setLineWidth(0.5f);
        } else {
            set.setHighlightEnabled(true);
            set.setDrawVerticalHighlightIndicator(false);
            set.setHighLightColor(transparentColor);
            set.setColor(mLineColor);
            set.enableDashedLine(3, 40, 0);
            set.setDrawCircleHole(false);
            set.setCircleColor(transparentColor);
            set.setLineWidth(1f);
            set.setVisible(true);
        }
        set.setDrawCircles(false);
        set.setDrawValues(false);
        return set;
    }
 
Example 2
Source File: CurrentDayFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * date: 6/1/18
 * author: chenli
 * description: 初始化时产生分时图数据集
 */
private LineDataSet generateLineDataSet(List<Entry> entries, int color, String label, boolean isHighlight, YAxis.AxisDependency axisDependency) {
    LineDataSet set = new LineDataSet(entries, label);
    set.setColor(color);
    set.setLineWidth(0.7f);
    set.setDrawCircles(false);
    set.setDrawCircleHole(false);
    set.setDrawValues(false);
    set.setAxisDependency(axisDependency);
    if (isHighlight) {
        refreshYAxisRange(set);
        set.setHighlightLineWidth(0.7f);
        set.setHighLightColor(mHighlightColor);
    } else {
        set.setHighlightEnabled(false);
    }
    return set;
}
 
Example 3
Source File: FragmentPrice.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
private LineData getData(ArrayList<Entry> yVals) {
    LineDataSet set1 = new LineDataSet(yVals, "");
    set1.setLineWidth(1.45f);
    set1.setColor(Color.argb(240, 255, 255, 255));
    set1.setCircleColor(Color.WHITE);
    set1.setHighLightColor(Color.WHITE);
    set1.setFillColor(getResources().getColor(R.color.chartFilled));
    set1.setDrawCircles(false);
    set1.setDrawValues(false);
    set1.setDrawFilled(true);
    set1.setFillFormatter(new IFillFormatter() {
        @Override
        public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
            return priceChart.getAxisLeft().getAxisMinimum();
        }
    });

    LineData data = new LineData(set1);
    return data;
}
 
Example 4
Source File: GraphFragment.java    From CryptoBuddy with GNU Affero General Public License v3.0 6 votes vote down vote up
public LineDataSet setUpLineDataSet(List<Entry> entries) {
    LineDataSet dataSet = new LineDataSet(entries, "Price");
    dataSet.setColor(chartBorderColor);
    dataSet.setFillColor(chartFillColor);
    dataSet.setDrawHighlightIndicators(true);
    dataSet.setDrawFilled(true);
    dataSet.setDrawCircles(true);
    dataSet.setCircleColor(chartBorderColor);
    dataSet.setDrawCircleHole(false);
    dataSet.setDrawValues(false);
    dataSet.setCircleRadius(1);
    dataSet.setHighlightLineWidth(2);
    dataSet.setHighlightEnabled(true);
    dataSet.setDrawHighlightIndicators(true);
    dataSet.setHighLightColor(chartBorderColor); // color for highlight indicator
    return dataSet;
}
 
Example 5
Source File: FragmentPrice.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 6 votes vote down vote up
private LineData getData(ArrayList<Entry> yVals) {
    LineDataSet set1 = new LineDataSet(yVals, "");
    set1.setLineWidth(1.45f);
    set1.setColor(Color.argb(240, 255, 255, 255));
    set1.setCircleColor(Color.WHITE);
    set1.setHighLightColor(Color.WHITE);
    set1.setFillColor(getResources().getColor(R.color.chartFilled));
    set1.setDrawCircles(false);
    set1.setDrawValues(false);
    set1.setDrawFilled(true);
    set1.setFillFormatter(new IFillFormatter() {
        @Override
        public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
            return priceChart.getAxisLeft().getAxisMinimum();
        }
    });

    LineData data = new LineData(set1);
    return data;
}
 
Example 6
Source File: RealtimeLineChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
 
Example 7
Source File: LineChartActivityColored.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private LineData getData(int count, float range) {

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

        for (int i = 0; i < count; i++) {
            float val = (float) (Math.random() * range) + 3;
            values.add(new Entry(i, val));
        }

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(values, "DataSet 1");
        // set1.setFillAlpha(110);
        // set1.setFillColor(Color.RED);

        set1.setLineWidth(1.75f);
        set1.setCircleRadius(5f);
        set1.setCircleHoleRadius(2.5f);
        set1.setColor(Color.WHITE);
        set1.setCircleColor(Color.WHITE);
        set1.setHighLightColor(Color.WHITE);
        set1.setDrawValues(false);

        // create a data object with the data sets
        return new LineData(set1);
    }
 
Example 8
Source File: RealtimeLineChartActivity.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "Dynamic Data");
        set.setAxisDependency(AxisDependency.LEFT);
        set.setColor(ColorTemplate.getHoloBlue());
        set.setCircleColor(Color.WHITE);
        set.setLineWidth(2f);
        set.setCircleRadius(4f);
        set.setFillAlpha(65);
        set.setFillColor(ColorTemplate.getHoloBlue());
        set.setHighLightColor(Color.rgb(244, 117, 117));
        set.setValueTextColor(Color.WHITE);
        set.setValueTextSize(9f);
        set.setDrawValues(false);
        return set;
    }
 
Example 9
Source File: LineChartHelper.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
public ILineDataSet generateLineDataSet(List<Entry> yEntrys, int color, String label) {
        LineDataSet dataSet = new LineDataSet(yEntrys, label);
        dataSet.setLineWidth(2.0f);
        dataSet.setCircleRadius(3.5f);
        dataSet.setDrawCircleHole(true);//填充圆
//        dataSet.setDrawValues(true);
//        dataSet.setValueTextColor(color);
        dataSet.setValueTextSize(9f);
        dataSet.setHighlightLineWidth(2.0f);
//        dataSet.setDrawFilled(true);//区域颜色
        dataSet.setFillAlpha(51);
//        dataSet.setFillColor(color); //填充色
        dataSet.setHighLightColor(color); //选中十字线色
        dataSet.setColor(color); //线条颜色
        dataSet.setCircleColor(color); //圆点颜色
        dataSet.setCircleColorHole(Color.WHITE);
        dataSet.setCircleHoleRadius(2.0f);
        dataSet.setDrawValues(false);
        return dataSet;
    }
 
Example 10
Source File: ListViewMultiChartActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private LineData generateDataLine(int cnt) {

    ArrayList<Entry> e1 = new ArrayList<Entry>();

    for (int i = 0; i < 12; i++) {
        e1.add(new Entry((int) (Math.random() * 65) + 40, i));
    }

    LineDataSet d1 = new LineDataSet(e1, "New DataSet " + cnt + ", (1)");
    d1.setLineWidth(2.5f);
    d1.setCircleRadius(4.5f);
    d1.setHighLightColor(Color.rgb(244, 117, 117));
    d1.setDrawValues(false);
    
    ArrayList<Entry> e2 = new ArrayList<Entry>();

    for (int i = 0; i < 12; i++) {
        e2.add(new Entry(e1.get(i).getVal() - 30, i));
    }

    LineDataSet d2 = new LineDataSet(e2, "New DataSet " + cnt + ", (2)");
    d2.setLineWidth(2.5f);
    d2.setCircleRadius(4.5f);
    d2.setHighLightColor(Color.rgb(244, 117, 117));
    d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    d2.setDrawValues(false);
    
    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
    sets.add(d1);
    sets.add(d2);
    
    LineData cd = new LineData(getMonths(), sets);
    return cd;
}
 
Example 11
Source File: ModelDetailActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
private boolean setUpChart(@NonNull Model model) {
    final double[] accuracies = model.getAccuracies();

    if (accuracies == null
            || accuracies.length == 0
            || model.getStepEpoch() < 1) {
        return false;
    }

    mAccuracyData.clear();

    for (int i = 0, len = model.getStepEpoch(); i < len; ++i) {
        mAccuracyData.add(new Entry(i + 1, (float) accuracies[i]));
    }

    final LineDataSet set = new LineDataSet(mAccuracyData, getString(R.string.text_chart_left_axis));

    set.setMode(LineDataSet.Mode.LINEAR);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setColor(ContextCompat.getColor(this, R.color.chart_left_axis));
    set.setCircleColor(ContextCompat.getColor(this, R.color.chart_left_axis));
    set.setHighLightColor(ContextCompat.getColor(this, R.color.chart_highlight));
    set.setCircleColorHole(Color.WHITE);
    set.setDrawCircleHole(true);
    set.setHighlightEnabled(true);
    set.setLineWidth(2F);
    set.setCircleRadius(3F);
    set.setDrawFilled(false);

    final LineData group = new LineData(set);
    group.setDrawValues(false);

    setXAxis(model.getEpochs());

    mChart.setData(group);
    mChart.invalidate();
    startChartAnimate();

    return true;
}
 
Example 12
Source File: RideDetailActivity.java    From android-ponewheel with MIT License 5 votes vote down vote up
private void setupDatasetWithDefaultValues(LineDataSet dataSet) {
    dataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    dataSet.setColor(ColorTemplate.getHoloBlue());
    dataSet.setValueTextColor(ColorTemplate.getHoloBlue());
    dataSet.setLineWidth(1.5f);
    dataSet.setDrawCircles(false);
    dataSet.setDrawValues(false);
    dataSet.setFillAlpha(65);
    dataSet.setFillColor(ColorTemplate.getHoloBlue());
    dataSet.setHighLightColor(Color.rgb(244, 117, 117));
    dataSet.setDrawCircleHole(false);
}
 
Example 13
Source File: ListViewMultiChartActivity.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 *
 * @return Line data
 */
private LineData generateDataLine(int cnt) {

    ArrayList<Entry> values1 = new ArrayList<>();

    for (int i = 0; i < 12; i++) {
        values1.add(new Entry(i, (int) (Math.random() * 65) + 40));
    }

    LineDataSet d1 = new LineDataSet(values1, "New DataSet " + cnt + ", (1)");
    d1.setLineWidth(2.5f);
    d1.setCircleRadius(4.5f);
    d1.setHighLightColor(Color.rgb(244, 117, 117));
    d1.setDrawValues(false);

    ArrayList<Entry> values2 = new ArrayList<>();

    for (int i = 0; i < 12; i++) {
        values2.add(new Entry(i, values1.get(i).getY() - 30));
    }

    LineDataSet d2 = new LineDataSet(values2, "New DataSet " + cnt + ", (2)");
    d2.setLineWidth(2.5f);
    d2.setCircleRadius(4.5f);
    d2.setHighLightColor(Color.rgb(244, 117, 117));
    d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    d2.setDrawValues(false);

    ArrayList<ILineDataSet> sets = new ArrayList<>();
    sets.add(d1);
    sets.add(d2);

    return new LineData(sets);
}
 
Example 14
Source File: DynamicalAddingActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "DataSet 1");
        set.setLineWidth(2.5f);
        set.setCircleRadius(4.5f);
        set.setColor(Color.rgb(240, 99, 99));
        set.setCircleColor(Color.rgb(240, 99, 99));
        set.setHighLightColor(Color.rgb(190, 190, 190));
        set.setAxisDependency(AxisDependency.LEFT);
        set.setValueTextSize(10f);

        return set;
    }
 
Example 15
Source File: DynamicalAddingActivity.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
private LineDataSet createSet() {

        LineDataSet set = new LineDataSet(null, "DataSet 1");
        set.setLineWidth(2.5f);
        set.setCircleRadius(4.5f);
        set.setColor(Color.rgb(240, 99, 99));
        set.setCircleColor(Color.rgb(240, 99, 99));
        set.setHighLightColor(Color.rgb(190, 190, 190));
        set.setAxisDependency(AxisDependency.LEFT);
        set.setValueTextSize(10f);

        return set;
    }
 
Example 16
Source File: DynamicalAddingActivity.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
private void addDataSet() {

        LineData data = chart.getData();

        if (data == null) {
            chart.setData(new LineData());
        } else {
            int count = (data.getDataSetCount() + 1);
            int amount = data.getDataSetByIndex(0).getEntryCount();

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

            for (int i = 0; i < amount; i++) {
                values.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count));
            }

            LineDataSet set = new LineDataSet(values, "DataSet " + count);
            set.setLineWidth(2.5f);
            set.setCircleRadius(4.5f);

            int color = colors[count % colors.length];

            set.setColor(color);
            set.setCircleColor(color);
            set.setHighLightColor(color);
            set.setValueTextSize(10f);
            set.setValueTextColor(color);

            data.addDataSet(set);
            data.notifyDataChanged();
            chart.notifyDataSetChanged();
            chart.invalidate();
        }
    }
 
Example 17
Source File: StatisticActivity.java    From memorize with MIT License 5 votes vote down vote up
private LineData generateDataLine(int cnt) {

        ArrayList<Entry> values1 = new ArrayList<>();

        for (int i = 0; i < 12; i++) {
            values1.add(new Entry(i, (int) (Math.random() * 65) + 40));
        }

        LineDataSet d1 = new LineDataSet(values1, "New DataSet " + cnt + ", (1)");
        d1.setLineWidth(2.5f);
        d1.setCircleRadius(4.5f);
        d1.setHighLightColor(Color.rgb(244, 117, 117));
        d1.setDrawValues(false);

        ArrayList<Entry> values2 = new ArrayList<>();

        for (int i = 0; i < 12; i++) {
            values2.add(new Entry(i, values1.get(i).getY() - 30));
        }

        LineDataSet d2 = new LineDataSet(values2, "New DataSet " + cnt + ", (2)");
        d2.setLineWidth(2.5f);
        d2.setCircleRadius(4.5f);
        d2.setHighLightColor(Color.rgb(244, 117, 117));
        d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        d2.setDrawValues(false);

        ArrayList<ILineDataSet> sets = new ArrayList<>();
        sets.add(d1);
        sets.add(d2);

        return new LineData(sets);
    }
 
Example 18
Source File: DynamicalAddingActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
private void addDataSet() {

        LineData data = mChart.getData();
        
        if(data != null) {

            int count = (data.getDataSetCount() + 1);

            // create 10 y-vals
            ArrayList<Entry> yVals = new ArrayList<Entry>();
            
            if(data.getXValCount() == 0) {
                // add 10 x-entries
                for (int i = 0; i < 10; i++) {
                    data.addXValue("" + (i+1));
                }
            }

            for (int i = 0; i < data.getXValCount(); i++) {
                yVals.add(new Entry((float) (Math.random() * 50f) + 50f * count, i));
            }

            LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
            set.setLineWidth(2.5f);
            set.setCircleRadius(4.5f);

            int color = mColors[count % mColors.length];

            set.setColor(color);
            set.setCircleColor(color);
            set.setHighLightColor(color);
            set.setValueTextSize(10f);
            set.setValueTextColor(color);

            data.addDataSet(set);
            mChart.notifyDataSetChanged();
            mChart.invalidate();   
        }
    }
 
Example 19
Source File: ChartUtil.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 曲线赋值与设置
 *
 * @param context   上下文
 * @param yDataList y轴数据
 * @return LineData
 */
private static LineData setLineData(Context context, List<Entry> yDataList,
                                    String curveLable) {
    // y轴的数据集合
    LineDataSet lineDataSet = new LineDataSet(yDataList, curveLable);
    // 用y轴的集合来设置参数
    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    // 不显示坐标点的数据
    lineDataSet.setDrawValues(false);
    // 显示坐标点的小圆点
    lineDataSet.setDrawCircles(false);
    // 定位线
    lineDataSet.setHighlightEnabled(false);
    // 线宽
    lineDataSet.setLineWidth(1f);
    // 显示的圆形大小
    lineDataSet.setCircleSize(2f);
    // 显示颜色
    lineDataSet.setColor(context.getApplicationContext().getResources().getColor(R.color.chart_color));
    // 圆形的颜色
    lineDataSet.setCircleColor(context.getApplicationContext().getResources().getColor(R.color.chart_color));
    // 高亮的线的颜色
    lineDataSet.setHighLightColor(context.getApplicationContext().getResources()
            .getColor(R.color.chart_color));
    // 设置填充的颜色

    Drawable drawable = ContextCompat.getDrawable(context, R.drawable.fade_color);
    lineDataSet.setFillDrawable(drawable);

    // 设置坐标点为空心环状
    lineDataSet.setDrawCircleHole(false);
    // lineDataSet.setValueTextSize(9f);
    lineDataSet.setFillAlpha(30);
    // 设置显示曲线和X轴围成的区域阴影
    lineDataSet.setDrawFilled(true);
    // 坐标轴在左侧
    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    // 设置每条曲线图例标签名
    // lineDataSet.setLabel("标签");
    lineDataSet.setValueTextSize(14f);
    // 曲线弧度(区间0.05f-1f,默认0.2f)
    lineDataSet.setCubicIntensity(0.2f);
    // 设置为曲线显示,false为折线
    lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    lineDataSet.setValues(yDataList);
    // y轴的数据
    LineData lineData = new LineData(lineDataSet);
    return lineData;
}
 
Example 20
Source File: CubicLineChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
private void setData(int count, float range) {

        ArrayList<String> xVals = new ArrayList<String>();
        for (int i = 0; i < count; i++) {
            xVals.add((1990 +i) + "");
        }

        ArrayList<Entry> vals1 = new ArrayList<Entry>();

        for (int i = 0; i < count; i++) {
            float mult = (range + 1);
            float val = (float) (Math.random() * mult) + 20;// + (float)
                                                           // ((mult *
                                                           // 0.1) / 10);
            vals1.add(new Entry(val, i));
        }
        
        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(vals1, "DataSet 1");
        set1.setDrawCubic(true);
        set1.setCubicIntensity(0.2f);
        //set1.setDrawFilled(true);
        set1.setDrawCircles(false); 
        set1.setLineWidth(1.8f);
        set1.setCircleRadius(4f);
        set1.setCircleColor(Color.WHITE);
        set1.setHighLightColor(Color.rgb(244, 117, 117));
        set1.setColor(Color.WHITE);
        set1.setFillColor(Color.WHITE);
        set1.setFillAlpha(100);
        set1.setDrawHorizontalHighlightIndicator(false);
        set1.setFillFormatter(new FillFormatter() {
            @Override
            public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
                return -10;
            }
        });
        
        // create a data object with the datasets
        LineData data = new LineData(xVals, set1);
        data.setValueTypeface(tf);
        data.setValueTextSize(9f);
        data.setDrawValues(false);

        // set data
        mChart.setData(data);
    }