Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setFillColor()
The following examples show how to use
com.github.mikephil.charting.data.LineDataSet#setFillColor() .
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: 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 4
Source File: CombinedChartActivity.java From Stayfit with Apache License 2.0 | 6 votes |
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 5
Source File: GraphFragment.java From CryptoBuddy with GNU Affero General Public License v3.0 | 6 votes |
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 6
Source File: FragmentPrice.java From Lunary-Ethereum-Wallet with GNU General Public License v3.0 | 6 votes |
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 7
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 8
Source File: FragmentPrice.java From bcm-android with GNU General Public License v3.0 | 6 votes |
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 9
Source File: TrainedModelViewBinder.java From Synapse with Apache License 2.0 | 5 votes |
private void changeStyle(long id, LineChart chart, LineDataSet set) { final int index = (int) (id % FG.length); final Context context = chart.getContext(); final int fg = ContextCompat.getColor(context, FG[index]); set.setColor(fg); set.setFillColor(fg); chart.setGridBackgroundColor(ContextCompat.getColor(context, BG[index])); }
Example 10
Source File: PlayActivity.java From Synapse with Apache License 2.0 | 5 votes |
private void changeStyle(long id, LineChart chart, LineDataSet set) { final int index = (int) (id % FG.length); final Context context = chart.getContext(); final int fg = ContextCompat.getColor(context, FG[index]); set.setColor(fg); set.setFillColor(fg); mLowerBg.setBackgroundColor(fg); getWindow().setBackgroundDrawableResource(BG[index]); }
Example 11
Source File: StatisticsFragment.java From HeartBeat with Apache License 2.0 | 5 votes |
private LineData getWeekThoughtData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<>(); for (int i=0; i<WEEK_COUNT; i++) { entries.add( new BarEntry( new GetCountSpecDayApi(getActivity()).exec( TimeUtils.calendarDaysBefore(WEEK_COUNT-i), GetCountSpecDayApi.THOUGHT ),i ) ); } LineDataSet set = new LineDataSet(entries, getString(R.string.thought_count_text)); set.setColor(mAccentColor); set.setLineWidth(2.5f); set.setAxisDependency(YAxis.AxisDependency.LEFT); set.setCircleColor(mPrimaryColorDark); set.setCircleSize(5f); set.setFillColor(mPrimaryColor); set.setDrawValues(true); set.setValueFormatter(new IntValueFormatter()); d.addDataSet(set); return d; }
Example 12
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 13
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 14
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 15
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 16
Source File: PowerChart.java From AndroidApp with GNU Affero General Public License v3.0 | 5 votes |
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: 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 18
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 19
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 20
Source File: CurrencyActivity.java From Travel-Mate with MIT License | 4 votes |
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); }