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

The following examples show how to use com.github.mikephil.charting.data.LineDataSet#setDrawCircleHole() . 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: KlineFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
private LineDataSet generateMALineDataSet(int para, int color, String label) {
    List<Entry> entries = new ArrayList<>();
    for (int i = mLeftIndex + para - 1; i <= mLastIndex; i++) {
        Entry entry = generateMALineDataEntry(i, para - 1);
        entries.add(entry);
    }
    LineDataSet set = new LineDataSet(entries, label);
    set.setColor(color);
    set.setLineWidth(0.7f);
    set.setDrawCircles(false);
    set.setDrawCircleHole(false);
    set.setDrawValues(false);
    set.setHighlightEnabled(false);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    return set;
}
 
Example 3
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 4
Source File: TrainedModelViewBinder.java    From Synapse with Apache License 2.0 6 votes vote down vote up
private LineDataSet prepareInitData(@NonNull LineChart chart, @NonNull List<Entry> entries) {
    final LineDataSet set = new LineDataSet(entries, "Accuracy");

    set.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setLineWidth(2F);
    set.setDrawCircleHole(false);
    set.setDrawCircles(false);
    set.setHighlightEnabled(false);
    set.setDrawFilled(true);

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

    chart.setData(group);

    return set;
}
 
Example 5
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 6
Source File: KlineFragment.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * date: 2019/2/22
 * 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) {
        set.setHighlightLineWidth(0.7f);
        set.setHighLightColor(color);
    } else {
        set.setHighlightEnabled(false);
    }
    return set;
}
 
Example 7
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 8
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 9
Source File: TimeLineView.java    From android-kline with Apache License 2.0 5 votes vote down vote up
@android.support.annotation.NonNull
private LineDataSet setLine(int type, ArrayList<Entry> lineEntries) {
    LineDataSet lineDataSetMa = new LineDataSet(lineEntries, "ma" + type);
    lineDataSetMa.setDrawValues(false);
    if (type == NORMAL_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color));
        lineDataSetMa.setCircleColor(ContextCompat.getColor(mContext, R.color.normal_line_color));
    } else if (type == NORMAL_LINE_5DAY) {
        lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color));
        lineDataSetMa.setCircleColor(mTransparentColor);
    } else if (type == AVE_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ave_color));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else {
        lineDataSetMa.setVisible(false);
        lineDataSetMa.setHighlightEnabled(false);
    }
    lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSetMa.setLineWidth(1f);
    lineDataSetMa.setCircleRadius(1f);

    lineDataSetMa.setDrawCircles(false);
    lineDataSetMa.setDrawCircleHole(false);

    return lineDataSetMa;
}
 
Example 10
Source File: LineChartTime.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
private void setData(int count, float range) {

        // now in hours
        long now = TimeUnit.MILLISECONDS.toHours(System.currentTimeMillis());

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

        // count = hours
        float to = now + count;

        // increment by 1 hour
        for (float x = now; x < to; x++) {

            float y = getRandom(range, 50);
            values.add(new Entry(x, y)); // add one entry per hour
        }

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(values, "DataSet 1");
        set1.setAxisDependency(AxisDependency.LEFT);
        set1.setColor(ColorTemplate.getHoloBlue());
        set1.setValueTextColor(ColorTemplate.getHoloBlue());
        set1.setLineWidth(1.5f);
        set1.setDrawCircles(false);
        set1.setDrawValues(false);
        set1.setFillAlpha(65);
        set1.setFillColor(ColorTemplate.getHoloBlue());
        set1.setHighLightColor(Color.rgb(244, 117, 117));
        set1.setDrawCircleHole(false);

        // create a data object with the data sets
        LineData data = new LineData(set1);
        data.setValueTextColor(Color.WHITE);
        data.setValueTextSize(9f);

        // set data
        chart.setData(data);
    }
 
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: ReportAdapter.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
private LineDataSet getNewChartLineDataSet(Context context, String label){
    LineDataSet chartLineDataSet = new LineDataSet(new ArrayList<Entry>(), label);
    chartLineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    chartLineDataSet.setLineWidth(3);
    chartLineDataSet.setCircleRadius(3.5f);
    chartLineDataSet.setDrawCircleHole(false);
    chartLineDataSet.setColor(ContextCompat.getColor(context, R.color.colorPrimary), 200);
    chartLineDataSet.setCircleColor(ContextCompat.getColor(context, R.color.colorPrimary));
    chartLineDataSet.setDrawValues(false);

    return chartLineDataSet;
}
 
