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

The following examples show how to use com.github.mikephil.charting.data.LineDataSet#setDrawCircles() . 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: PlotterFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 6 votes vote down vote up
private void appendDataset(@NonNull String peripheralIdentifier, @NonNull Entry entry, int index) {
    LineDataSet dataSet = new LineDataSet(null, "Values[" + peripheralIdentifier + ":" + index + "]");
    dataSet.addEntry(entry);
    dataSet.addEntry(entry);

    dataSet.setDrawCircles(false);
    dataSet.setDrawValues(false);
    dataSet.setLineWidth(2);
    final int[] colors = UartStyle.defaultColors();
    final int color = colors[index % colors.length];
    dataSet.setColor(color);
    final DashPathEffect dashPatternEffect = mLineDashPathEffectForPeripheral.get(peripheralIdentifier);
    dataSet.setFormLineDashEffect(dashPatternEffect);

    List<LineDataSet> previousDataSets = mDataSetsForPeripheral.get(peripheralIdentifier);
    if (previousDataSets != null) {
        previousDataSets.add(dataSet);
    } else {
        List<LineDataSet> dataSets = new ArrayList<>();
        dataSets.add(dataSet);
        mDataSetsForPeripheral.put(peripheralIdentifier, dataSets);
    }
}
 
Example 2
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 3
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 4
Source File: RangeTestFragmentView.java    From EFRConnect-android with Apache License 2.0 6 votes vote down vote up
private LineData createChartData(int color) {
    List<Entry> entries = new ArrayList<>(1024);
    entries.add(new Entry(-2, 0));
    entries.add(new Entry(-1, 0));

    chartDataSet = new LineDataSet(entries, null);

    chartDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    chartDataSet.setCubicIntensity(0.1f);
    chartDataSet.setDrawCircles(false);
    chartDataSet.setDrawFilled(true);
    chartDataSet.setLineWidth(0f);
    chartDataSet.setColor(color);
    chartDataSet.setFillColor(color);
    chartDataSet.setFillAlpha(255);
    chartDataSet.setDrawHorizontalHighlightIndicator(false);
    chartDataSet.setDrawVerticalHighlightIndicator(false);
    chartDataSet.setFillFormatter(new CubicLineSampleFillFormatter());

    chartData = new LineData(chartDataSet);

    chartData.setDrawValues(false);

    return chartData;
}
 
Example 5
Source File: ChartMeasurementView.java    From openScale with GNU General Public License v3.0 6 votes vote down vote up
private void addGoalLine(List<ILineDataSet> lineDataSets) {
    if (prefs.getBoolean("goalLine", true)) {
        List<Entry> valuesGoalLine = new Stack<>();

        ScaleUser user = OpenScale.getInstance().getSelectedScaleUser();
        float goalWeight = Converters.fromKilogram(user.getGoalWeight(), user.getScaleUnit());

        valuesGoalLine.add(new Entry(minXValue, goalWeight));
        valuesGoalLine.add(new Entry(maxXValue, goalWeight));

        LineDataSet goalLine = new LineDataSet(valuesGoalLine, getContext().getString(R.string.label_goal_line));
        goalLine.setLineWidth(1.5f);
        goalLine.setColor(ColorUtil.COLOR_GREEN);
        goalLine.setAxisDependency(prefs.getBoolean("weightOnRightAxis", true) ? YAxis.AxisDependency.RIGHT : YAxis.AxisDependency.LEFT);
        goalLine.setDrawValues(false);
        goalLine.setDrawCircles(false);
        goalLine.setHighlightEnabled(false);
        goalLine.enableDashedLine(10, 30, 0);

        lineDataSets.add(goalLine);
    }
}
 
Example 6
Source File: KLineDataManage.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private LineDataSet setALine(ColorType colorType, ArrayList<Entry> lineEntries, String label, boolean highlightEnable) {
    LineDataSet lineDataSetMa = new LineDataSet(lineEntries, label);
    lineDataSetMa.setDrawHorizontalHighlightIndicator(false);
    lineDataSetMa.setHighlightEnabled(highlightEnable);//是否画高亮十字线
    lineDataSetMa.setHighLightColor(ContextCompat.getColor(mContext, R.color.highLight_Color));//高亮十字线颜色
    lineDataSetMa.setDrawValues(false);//是否画出每个蜡烛线的数值
    if (colorType == ColorType.blue) {
        lineDataSetMa.setColor(ContextCompat.getColor(mContext, R.color.ma5));
    } else if (colorType == ColorType.yellow) {
        lineDataSetMa.setColor(ContextCompat.getColor(mContext, R.color.ma10));
    } else if (colorType == ColorType.purple) {
        lineDataSetMa.setColor(ContextCompat.getColor(mContext, R.color.ma20));
    }
    lineDataSetMa.setLineWidth(0.6f);
    lineDataSetMa.setDrawCircles(false);
    lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT);
    return lineDataSetMa;
}
 
