Java Code Examples for com.github.mikephil.charting.data.BarDataSet#setDrawValues()
The following examples show how to use
com.github.mikephil.charting.data.BarDataSet#setDrawValues() .
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: ScrollViewActivity.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private void setData(int count) { ArrayList<BarEntry> values = new ArrayList<>(); for (int i = 0; i < count; i++) { float val = (float) (Math.random() * count) + 15; values.add(new BarEntry(i, (int) val)); } BarDataSet set = new BarDataSet(values, "Data Set"); set.setColors(ColorTemplate.VORDIPLOM_COLORS); set.setDrawValues(false); BarData data = new BarData(set); chart.setData(data); chart.invalidate(); chart.animateY(800); }
Example 2
Source File: ScrollViewActivity.java From Stayfit with Apache License 2.0 | 6 votes |
private void setData(int count) { ArrayList<BarEntry> yVals = new ArrayList<BarEntry>(); ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { float val = (float) (Math.random() * count) + 15; yVals.add(new BarEntry((int) val, i)); xVals.add((int) val + ""); } BarDataSet set = new BarDataSet(yVals, "Data Set"); set.setColors(ColorTemplate.VORDIPLOM_COLORS); set.setDrawValues(false); BarData data = new BarData(xVals, set); mChart.setData(data); mChart.invalidate(); mChart.animateY(800); }
Example 3
Source File: ProductDetailActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
public BarData getBarData() { ArrayList<BarEntry> entries = new ArrayList<>(); float overall_people = 100f; Log.d(TAG + "barData", barRatingCount[3] + ""); entries.add(new BarEntry(4, barRatingCount[4])); entries.add(new BarEntry(3, barRatingCount[3])); entries.add(new BarEntry(2, barRatingCount[2])); entries.add(new BarEntry(1, barRatingCount[1])); entries.add(new BarEntry(0, barRatingCount[0])); BarDataSet dataset = new BarDataSet(entries, ""); dataset.setColors(CUSTOM_COLOR); dataset.setDrawValues(false); ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); dataSets.add(dataset); BarData data = new BarData(dataSets); // data.setValueTextSize(10f); // data.setValueTypeface(fontType); data.setBarWidth(1f); return data; }
Example 4
Source File: GraphLayout.java From voice-pitch-analyzer with GNU Affero General Public License v3.0 | 6 votes |
/** * get bar chart data for male/female vocal ranges * to display them as bars beneath other chart data * * @param amount amount of entries needed * @return bar data to add to chart */ public static BarDataSet getOverallRange(Context context, int amount) { BarDataSet set = new BarDataSet(GraphLayout.getRangeEntries(amount), ""); set.setDrawValues(false); set.setColors(new int[]{context.getResources().getColor(R.color.male_range), context.getResources().getColor(R.color.androgynous_range), context.getResources().getColor(R.color.female_range)}); set.setStackLabels(new String[]{context.getResources().getString(R.string.male_range), context.getResources().getString(R.string.androgynous_range), context.getResources().getString(R.string.female_range) }); // List<BarDataSet> setList = new ArrayList<BarDataSet>(); // setList.add(set); // // return setList; return set; }
Example 5
Source File: CurrentDayFragment.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
/** * date: 2019/2/21 * author: chenli * description: 生成成交量数据集 */ private BarDataSet generateBarDataSet(List<BarEntry> entries, String label, boolean isHighlight, int... colors) { BarDataSet set = new BarDataSet(entries, label); set.setColors(colors); set.setBarBorderWidth(0); set.setDrawValues(false); set.setAxisDependency(YAxis.AxisDependency.LEFT); if (isHighlight) { set.setHighLightColor(mHighlightColor); } else { set.setHighlightEnabled(false); } return set; }
Example 6
Source File: KlineFragment.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
/** * date: 2019/2/22 * author: chenli * description: 生成成交量数据集 */ private BarDataSet generateBarDataSet(List<BarEntry> entries, String label, boolean isHighlight, int... colors) { BarDataSet set = new BarDataSet(entries, label); set.setColors(colors); set.setBarBorderWidth(0); set.setDrawValues(false); set.setAxisDependency(YAxis.AxisDependency.LEFT); if (isHighlight) { set.setHighLightColor(mHighlightColor); } else { set.setHighlightEnabled(false); } return set; }
Example 7
Source File: KLineDataManage.java From StockChart-MPAndroidChart with MIT License | 5 votes |
private BarDataSet setABar(ArrayList<BarEntry> barEntries, String label) { BarDataSet barDataSet = new BarDataSet(barEntries, label); barDataSet.setHighlightEnabled(true);//是否画高亮十字线 barDataSet.setHighLightColor(ContextCompat.getColor(mContext, R.color.highLight_Color));//高亮十字线颜色 barDataSet.setValueTextSize(10); barDataSet.setDrawValues(false);//是否画出每个蜡烛线的数值 barDataSet.setNeutralColor(ContextCompat.getColor(mContext, R.color.equal_color));//行情平势时蜡烛的标识颜色 barDataSet.setIncreasingColor(ContextCompat.getColor(mContext, R.color.up_color));//行情涨势时蜡烛的标识颜色 barDataSet.setDecreasingColor(ContextCompat.getColor(mContext, R.color.down_color));//行情跌势时蜡烛的标识颜色 barDataSet.setIncreasingPaintStyle(Paint.Style.FILL);//蜡烛实心或空心 barDataSet.setDecreasingPaintStyle(Paint.Style.FILL); return barDataSet; }
Example 8
Source File: TimeLineView.java From android-kline with Apache License 2.0 | 5 votes |
private BarDataSet setBar(ArrayList<BarEntry> barEntries, int type) { BarDataSet barDataSet = new BarDataSet(barEntries, "vol"); barDataSet.setHighLightAlpha(120); barDataSet.setHighLightColor(getResources().getColor(R.color.highlight_color)); barDataSet.setDrawValues(false); barDataSet.setVisible(type != INVISIABLE_LINE); barDataSet.setHighlightEnabled(type != INVISIABLE_LINE); barDataSet.setColors(getResources().getColor(R.color.increasing_color), getResources().getColor(R.color.decreasing_color)); return barDataSet; }
Example 9
Source File: KLineView.java From android-kline with Apache License 2.0 | 5 votes |
private BarDataSet setBar(ArrayList<BarEntry> barEntries, int type) { BarDataSet barDataSet = new BarDataSet(barEntries, "vol"); barDataSet.setHighLightAlpha(120); barDataSet.setHighLightColor(getResources().getColor(R.color.highlight_color)); barDataSet.setDrawValues(false); barDataSet.setVisible(type != INVISIABLE_LINE); barDataSet.setHighlightEnabled(type != INVISIABLE_LINE); barDataSet.setColors(getResources().getColor(R.color.increasing_color), getResources().getColor(R.color.decreasing_color)); return barDataSet; }
Example 10
Source File: StatActivity.java From ankihelper with GNU General Public License v3.0 | 5 votes |
private void drawHourChart(int[][] data){ // List<BarEntry> popupEntries = new ArrayList<>(); List<BarEntry> lookupEntries = new ArrayList<>(); List<BarEntry> cardaddEntries = new ArrayList<>(); for(int i = 0; i < 24; i ++){ // popupEntries.add(new BarEntry(i, data[0][i])); lookupEntries.add(new BarEntry(i, new float[] {data[1][i], data[2][i]})); } BarDataSet barDataSet = new BarDataSet(lookupEntries, "Bar"); barDataSet.setStackLabels(new String[]{"Lookups", "Cards"}); barDataSet.setDrawValues(false); barDataSet.setColors(DARK_PINK, DARK_GREEN); BarData barData = new BarData(barDataSet); mHourChart.setData(barData); mHourChart.getDescription().setText("hour"); //mHourChart.getDescription().setTextAlign(); mHourChart.getXAxis().setDrawGridLines(false); mHourChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM); mHourChart.getAxisRight().setEnabled(false); //mHourChart.getAxisLeft().setDrawGridLines(false); mHourChart.getXAxis().setValueFormatter( new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { return ((int) value) + ""; } } ); mHourChart.getXAxis().setLabelCount(24); mHourChart.getXAxis().setAxisMinimum(-0.5f); mHourChart.getXAxis().setAxisMaximum(23.5f); mHourChart.getLegend().setEnabled(false); mHourChart.invalidate(); }
Example 11
Source File: AnotherBarActivity.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tvX.setText("" + (mSeekBarX.getProgress() + 1)); tvY.setText("" + (mSeekBarY.getProgress())); ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>(); for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) { float mult = (mSeekBarY.getProgress() + 1); float val1 = (float) (Math.random() * mult) + mult / 3; yVals1.add(new BarEntry((int) val1, i)); } ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) { xVals.add((int) yVals1.get(i).getVal() + ""); } BarDataSet set1 = new BarDataSet(yVals1, "Data Set"); set1.setColors(ColorTemplate.VORDIPLOM_COLORS); set1.setDrawValues(false); ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); dataSets.add(set1); BarData data = new BarData(xVals, dataSets); mChart.setData(data); mChart.invalidate(); }
Example 12
Source File: StackedBarActivity.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.actionToggleValues: { List<IBarDataSet> sets = mChart.getData() .getDataSets(); for (IBarDataSet iSet : sets) { BarDataSet set = (BarDataSet) iSet; set.setDrawValues(!set.isDrawValuesEnabled()); } mChart.invalidate(); break; } case R.id.actionToggleHighlight: { if(mChart.getData() != null) { mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled()); mChart.invalidate(); } break; } case R.id.actionTogglePinch: { if (mChart.isPinchZoomEnabled()) mChart.setPinchZoom(false); else mChart.setPinchZoom(true); mChart.invalidate(); break; } case R.id.actionToggleAutoScaleMinMax: { mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled()); mChart.notifyDataSetChanged(); break; } case R.id.actionToggleHighlightArrow: { if (mChart.isDrawHighlightArrowEnabled()) mChart.setDrawHighlightArrow(false); else mChart.setDrawHighlightArrow(true); mChart.invalidate(); break; } case R.id.animateX: { mChart.animateX(3000); break; } case R.id.animateY: { mChart.animateY(3000); break; } case R.id.animateXY: { mChart.animateXY(3000, 3000); break; } case R.id.actionSave: { if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) { Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!", Toast.LENGTH_SHORT).show(); } else Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT).show(); break; } } return true; }
Example 13
Source File: StackedBarActivityNegative.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.actionToggleValues: { List<IBarDataSet> sets = mChart.getData() .getDataSets(); for (IBarDataSet iSet : sets) { BarDataSet set = (BarDataSet) iSet; set.setDrawValues(!set.isDrawValuesEnabled()); } mChart.invalidate(); break; } case R.id.actionToggleHighlight: { if(mChart.getData() != null) { mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled()); mChart.invalidate(); } break; } case R.id.actionTogglePinch: { if (mChart.isPinchZoomEnabled()) mChart.setPinchZoom(false); else mChart.setPinchZoom(true); mChart.invalidate(); break; } case R.id.actionToggleAutoScaleMinMax: { mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled()); mChart.notifyDataSetChanged(); break; } case R.id.actionToggleHighlightArrow: { if (mChart.isDrawHighlightArrowEnabled()) mChart.setDrawHighlightArrow(false); else mChart.setDrawHighlightArrow(true); mChart.invalidate(); break; } case R.id.animateX: { mChart.animateX(3000); break; } case R.id.animateY: { mChart.animateY(3000); break; } case R.id.animateXY: { mChart.animateXY(3000, 3000); break; } case R.id.actionSave: { if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) { Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!", Toast.LENGTH_SHORT).show(); } else Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT) .show(); break; } } return true; }
Example 14
Source File: CalibrationLinearityActivity.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
private void updateBarChart() { BarChart barChart = getBarChart(); if(barChart == null) { return; } if(freqLeqStats.size() <= 2) { return; } double[] pearsons = computePearson(); if(pearsons == null) { return; } float YMin = Float.MAX_VALUE; float YMax = Float.MIN_VALUE; ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>(); // Read all white noise values for indexing before usage ArrayList<BarEntry> yMeasure = new ArrayList<BarEntry>(); int idfreq = 0; for (double value : pearsons) { YMax = Math.max(YMax, (float)value); YMin = Math.min(YMin, (float)value); yMeasure.add(new BarEntry((float)value, idfreq++)); } BarDataSet freqSet = new BarDataSet(yMeasure, "Pearson's correlation"); freqSet.setColor(ColorTemplate.COLORFUL_COLORS[0]); freqSet.setValueTextColor(Color.WHITE); freqSet.setDrawValues(true); dataSets.add(freqSet); 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 BarData data = new BarData(xVals, dataSets); barChart.setData(data); YAxis yl = barChart.getAxisLeft(); yl.setAxisMinValue(YMin - 0.1f); yl.setAxisMaxValue(YMax + 0.1f); barChart.invalidate(); }