Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setMode()
The following examples show how to use
com.github.mikephil.charting.data.LineDataSet#setMode() .
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: CombinedChartActivity.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private LineData generateLineData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<>(); for (int index = 0; index < count; index++) entries.add(new Entry(index + 0.5f, getRandom(15, 5))); 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.setMode(LineDataSet.Mode.CUBIC_BEZIER); set.setDrawValues(true); set.setValueTextSize(10f); set.setValueTextColor(Color.rgb(240, 238, 70)); set.setAxisDependency(YAxis.AxisDependency.LEFT); d.addDataSet(set); return d; }
Example 2
Source File: RecordingsAdapter.java From go-bees with GNU General Public License v3.0 | 6 votes |
/** * 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 3
Source File: RangeTestFragmentView.java From EFRConnect-android with Apache License 2.0 | 6 votes |
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 4
Source File: TrainedModelViewBinder.java From Synapse with Apache License 2.0 | 6 votes |
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: Utils.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@NonNull private static LineDataSet initDownloadSet(Context context) { LineDataSet set = new LineDataSet(null, context.getString(R.string.downloadSpeed)); set.setAxisDependency(YAxis.AxisDependency.LEFT); set.setLineWidth(2f); set.setColor(ContextCompat.getColor(context, R.color.downloadColor)); set.setDrawCircles(false); set.setDrawValues(false); set.setMode(LineDataSet.Mode.CUBIC_BEZIER); set.setDrawFilled(false); return set; }
Example 6
Source File: ChartRVAdapter.java From batteryhub with Apache License 2.0 | 5 votes |
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 7
Source File: RecordingFragment.java From go-bees with GNU General Public License v3.0 | 5 votes |
/** * 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 8
Source File: ModelDetailActivity.java From Synapse with Apache License 2.0 | 5 votes |
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: PerformanceLineChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
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 10
Source File: Utils.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@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 11
Source File: ChartUtil.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 4 votes |
/** * 曲线赋值与设置 * * @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 12
Source File: DataPlotFragment.java From OpenLibre with GNU General Public License v3.0 | 4 votes |
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 13
Source File: StatActivity.java From ankihelper with GNU General Public License v3.0 | 4 votes |
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 14
Source File: RecordingFragment.java From go-bees with GNU General Public License v3.0 | 4 votes |
/** * 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 15
Source File: HourlyActivity.java From weather with Apache License 2.0 | 4 votes |
private void setChartValues(List<ItemHourlyDB> itemHourlyDBList) { List<Entry> entries = new ArrayList<>(); int i = 0; if (AppUtil.isRTL(this)) { int j = itemHourlyDBList.size() - 1; while (j >= 0) { entries.add(new Entry(i, (float) itemHourlyDBList.get(j).getTemp())); i++; j--; } } else { for (ItemHourlyDB itemHourlyDB : itemHourlyDBList) { entries.add(new Entry(i, (float) itemHourlyDB.getTemp())); i++; } } LineDataSet dataSet = new LineDataSet(entries, "Label"); // add entries to dataset dataSet.setLineWidth(4f); dataSet.setCircleRadius(7f); dataSet.setHighlightEnabled(false); dataSet.setCircleColor(Color.parseColor("#33b5e5")); dataSet.setValueTextSize(12); dataSet.setValueTextColor(Color.WHITE); dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER); dataSet.setValueTypeface(typeface); dataSet.setValueFormatter(new ValueFormatter() { @Override public String getFormattedValue(float value) { return String.format(Locale.getDefault(), "%.0f", value); } }); LineData lineData = new LineData(dataSet); chart.getDescription().setEnabled(false); chart.getAxisLeft().setDrawLabels(false); chart.getAxisRight().setDrawLabels(false); chart.getXAxis().setDrawLabels(false); chart.getLegend().setEnabled(false); // Hide the legend chart.getXAxis().setDrawGridLines(false); chart.getAxisLeft().setDrawGridLines(false); chart.getAxisRight().setDrawGridLines(false); chart.getAxisLeft().setDrawAxisLine(false); chart.getAxisRight().setDrawAxisLine(false); chart.getXAxis().setDrawAxisLine(false); chart.setScaleEnabled(false); chart.setData(lineData); chart.animateY(1000); }
Example 16
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
private void updateLineChart() { LineChart lineChart = getLineChart(); if(lineChart == null) { return; } if(freqLeqStats.isEmpty()) { return; } float YMin = Float.MAX_VALUE; float YMax = Float.MIN_VALUE; ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); // Read all white noise values for indexing before usage int idStep = 0; double referenceLevel = freqLeqStats.get(0).whiteNoiseLevel.getGlobaldBaValue(); for(LinearCalibrationResult result : freqLeqStats) { ArrayList<Entry> yMeasure = new ArrayList<Entry>(); int idfreq = 0; for (LeqStats leqStat : result.measure) { float dbLevel = (float)leqStat.getLeqMean(); YMax = Math.max(YMax, dbLevel); YMin = Math.min(YMin, dbLevel); yMeasure.add(new Entry(dbLevel, idfreq++)); } LineDataSet freqSet = new LineDataSet(yMeasure, String.format(Locale.getDefault(),"%d dB", (int)(result.whiteNoiseLevel.getGlobaldBaValue() - referenceLevel))); freqSet.setColor(ColorTemplate.COLORFUL_COLORS[idStep % ColorTemplate.COLORFUL_COLORS.length]); freqSet.setFillColor(ColorTemplate.COLORFUL_COLORS[idStep % ColorTemplate.COLORFUL_COLORS.length]); freqSet.setValueTextColor(Color.WHITE); freqSet.setCircleColorHole(ColorTemplate.COLORFUL_COLORS[idStep % ColorTemplate.COLORFUL_COLORS.length]); freqSet.setDrawValues(false); freqSet.setDrawFilled(true); freqSet.setFillAlpha(255); freqSet.setDrawCircles(true); freqSet.setMode(LineDataSet.Mode.LINEAR); dataSets.add(freqSet); idStep++; } ArrayList<String> xVals = new ArrayList<String>(); double[] freqs = FFTSignalProcessing.computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION); for (double freqValue : freqs) { xVals.add(Spectrogram.formatFrequency((int)freqValue)); } // create a data object with the datasets LineData data = new LineData(xVals, dataSets); lineChart.setData(data); YAxis yl = lineChart.getAxisLeft(); yl.setAxisMinValue(YMin - 3); yl.setAxisMaxValue(YMax + 3); lineChart.invalidate(); }
Example 17
Source File: DataUsageActivity.java From utexas-utilities with Apache License 2.0 | 4 votes |
private void setupChart(List<String> labels, List<Entry> downData, List<Entry> totalData) { LineDataSet totalLineDataSet = new LineDataSet(totalData, "Uploaded"); totalLineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT); totalLineDataSet.setDrawCircles(false); totalLineDataSet.setCubicIntensity(0.1f); totalLineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); totalLineDataSet.setDrawFilled(true); totalLineDataSet.setDrawValues(false); totalLineDataSet.setColor(ContextCompat.getColor(this, R.color.data_usage_chart_upload)); totalLineDataSet.setFillColor(ContextCompat.getColor(this, R.color.data_usage_chart_upload)); totalLineDataSet.setFillAlpha(255); LineDataSet downLineDataSet = new LineDataSet(downData, "Downloaded"); downLineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT); downLineDataSet.setDrawCircles(false); downLineDataSet.setCubicIntensity(0.1f); downLineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); downLineDataSet.setDrawFilled(true); downLineDataSet.setDrawValues(false); downLineDataSet.setColor(ContextCompat.getColor(this, R.color.data_usage_chart_download)); downLineDataSet.setFillColor(ContextCompat.getColor(this, R.color.data_usage_chart_download)); downLineDataSet.setFillAlpha(255); List<ILineDataSet> downAndUp = new ArrayList<>(); downAndUp.add(totalLineDataSet); downAndUp.add(downLineDataSet); LineData dataUsageLineData = new LineData(labels, downAndUp); chart.getAxisRight().setEnabled(true); chart.getAxisRight().setDrawAxisLine(true); chart.getAxisRight().setDrawGridLines(false); chart.getAxisRight().setDrawLabels(false); chart.getAxisLeft().setStartAtZero(true); chart.setData(dataUsageLineData); chart.setDescription(""); chart.setScaleXEnabled(true); chart.setScaleYEnabled(false); chart.setPinchZoom(true); chart.setDoubleTapToZoomEnabled(true); chart.getData().setHighlightEnabled(false); chart.getAxisLeft().setValueFormatter((value, axis) -> value + " MB"); // maximum viewable area is one day chart.setScaleMinima(downData.size() / 288f, 1f); // initially show the most recent 24 hours chart.centerViewTo(Math.max(downData.size() - 144, 0), chart.getYChartMax() / 2, YAxis.AxisDependency.LEFT); chart.setVisibility(View.VISIBLE); progressLayout.setVisibility(View.GONE); }