Example 7
Source File: RecordingsAdapter.java    From go-bees with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Style char lines (type, color, etc.).
 *
 * @param entries list of entries.
 * @return line data chart.
 */
private LineData styleChartLines(List<Entry> entries) {
    // Set styles
    LineDataSet lineDataSet = new LineDataSet(entries, "Recording");
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet.setCubicIntensity(0.2f);
    lineDataSet.setDrawValues(false);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setColor(ContextCompat.getColor(context, R.color.colorAccent));
    if (((int) lineDataSet.getYMax()) != 0) {
        lineDataSet.setDrawFilled(true);
        lineDataSet.setFillAlpha(255);
        // Fix bug with vectors in API < 21
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT){
            Drawable drawable = ResourcesCompat.getDrawable(context.getResources(),
                    R.drawable.chart_fade, null);
            lineDataSet.setFillDrawable(drawable);
        } else{
            lineDataSet.setFillColor(ContextCompat.getColor(context, R.color.colorPrimary));
        }
    }
    return new LineData(lineDataSet);
}
 
Example 8
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 9
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 10
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 11
Source File: Utils.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
private static LineDataSet initUploadSet(Context context) {
    LineDataSet set = new LineDataSet(null, context.getString(R.string.uploadSpeed));
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    set.setLineWidth(2f);
    set.setColor(ContextCompat.getColor(context, R.color.uploadColor));
    set.setDrawCircles(false);
    set.setDrawValues(false);
    set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    set.setDrawFilled(false);
    return set;
}
 
Example 12
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 13
Source File: PerformanceLineChart.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
private void setData(int count, float range) {

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

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

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

        set1.setColor(Color.BLACK);
        set1.setLineWidth(0.5f);
        set1.setDrawValues(false);
        set1.setDrawCircles(false);
        set1.setMode(LineDataSet.Mode.LINEAR);
        set1.setDrawFilled(false);

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

        // set data
        chart.setData(data);

        // get the legend (only possible after setting data)
        Legend l = chart.getLegend();
        l.setEnabled(false);
    }
 
Example 14
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 15
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 16
Source File: PowerChart.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
private LineDataSet createDataSet() {
    LineDataSet powerDataset = new LineDataSet(null, "watts");
    powerDataset.setColor(ContextCompat.getColor(context, R.color.chartBlue));
    powerDataset.setValueTextColor(ContextCompat.getColor(context, R.color.lightGrey));
    powerDataset.setDrawCircles(false);
    powerDataset.setDrawFilled(true);
    powerDataset.setFillColor(ContextCompat.getColor(context, R.color.chartBlue));
    powerDataset.setDrawValues(false);
    powerDataset.setValueTextSize(R.integer.chartValueTextSize);
    powerDataset.setHighlightEnabled(false);
    return powerDataset;
}
 
Example 17
Source File: RecordingFragment.java    From go-bees with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Configure styles of weather charts.
 *
 * @param entries   chart data.
 * @param formatter value formatter.
 * @param minVal    min value to show.
 * @param maxVal    max value to show.
 * @return chart formatted.
 */
private LineDataSet configureWeatherChart(
        LineChart chart, int chartName, int colorLineTempChart, int colorFillTempChart,
        List<Entry> entries, IAxisValueFormatter formatter, double minVal, double maxVal) {
    LineDataSet lineDataSet = new LineDataSet(entries, getString(chartName));
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet.setDrawValues(false);
    lineDataSet.setValueTextSize(10f);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setColor(ContextCompat.getColor(getContext(), colorLineTempChart));
    lineDataSet.setLineWidth(2f);
    lineDataSet.setDrawFilled(true);
    lineDataSet.setFillColor(ContextCompat.getColor(getContext(), colorFillTempChart));
    lineDataSet.setFillAlpha(255);
    // General setup
    chart.setDrawGridBackground(false);
    chart.setDrawBorders(false);
    chart.setViewPortOffsets(0, 0, 0, 0);
    chart.getDescription().setEnabled(false);
    chart.getLegend().setEnabled(false);
    chart.setTouchEnabled(false);
    // X axis setup
    XAxis xAxis = chart.getXAxis();
    xAxis.setEnabled(false);
    xAxis.setAxisMinimum(0);
    xAxis.setAxisMaximum(lastTimestamp);
    // Y axis setup
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setEnabled(false);
    leftAxis.setAxisMaximum((float) (maxVal));
    leftAxis.setAxisMinimum((float) (minVal));
    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setAxisMaximum((float) (maxVal));
    rightAxis.setAxisMinimum((float) (minVal));
    rightAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    rightAxis.setValueFormatter(formatter);
    return lineDataSet;
}
 
Example 18
Source File: RecordingFragment.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Configure bees chart and the data.
 *
 * @param recordsList list of records.
 */