Example 13
Source File: TrafficFragment.java    From gito-github-client with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void chartDataSetStyling(LineDataSet dataSet) {
    dataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    dataSet.setColor(SettingsActivity.ThemePreferenceFragment.isLight(getContext()) ?
            getResources().getColor(R.color.traffic_chart_line_color_light) :
            getResources().getColor(R.color.traffic_chart_line_color_dark));
    dataSet.setLineWidth(2f);
    dataSet.setCircleRadius(4f);
    dataSet.setDrawValues(false);
    dataSet.setDrawCircleHole(false);
    dataSet.setCircleColor(SettingsActivity.ThemePreferenceFragment.isLight(getContext()) ?
            getResources().getColor(R.color.traffic_chart_line_color_light) :
            getResources().getColor(R.color.traffic_chart_line_color_dark));
}
 
Example 14
Source File: ChartRVAdapter.java    From batteryhub with Apache License 2.0 5 votes vote down vote up
private LineData loadData(ChartCard card) {
    // add entries to dataset
    LineDataSet lineDataSet = new LineDataSet(card.entries, null);
    lineDataSet.setMode(LineDataSet.Mode.LINEAR);
    lineDataSet.setDrawValues(false);
    lineDataSet.setDrawCircleHole(false);
    lineDataSet.setColor(card.color);
    lineDataSet.setCircleColor(card.color);
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setDrawFilled(true);
    lineDataSet.setFillColor(card.color);

    return new LineData(lineDataSet);
}
 
Example 15
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 16
Source File: KLineView.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@android.support.annotation.NonNull
private LineDataSet setLine(int type, ArrayList<Entry> lineEntries) {
    LineDataSet lineDataSetMa = new LineDataSet(lineEntries, "ma" + type);
    lineDataSetMa.setDrawValues(false);
    if (type == NORMAL_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color));
        lineDataSetMa.setCircleColor(ContextCompat.getColor(mContext, R.color.normal_line_color));
    } else if (type == K) {
        lineDataSetMa.setColor(getResources().getColor(R.color.k));
        lineDataSetMa.setCircleColor(mTransparentColor);
    } else if (type == D) {
        lineDataSetMa.setColor(getResources().getColor(R.color.d));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == J) {
        lineDataSetMa.setColor(getResources().getColor(R.color.j));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == DIF) {
        lineDataSetMa.setColor(getResources().getColor(R.color.dif));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == DEA) {
        lineDataSetMa.setColor(getResources().getColor(R.color.dea));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == AVE_LINE) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ave_color));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA5) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma5));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA10) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma10));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA20) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma20));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else if (type == MA30) {
        lineDataSetMa.setColor(getResources().getColor(R.color.ma30));
        lineDataSetMa.setCircleColor(mTransparentColor);
        lineDataSetMa.setHighlightEnabled(false);
    } else {
        lineDataSetMa.setVisible(false);
        lineDataSetMa.setHighlightEnabled(false);
    }
    lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSetMa.setLineWidth(1f);
    lineDataSetMa.setCircleRadius(1f);

    lineDataSetMa.setDrawCircles(false);
    lineDataSetMa.setDrawCircleHole(false);

    return lineDataSetMa;
}
 
Example 17
Source File: DataPlotFragment.java    From OpenLibre with GNU General Public License v3.0 4 votes vote down vote up
private LineDataSet makeLineData(List<GlucoseData> glucoseDataList) {
    String title = "History";
    if (glucoseDataList.get(0).isTrendData()) title = "Trend";

    LineDataSet lineDataSet = new LineDataSet(new ArrayList<Entry>(), title);
    for (GlucoseData gd : glucoseDataList) {
        float x = convertDateToXAxisValue(gd.getDate());
        float y = gd.glucose();
        lineDataSet.addEntryOrdered(new Entry(x, y));
        /*
        Log.d(LOG_ID, String.format("%s: %s -> %s: %f -> %f",
                title,
                mFormatDateTime.format(new Date(gd.date)),
                mFormatDateTime.format(new Date(convertXAxisValueToDate(x))),
                x,
                y)
        );
        */
    }

    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSet.setDrawCircles(true);
    lineDataSet.setCircleRadius(2f);

    lineDataSet.setDrawCircleHole(false);
    lineDataSet.setDrawValues(false);

    lineDataSet.setDrawHighlightIndicators(true);

    int baseColor = PLOT_COLORS[mPlotColorIndex % NUM_PLOT_COLORS][0];
    int softColor = Color.argb(150, Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor));
    int hardColor = PLOT_COLORS[mPlotColorIndex % NUM_PLOT_COLORS][1];
    if (glucoseDataList.get(0).isTrendData()) {
        lineDataSet.setColor(hardColor);
        lineDataSet.setLineWidth(2f);

        lineDataSet.setCircleColor(softColor);

        lineDataSet.setMode(LineDataSet.Mode.LINEAR);
    } else {
        lineDataSet.setColor(softColor);
        lineDataSet.setLineWidth(4f);

        lineDataSet.setCircleColor(hardColor);

        lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
        lineDataSet.setCubicIntensity(0.1f);
    }

    return lineDataSet;
}
 
