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

The following examples show how to use com.github.mikephil.charting.data.LineDataSet#setCircleRadius() . 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: 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 3
Source File: CombinedChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private LineData generateLineData() {

        LineData d = new LineData();

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

        for (int index = 0; index < itemcount; index++)
            entries.add(new Entry(getRandom(15, 10), index));

        LineDataSet set = new LineDataSet(entries, "Line DataSet");
        set.setColor(Color.rgb(240, 238, 70));
        set.setLineWidth(2.5f);
        set.setCircleColor(Color.rgb(240, 238, 70));
        set.setCircleRadius(5f);
        set.setFillColor(Color.rgb(240, 238, 70));
        set.setDrawCubic(true);
        set.setDrawValues(true);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.rgb(240, 238, 70));

        set.setAxisDependency(YAxis.AxisDependency.LEFT);

        d.addDataSet(set);

        return d;
    }
 
Example 4
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 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: InvertedLineChartActivity.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private void setData(int count, float range) {

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

        for (int i = 0; i < count; i++) {
            float xVal = (float) (Math.random() * range);
            float yVal = (float) (Math.random() * range);
            entries.add(new Entry(xVal, yVal));
        }

        // sort by x-value
        Collections.sort(entries, new EntryXComparator());

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(entries, "DataSet 1");

        set1.setLineWidth(1.5f);
        set1.setCircleRadius(4f);

        // create a data object with the data sets
        LineData data = new LineData(set1);

        // set data
        chart.setData(data);
    }
 
Example 7
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 8
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 9
Source File: ChartStatistics.java    From TwistyTimer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the main data set for all times and the data set for the progression of record best
 * times among all times. The progression of best times are marked in a different color to the
 * main line of all time using circles lined with a dashed line. This will appear to connect
 * the lowest troughs along the main line of all times.
 *
 * @param chartData The chart data to which to add the new data sets.
 * @param allLabel  The label of the all-times line.
 * @param allColor  The color of the all-times line.
 * @param bestLabel The label of the best-times line.
 * @param bestColor The color of the best-times line.
 */
private void addMainDataSets(LineData chartData, String allLabel, int allColor,
                             String bestLabel, int bestColor) {
    // Main data set for all solve times.
    final LineDataSet mainDataSet = createDataSet(allLabel, allColor);

    mainDataSet.setDrawCircles(getDrawCircle());
    mainDataSet.setCircleRadius(getCircleRadius());
    mainDataSet.setCircleColor(allColor);
    mainDataSet.setColor(getLineColor(allColor));

    chartData.addDataSet(mainDataSet);

    // Data set to show the progression of best times along the main line of all times.
    final LineDataSet bestDataSet = createDataSet(bestLabel, bestColor);

    bestDataSet.enableDashedLine(3f, 6f, 0f);

    bestDataSet.setDrawCircles(true);
    bestDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
    bestDataSet.setCircleColor(bestColor);

    bestDataSet.setDrawValues(false);
    bestDataSet.setValueTextColor(bestColor);
    bestDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
    bestDataSet.setValueFormatter(new TimeChartValueFormatter());

    chartData.addDataSet(bestDataSet);
}
 
Example 10
Source File: MultiLineChartActivity.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

    chart.resetTracking();

    progress = seekBarX.getProgress();

    tvX.setText(String.valueOf(seekBarX.getProgress()));
    tvY.setText(String.valueOf(seekBarY.getProgress()));

    ArrayList<ILineDataSet> dataSets = new ArrayList<>();

    for (int z = 0; z < 3; z++) {

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

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

        LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
        d.setLineWidth(2.5f);
        d.setCircleRadius(4f);

        int color = colors[z % colors.length];
        d.setColor(color);
        d.setCircleColor(color);
        dataSets.add(d);
    }

    // make the first DataSet dashed
    ((LineDataSet) dataSets.get(0)).enableDashedLine(10, 10, 0);
    ((LineDataSet) dataSets.get(0)).setColors(ColorTemplate.VORDIPLOM_COLORS);
    ((LineDataSet) dataSets.get(0)).setCircleColors(ColorTemplate.VORDIPLOM_COLORS);

    LineData data = new LineData(dataSets);
    chart.setData(data);
    chart.invalidate();
}
 
Example 11
Source File: LineChartActivityColored.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
private LineData getData(int count, float range) {

        ArrayList<String> xVals = new ArrayList<String>();
        for (int i = 0; i < count; i++) {
            xVals.add(mMonths[i % 12]);
        }

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

        for (int i = 0; i < count; i++) {
            float val = (float) (Math.random() * range) + 3;
            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);

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

        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);

        return data;
    }
 
