Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setCircleColor()
The following examples show how to use
com.github.mikephil.charting.data.LineDataSet#setCircleColor() .
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 |
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: 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 3
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 4
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 5
Source File: LineChartActivityColored.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private LineData getData(int count, float range) { ArrayList<Entry> values = new ArrayList<>(); for (int i = 0; i < count; i++) { float val = (float) (Math.random() * range) + 3; values.add(new Entry(i, val)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(values, "DataSet 1"); // set1.setFillAlpha(110); // set1.setFillColor(Color.RED); set1.setLineWidth(1.75f); set1.setCircleRadius(5f); set1.setCircleHoleRadius(2.5f); set1.setColor(Color.WHITE); set1.setCircleColor(Color.WHITE); set1.setHighLightColor(Color.WHITE); set1.setDrawValues(false); // create a data object with the data sets return new LineData(set1); }
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: SimpleFragment.java From Stayfit with Apache License 2.0 | 5 votes |
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 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: TimeLineView.java From android-kline with Apache License 2.0 | 5 votes |
@android.support.annotation.NonNull private LineDataSet setLine(int type, ArrayList<Entry> lineEntries) { LineDataSet lineDataSetMa = new LineDataSet(lineEntries, "ma" + type); lineDataSetMa.setDrawValues(false); if (type == NORMAL_LINE) { lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color)); lineDataSetMa.setCircleColor(ContextCompat.getColor(mContext, R.color.normal_line_color)); } else if (type == NORMAL_LINE_5DAY) { lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color)); lineDataSetMa.setCircleColor(mTransparentColor); } else if (type == AVE_LINE) { lineDataSetMa.setColor(getResources().getColor(R.color.ave_color)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else { lineDataSetMa.setVisible(false); lineDataSetMa.setHighlightEnabled(false); } lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT); lineDataSetMa.setLineWidth(1f); lineDataSetMa.setCircleRadius(1f); lineDataSetMa.setDrawCircles(false); lineDataSetMa.setDrawCircleHole(false); return lineDataSetMa; }
Example 10
Source File: MultiLineChartActivity.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@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: 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: DynamicalAddingActivity.java From StockChart-MPAndroidChart with MIT License | 5 votes |
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 13
Source File: LineChartActivityColored.java From Stayfit with Apache License 2.0 | 5 votes |
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 14
Source File: StatisticActivity.java From memorize with MIT License | 5 votes |
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 15
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 16
Source File: MultiLineChartActivity.java From Stayfit with Apache License 2.0 | 4 votes |
@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(); }
Example 17
Source File: KLineView.java From android-kline with Apache License 2.0 | 4 votes |
@android.support.annotation.NonNull private LineDataSet setLine(int type, ArrayList<Entry> lineEntries) { LineDataSet lineDataSetMa = new LineDataSet(lineEntries, "ma" + type); lineDataSetMa.setDrawValues(false); if (type == NORMAL_LINE) { lineDataSetMa.setColor(getResources().getColor(R.color.normal_line_color)); lineDataSetMa.setCircleColor(ContextCompat.getColor(mContext, R.color.normal_line_color)); } else if (type == K) { lineDataSetMa.setColor(getResources().getColor(R.color.k)); lineDataSetMa.setCircleColor(mTransparentColor); } else if (type == D) { lineDataSetMa.setColor(getResources().getColor(R.color.d)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == J) { lineDataSetMa.setColor(getResources().getColor(R.color.j)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == DIF) { lineDataSetMa.setColor(getResources().getColor(R.color.dif)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == DEA) { lineDataSetMa.setColor(getResources().getColor(R.color.dea)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == AVE_LINE) { lineDataSetMa.setColor(getResources().getColor(R.color.ave_color)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == MA5) { lineDataSetMa.setColor(getResources().getColor(R.color.ma5)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == MA10) { lineDataSetMa.setColor(getResources().getColor(R.color.ma10)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == MA20) { lineDataSetMa.setColor(getResources().getColor(R.color.ma20)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else if (type == MA30) { lineDataSetMa.setColor(getResources().getColor(R.color.ma30)); lineDataSetMa.setCircleColor(mTransparentColor); lineDataSetMa.setHighlightEnabled(false); } else { lineDataSetMa.setVisible(false); lineDataSetMa.setHighlightEnabled(false); } lineDataSetMa.setAxisDependency(YAxis.AxisDependency.LEFT); lineDataSetMa.setLineWidth(1f); lineDataSetMa.setCircleRadius(1f); lineDataSetMa.setDrawCircles(false); lineDataSetMa.setDrawCircleHole(false); return lineDataSetMa; }
Example 18
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 19
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 20
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); }