Example 18
Source File: LineChartActivity1.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((i) + "");
        }

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

        for (int i = 0; i < count; i++) {

            float mult = (range + 1);
            float val = (float) (Math.random() * mult) + 3;// + (float)
            // ((mult *
            // 0.1) / 10);
            yVals.add(new Entry(val, i));
        }

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

        // set the line to be drawn like this "- - - - - -"
        set1.enableDashedLine(10f, 5f, 0f);
        set1.enableDashedHighlightLine(10f, 5f, 0f);
        set1.setColor(Color.BLACK);
        set1.setCircleColor(Color.BLACK);
        set1.setLineWidth(1f);
        set1.setCircleRadius(3f);
        set1.setDrawCircleHole(false);
        set1.setValueTextSize(9f);
        Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
        set1.setFillDrawable(drawable);
        set1.setDrawFilled(true);

        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        dataSets.add(set1); // add the datasets

        // create a data object with the datasets
        LineData data = new LineData(xVals, dataSets);

        // set data
        mChart.setData(data);
    }
 
Example 19
Source File: CurrencyActivity.java    From Travel-Mate with MIT License 4 votes vote down vote up
void setGraphData(JSONArray currencyRateTrends) {
    ArrayList<Entry> values = new ArrayList<>();

    for (int i = 0; i < currencyRateTrends.length(); i++) {
        try {
            values.add(new Entry(i, (float) currencyRateTrends.getDouble(i)));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    LineDataSet lineDataSet = new LineDataSet(values, GRAPH_LABEL_NAME);
    lineDataSet.setDrawIcons(false);
    lineDataSet.setColor(Color.RED);
    lineDataSet.setCircleColor(Color.BLUE);
    lineDataSet.setCircleRadius(1f);
    lineDataSet.setLineWidth(1f);
    lineDataSet.setCircleRadius(3f);
    lineDataSet.setDrawCircleHole(true);
    lineDataSet.setValueTextSize(10f);
    lineDataSet.setValueTextColor(Color.BLACK);
    lineDataSet.setDrawFilled(true);
    lineDataSet.setFormSize(10.f);
    if (Utils.getSDKInt() >= 18) {
        // fill drawable only supported on api level 18 and above
        Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_green);
        lineDataSet.setFillDrawable(drawable);
    } else {
        lineDataSet.setFillColor(Color.BLACK);
    }

    ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(lineDataSet);

    // create a data object with the datasets
    LineData data = new LineData(dataSets);

    // set data
    graph.setData(data);

}
 
Example 20
Source File: LineChartManager.java    From react-native-mp-android-chart with MIT License 4 votes vote down vote up
@Override
void dataSetConfig(IDataSet<Entry> dataSet, ReadableMap config) {
    LineDataSet lineDataSet = (LineDataSet) dataSet;

    ChartDataSetConfigUtils.commonConfig(lineDataSet, config);
    ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(lineDataSet, config);
    ChartDataSetConfigUtils.commonLineScatterCandleRadarConfig(lineDataSet, config);
    ChartDataSetConfigUtils.commonLineRadarConfig(lineDataSet, config);

    // LineDataSet only config
    if (BridgeUtils.validate(config, ReadableType.Number, "circleRadius")) {
        lineDataSet.setCircleRadius((float) config.getDouble("circleRadius"));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawCircles")) {
        lineDataSet.setDrawCircles(config.getBoolean("drawCircles"));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawCubic")) {
        lineDataSet.setDrawCubic(config.getBoolean("drawCubic"));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "drawCubicIntensity")) {
        lineDataSet.setCubicIntensity((float) config.getDouble("drawCubicIntensity"));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "circleColor")) {
        lineDataSet.setCircleColor(Color.parseColor(config.getString("circleColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.Array, "circleColors")) {
        lineDataSet.setCircleColors(BridgeUtils.parseColors(config.getArray("circleColors")));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "circleColorHole")) {
        lineDataSet.setCircleColorHole(Color.parseColor(config.getString("circleColorHole")));
    }
    if (BridgeUtils.validate(config, ReadableType.Boolean, "drawCircleHole")) {
        lineDataSet.setDrawCircleHole(config.getBoolean("drawCircleHole"));
    }
    if (BridgeUtils.validate(config, ReadableType.Map, "dashedLine")) {
        ReadableMap dashedLine = config.getMap("dashedLine");
        float lineLength = 0;
        float spaceLength = 0;
        float phase = 0;

        if (BridgeUtils.validate(dashedLine, ReadableType.Number, "lineLength")) {
            lineLength = (float) dashedLine.getDouble("lineLength");
        }
        if (BridgeUtils.validate(dashedLine, ReadableType.Number, "spaceLength")) {
            spaceLength = (float) dashedLine.getDouble("spaceLength");
        }
        if (BridgeUtils.validate(dashedLine, ReadableType.Number, "phase")) {
            phase = (float) dashedLine.getDouble("phase");
        }

        lineDataSet.enableDashedLine(lineLength, spaceLength, phase);
    }
}