Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setFillAlpha()
The following examples show how to use
com.github.mikephil.charting.data.LineDataSet#setFillAlpha() .
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: RealtimeLineChartActivity.java From StockChart-MPAndroidChart with MIT License | 6 votes |
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 2
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 3
Source File: LineChartHelper.java From Ticket-Analysis with MIT License | 6 votes |
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 4
Source File: RealtimeLineChartActivity.java From Stayfit with Apache License 2.0 | 6 votes |
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: 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 6
Source File: LineChartTime.java From StockChart-MPAndroidChart with MIT License | 5 votes |
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 7
Source File: RideDetailActivity.java From android-ponewheel with MIT License | 5 votes |
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 8
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 9
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 10
Source File: CubicLineChartActivity.java From Stayfit with Apache License 2.0 | 4 votes |
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((1990 +i) + ""); } ArrayList<Entry> vals1 = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult) + 20;// + (float) // ((mult * // 0.1) / 10); vals1.add(new Entry(val, i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(vals1, "DataSet 1"); set1.setDrawCubic(true); set1.setCubicIntensity(0.2f); //set1.setDrawFilled(true); set1.setDrawCircles(false); set1.setLineWidth(1.8f); set1.setCircleRadius(4f); set1.setCircleColor(Color.WHITE); set1.setHighLightColor(Color.rgb(244, 117, 117)); set1.setColor(Color.WHITE); set1.setFillColor(Color.WHITE); set1.setFillAlpha(100); set1.setDrawHorizontalHighlightIndicator(false); set1.setFillFormatter(new FillFormatter() { @Override public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { return -10; } }); // create a data object with the datasets LineData data = new LineData(xVals, set1); data.setValueTypeface(tf); data.setValueTextSize(9f); data.setDrawValues(false); // set data mChart.setData(data); }
Example 11
Source File: DateGraph.java From fastnfitness with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void draw(ArrayList<Entry> entries) { mChart.clear(); if (entries.isEmpty()) { return; } Collections.sort(entries, new EntryXComparator()); //Log.d("DEBUG", arrayToString(entries)); LineDataSet set1 = new LineDataSet(entries, mChartName); set1.setLineWidth(3f); set1.setCircleRadius(4f); set1.setDrawFilled(true); if (Utils.getSDKInt() >= 18) { // fill drawable only supported on api level 18 and above Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.fade_blue); set1.setFillDrawable(drawable); } else { set1.setFillColor(ColorTemplate.getHoloBlue()); } set1.setFillAlpha(100); set1.setColor(mContext.getResources().getColor(R.color.toolbar_background)); set1.setCircleColor(mContext.getResources().getColor(R.color.toolbar_background)); // Create a data object with the datasets LineData data = new LineData(set1); data.setValueFormatter(new IValueFormatter() { private DecimalFormat mFormat = new DecimalFormat("#.##"); @Override public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { return mFormat.format(value); } }); // Set data mChart.setData(data); mChart.invalidate(); //mChart.animateY(500, Easing.EasingOption.EaseInBack); //refresh graph }
Example 12
Source File: MiniDateGraph.java From fastnfitness with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void draw(ArrayList<Entry> entries) { mChart.clear(); if (entries.isEmpty()) { return; } Collections.sort(entries, new EntryXComparator()); //Log.d("DEBUG", arrayToString(entries)); LineDataSet set1 = new LineDataSet(entries, mChartName); set1.setLineWidth(3f); set1.setCircleRadius(0f); set1.setDrawFilled(true); if (Utils.getSDKInt() >= 18) { // fill drawable only supported on api level 18 and above Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.fade_blue); set1.setFillDrawable(drawable); } else { set1.setFillColor(ColorTemplate.getHoloBlue()); } set1.setFillAlpha(100); set1.setColor(mContext.getResources().getColor(R.color.toolbar_background)); set1.setCircleColor(mContext.getResources().getColor(R.color.toolbar_background)); // Create a data object with the datasets LineData data = new LineData(set1); data.setDrawValues(false); /*data.setValueFormatter(new IValueFormatter() { private DecimalFormat mFormat = new DecimalFormat("#.##"); @Override public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { return mFormat.format(value); } });*/ // Set data mChart.setData(data); mChart.invalidate(); //mChart.animateY(500, Easing.EasingOption.EaseInBack); //refresh graph }
Example 13
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 14
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); }