Java Code Examples for com.github.mikephil.charting.data.LineDataSet#setValueTextColor()
The following examples show how to use
com.github.mikephil.charting.data.LineDataSet#setValueTextColor() .
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: 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 3
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 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: DynamicalAddingActivity.java From StockChart-MPAndroidChart with MIT License | 5 votes |
private void addDataSet() { LineData data = chart.getData(); if (data == null) { chart.setData(new LineData()); } else { int count = (data.getDataSetCount() + 1); int amount = data.getDataSetByIndex(0).getEntryCount(); ArrayList<Entry> values = new ArrayList<>(); for (int i = 0; i < amount; i++) { values.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count)); } LineDataSet set = new LineDataSet(values, "DataSet " + count); set.setLineWidth(2.5f); set.setCircleRadius(4.5f); int color = colors[count % colors.length]; set.setColor(color); set.setCircleColor(color); set.setHighLightColor(color); set.setValueTextSize(10f); set.setValueTextColor(color); data.addDataSet(set); data.notifyDataChanged(); chart.notifyDataSetChanged(); chart.invalidate(); } }
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: ChartStatistics.java From TwistyTimer with GNU General Public License v3.0 | 5 votes |
/** * 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 9
Source File: DynamicalAddingActivity.java From Stayfit with Apache License 2.0 | 5 votes |
private void addDataSet() { LineData data = mChart.getData(); if(data != null) { int count = (data.getDataSetCount() + 1); // create 10 y-vals ArrayList<Entry> yVals = new ArrayList<Entry>(); if(data.getXValCount() == 0) { // add 10 x-entries for (int i = 0; i < 10; i++) { data.addXValue("" + (i+1)); } } for (int i = 0; i < data.getXValCount(); i++) { yVals.add(new Entry((float) (Math.random() * 50f) + 50f * count, i)); } LineDataSet set = new LineDataSet(yVals, "DataSet " + count); set.setLineWidth(2.5f); set.setCircleRadius(4.5f); int color = mColors[count % mColors.length]; set.setColor(color); set.setCircleColor(color); set.setHighLightColor(color); set.setValueTextSize(10f); set.setValueTextColor(color); data.addDataSet(set); mChart.notifyDataSetChanged(); mChart.invalidate(); } }
Example 10
Source File: ScreenResponseFragment.java From walt with Apache License 2.0 | 5 votes |
private void drawBrightnessChart() { final String brightnessCurveString = brightnessCurveData.toString(); List<Entry> entries = new ArrayList<>(); // "u" marks the start of the brightness curve data int startIndex = brightnessCurveString.indexOf("u") + 1; int endIndex = brightnessCurveString.indexOf("end"); if (endIndex == -1) endIndex = brightnessCurveString.length(); String[] brightnessStrings = brightnessCurveString.substring(startIndex, endIndex).trim().split("\n"); for (String str : brightnessStrings) { String[] arr = str.split(" "); final float timestampMs = Integer.parseInt(arr[0]) / 1000f; final float brightness = Integer.parseInt(arr[1]); entries.add(new Entry(timestampMs, brightness)); } LineDataSet dataSet = new LineDataSet(entries, "Brightness"); dataSet.setColor(Color.BLACK); dataSet.setValueTextColor(Color.BLACK); dataSet.setCircleColor(Color.BLACK); dataSet.setCircleRadius(1.5f); dataSet.setCircleColorHole(Color.DKGRAY); LineData lineData = new LineData(dataSet); brightnessChart.setData(lineData); final Description desc = new Description(); desc.setText("Screen Brightness [digital level 0-1023] vs. Time [ms]"); desc.setTextSize(12f); brightnessChart.setDescription(desc); brightnessChart.getLegend().setEnabled(false); brightnessChart.invalidate(); brightnessChartLayout.setVisibility(View.VISIBLE); }
Example 11
Source File: AudioFragment.java From walt with Apache License 2.0 | 5 votes |
private void drawWaveformChart() { final short[] wave = AudioTest.getRecordedWave(); List<Entry> entries = new ArrayList<>(); int frameRate = audioTest.getOptimalFrameRate(); for (int i = 0; i < wave.length; i++) { float timeStamp = (float) i / frameRate * 1000f; entries.add(new Entry(timeStamp, (float) wave[i])); } LineDataSet dataSet = new LineDataSet(entries, "Waveform"); dataSet.setColor(Color.BLACK); dataSet.setValueTextColor(Color.BLACK); dataSet.setCircleColor(ContextCompat.getColor(getContext(), R.color.DarkGreen)); dataSet.setCircleRadius(1.5f); dataSet.setCircleColorHole(Color.DKGRAY); LineData lineData = new LineData(dataSet); chart.setData(lineData); LimitLine line = new LimitLine(audioTest.getThreshold(), "Threshold"); line.setLineColor(Color.RED); line.setLabelPosition(LimitLine.LimitLabelPosition.LEFT_TOP); line.setLineWidth(2f); line.setTextColor(Color.DKGRAY); line.setTextSize(10f); chart.getAxisLeft().addLimitLine(line); final Description desc = new Description(); desc.setText("Wave [digital level -32768 to +32767] vs. Time [ms]"); desc.setTextSize(12f); chart.setDescription(desc); chart.getLegend().setEnabled(false); chart.invalidate(); chartLayout.setVisibility(View.VISIBLE); }
Example 12
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 13
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 14
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); }
Example 15
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(); }