private void setupBeesChart(List<Record> recordsList) {
    // Setup data
    referenceTimestamp = recordsList.get(0).getTimestamp().getTime() / 1000;
    Record[] records = recordsList.toArray(new Record[recordsList.size()]);
    List<Entry> entries = new ArrayList<>();
    int maxNumBees = 0;
    for (Record record : records) {
        // Convert timestamp to seconds and relative to first timestamp
        long timestamp = record.getTimestamp().getTime() / 1000 - referenceTimestamp;
        int numBees = record.getNumBees();
        entries.add(new Entry(timestamp, numBees));
        // Get max num of bees
        if (numBees > maxNumBees) {
            maxNumBees = numBees;
        }
    }
    lastTimestamp = (long) entries.get(entries.size() - 1).getX();
    // Style char lines (type, color, etc.)
    LineDataSet lineDataSet = new LineDataSet(entries, getString(R.string.num_bees));
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet.setCubicIntensity(0.2f);
    lineDataSet.setDrawValues(false);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
    // General setup
    beesChart.setDrawGridBackground(false);
    beesChart.setDrawBorders(false);
    beesChart.setViewPortOffsets(80, 40, 80, 50);
    beesChart.getDescription().setEnabled(false);
    beesChart.getLegend().setEnabled(false);
    beesChart.setTouchEnabled(true);
    beesChart.setDragEnabled(false);
    beesChart.setScaleEnabled(false);
    beesChart.setPinchZoom(false);
    BeesMarkerView mv = new BeesMarkerView(getContext(), R.layout.recording_bees_marker_vew);
    mv.setChartView(beesChart);
    beesChart.setMarker(mv);
    beesChart.setNoDataText(getString(R.string.no_flight_act_data_available));
    // X axis setup
    IAxisValueFormatter xAxisFormatter = new HourAxisValueFormatter(referenceTimestamp);
    XAxis xAxis = beesChart.getXAxis();
    xAxis.setValueFormatter(xAxisFormatter);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(Color.BLACK);
    // Y axis setup
    YAxis leftAxis = beesChart.getAxisLeft();
    leftAxis.setAxisMaximum(maxNumBees > 40 ? maxNumBees + 2 : 40);
    leftAxis.setAxisMinimum(0);
    leftAxis.setDrawGridLines(true);
    leftAxis.setDrawAxisLine(false);
    YAxis rightAxis = beesChart.getAxisRight();
    rightAxis.setAxisMaximum(maxNumBees > 40 ? maxNumBees + 2 : 40);
    rightAxis.setAxisMinimum(0);
    rightAxis.setDrawGridLines(true);
    rightAxis.setDrawAxisLine(false);
    // Add data
    beesChart.setData(new LineData(lineDataSet));
}
 
Example 19
Source File: StatActivity.java    From ankihelper with GNU General Public License v3.0 4 votes vote down vote up
private void drawLastDaysChart(int[][] data) {
    List<Entry> lookupEntries = new ArrayList<>();
    List<Entry> cardaddEntries = new ArrayList<>();
    for(int i = 0; i < data[0].length; i ++){
        lookupEntries.add(new Entry(i, data[1][i]));
        cardaddEntries.add(new Entry(i, data[2][i]));
    }
    if(lookupEntries.size() <= 1){
        mLastDaysChart.setVisibility(View.INVISIBLE);
    }else{
        mLastDaysChart.setVisibility(View.VISIBLE);
    }
    float lineWidth = 2;
    LineDataSet lineDataSet2 = new LineDataSet(lookupEntries, "Lookups");
    lineDataSet2.setColor(DARK_PINK);
    lineDataSet2.setLineWidth(lineWidth);
    lineDataSet2.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet2.setDrawCircles(false);
    lineDataSet2.setDrawValues(false);
    LineDataSet lineDataSet3 = new LineDataSet(cardaddEntries, "Cards");
    lineDataSet3.setColor(DARK_GREEN);
    lineDataSet3.setLineWidth(lineWidth);
    lineDataSet3.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet3.setDrawCircles(false);
    lineDataSet3.setDrawValues(false);
    List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(lineDataSet2);
    dataSets.add(lineDataSet3);
    mLastDaysChart.setData(new LineData(dataSets));
    mLastDaysChart.getDescription().setText("");
    //mHourChart.getDescription().setTextAlign();
    mLastDaysChart.getXAxis().setDrawGridLines(false);
    mLastDaysChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    mLastDaysChart.getAxisRight().setEnabled(false);
    //mHourChart.getAxisLeft().setDrawGridLines(false);
    mLastDaysChart.getXAxis().setValueFormatter(
            new IAxisValueFormatter() {
                @Override
                public String getFormattedValue(float value, AxisBase axis) {
                    return  + ((int)(-mLastDays + value + 1)) + "d";
                }
            }
    );
    mLastDaysChart.getLegend().setPosition(Legend.LegendPosition.BELOW_CHART_CENTER);
    mLastDaysChart.invalidate();
}
 
Example 20
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;
}