Example 12
Source File: SimpleFragment.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
protected LineData getComplexity() {
    
    ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>();
    
    LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "n.txt"), "O(n)");
    LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "nlogn.txt"), "O(nlogn)");
    LineDataSet ds3 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "square.txt"), "O(n\u00B2)");
    LineDataSet ds4 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "three.txt"), "O(n\u00B3)");
    
    ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);
    ds3.setColor(ColorTemplate.VORDIPLOM_COLORS[2]);
    ds4.setColor(ColorTemplate.VORDIPLOM_COLORS[3]);
    
    ds1.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
    ds2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[1]);
    ds3.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]);
    ds4.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[3]);
    
    ds1.setLineWidth(2.5f);
    ds1.setCircleRadius(3f);
    ds2.setLineWidth(2.5f);
    ds2.setCircleRadius(3f);
    ds3.setLineWidth(2.5f);
    ds3.setCircleRadius(3f);
    ds4.setLineWidth(2.5f);
    ds4.setCircleRadius(3f);
    
    
    // load DataSets from textfiles in assets folders
    sets.add(ds1);        
    sets.add(ds2);
    sets.add(ds3);
    sets.add(ds4);
    
    LineData d = new LineData(ChartData.generateXVals(0, ds1.getEntryCount()), sets);
    d.setValueTypeface(tf);
    return d;
}
 
Example 13
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 14
Source File: AudioFragment.java    From walt with Apache License 2.0 5 votes vote down vote up
private void drawWaveformChart() {
    final short[] wave = AudioTest.getRecordedWave();
    List<Entry> entries = new ArrayList<>();
    int frameRate = audioTest.getOptimalFrameRate();
    for (int i = 0; i < wave.length; i++) {
        float timeStamp = (float) i / frameRate * 1000f;
        entries.add(new Entry(timeStamp, (float) wave[i]));
    }
    LineDataSet dataSet = new LineDataSet(entries, "Waveform");
    dataSet.setColor(Color.BLACK);
    dataSet.setValueTextColor(Color.BLACK);
    dataSet.setCircleColor(ContextCompat.getColor(getContext(), R.color.DarkGreen));
    dataSet.setCircleRadius(1.5f);
    dataSet.setCircleColorHole(Color.DKGRAY);
    LineData lineData = new LineData(dataSet);
    chart.setData(lineData);

    LimitLine line = new LimitLine(audioTest.getThreshold(), "Threshold");
    line.setLineColor(Color.RED);
    line.setLabelPosition(LimitLine.LimitLabelPosition.LEFT_TOP);
    line.setLineWidth(2f);
    line.setTextColor(Color.DKGRAY);
    line.setTextSize(10f);
    chart.getAxisLeft().addLimitLine(line);

    final Description desc = new Description();
    desc.setText("Wave [digital level -32768 to +32767] vs. Time [ms]");
    desc.setTextSize(12f);
    chart.setDescription(desc);
    chart.getLegend().setEnabled(false);
    chart.invalidate();
    chartLayout.setVisibility(View.VISIBLE);
}
 
Example 15
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 16
Source File: ProcessViewer.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates an instance for {@link LineDataSet} which will store the entries
 * @return
 */
private LineDataSet createDataSet() {
    LineDataSet lineDataset = new LineDataSet(new ArrayList<Entry>(), null);

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

    return lineDataset;
}
 
Example 17
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 18
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 19
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);
    }
}
 
Example 20
Source File: MultiLineChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    
    mChart.resetTracking();

    tvX.setText("" + (mSeekBarX.getProgress()));
    tvY.setText("" + (mSeekBarY.getProgress()));

    ArrayList<String> xVals = new ArrayList<String>();
    for (int i = 0; i < mSeekBarX.getProgress(); i++) {
        xVals.add((i) + "");
    }
 
    ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();

    for (int z = 0; z < 3; z++) {

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

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

        LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
        d.setLineWidth(2.5f);
        d.setCircleRadius(4f);

        int color = mColors[z % mColors.length];
        d.setColor(color);
        d.setCircleColor(color);
        dataSets.add(d);
    }

    // make the first DataSet dashed
    ((LineDataSet) dataSets.get(0)).enableDashedLine(10, 10, 0);
    ((LineDataSet) dataSets.get(0)).setColors(ColorTemplate.VORDIPLOM_COLORS);
    ((LineDataSet) dataSets.get(0)).setCircleColors(ColorTemplate.VORDIPLOM_COLORS);

    LineData data = new LineData(xVals, dataSets);
    mChart.setData(data);
    mChart.invalidate();
}