/** * Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries. * Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified * by the parameters. * Calls notifyDataSetChanged() afterwards. * * @param fromX the starting point on the x-axis where the grouping should begin * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f * @param barSpace the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f */ public void groupBars(float fromX, float groupSpace, float barSpace) { if (getBarData() == null) { throw new RuntimeException("You need to set data for the chart before grouping bars."); } else { getBarData().groupBars(fromX, groupSpace, barSpace); notifyDataSetChanged(); } } }
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tvX.setText(String.valueOf(seekBarX.getProgress())); tvY.setText(String.valueOf(seekBarY.getProgress())); ArrayList<BarEntry> values = new ArrayList<>(); for (int i = 0; i < seekBarX.getProgress(); i++) { float multi = (seekBarY.getProgress() + 1); float val = (float) (Math.random() * multi) + multi / 3; values.add(new BarEntry(i, val)); } BarDataSet set1; if (chart.getData() != null && chart.getData().getDataSetCount() > 0) { set1 = (BarDataSet) chart.getData().getDataSetByIndex(0); set1.setValues(values); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged(); } else { set1 = new BarDataSet(values, "Data Set"); set1.setColors(ColorTemplate.VORDIPLOM_COLORS); set1.setDrawValues(false); ArrayList<IBarDataSet> dataSets = new ArrayList<>(); dataSets.add(set1); BarData data = new BarData(dataSets); chart.setData(data); chart.setFitBars(true); } chart.invalidate(); }
set1.setValues(values); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged(); } else { set1 = new BarDataSet(values, "Statistics Vienna 2014");
set.setValues(values); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged(); } else { set = new BarDataSet(values, "Values");
private void setData(int count) { ArrayList<BarEntry> entries = new ArrayList<>(); for (int i = 0; i < count; i++) { entries.add(data.get(i)); } BarDataSet set; if (chart.getData() != null && chart.getData().getDataSetCount() > 0) { set = (BarDataSet) chart.getData().getDataSetByIndex(0); set.setValues(entries); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged(); } else { set = new BarDataSet(entries, "Sinus Function"); set.setColor(Color.rgb(240, 120, 124)); } BarData data = new BarData(set); data.setValueTextSize(10f); data.setValueTypeface(tfLight); data.setDrawValues(false); data.setBarWidth(0.8f); chart.setData(data); }
set4.setValues(values4); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged();
set1.setValues(values); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged();
chart.notifyDataSetChanged(); break;
chart.notifyDataSetChanged(); break;
chart.notifyDataSetChanged(); break;
chart.notifyDataSetChanged(); break;
chart.notifyDataSetChanged(); break;
public void setLegendEnabled(boolean enabled) { barChart.getLegend().setEnabled(enabled); barChart.notifyDataSetChanged(); barChart.invalidate(); }
/** * Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries. * Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified * by the parameters. * Calls notifyDataSetChanged() afterwards. * * @param fromX the starting point on the x-axis where the grouping should begin * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f * @param barSpace the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f */ public void groupBars(float fromX, float groupSpace, float barSpace) { if (getBarData() == null) { throw new RuntimeException("You need to set data for the chart before grouping bars."); } else { getBarData().groupBars(fromX, groupSpace, barSpace); notifyDataSetChanged(); } } }
/** * Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries. * Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified * by the parameters. * Calls notifyDataSetChanged() afterwards. * * @param fromX the starting point on the x-axis where the grouping should begin * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f * @param barSpace the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f */ public void groupBars(float fromX, float groupSpace, float barSpace) { if (getBarData() == null) { throw new RuntimeException("You need to set data for the chart before grouping bars."); } else { getBarData().groupBars(fromX, groupSpace, barSpace); notifyDataSetChanged(); } } }
/** * Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries. * Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified * by the parameters. * Calls notifyDataSetChanged() afterwards. * * @param fromX the starting point on the x-axis where the grouping should begin * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f * @param barSpace the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f */ public void groupBars(float fromX, float groupSpace, float barSpace) { if (getBarData() == null) { throw new RuntimeException("You need to set data for the chart before grouping bars."); } else { getBarData().groupBars(fromX, groupSpace, barSpace); notifyDataSetChanged(); } } }
/** * Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries. * Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified * by the parameters. * Calls notifyDataSetChanged() afterwards. * * @param fromX the starting point on the x-axis where the grouping should begin * @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f * @param barSpace the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f */ public void groupBars(float fromX, float groupSpace, float barSpace) { if (getBarData() == null) { throw new RuntimeException("You need to set data for the chart before grouping bars."); } else { getBarData().groupBars(fromX, groupSpace, barSpace); notifyDataSetChanged(); } } }
private void recalculateXAxis() { final XAxis xAxis = barChart.getXAxis(); xAxis.setAxisMinimum(0); xAxis.setAxisMaximum(histogramData.getNumBins()); barChart.notifyDataSetChanged(); barChart.invalidate(); }
private void setData(int count) { ArrayList<BarEntry> entries = new ArrayList<BarEntry>(); for (int i = 0; i < count; i++) { entries.add(mSinusData.get(i)); } BarDataSet set; if (mChart.getData() != null && mChart.getData().getDataSetCount() > 0) { set = (BarDataSet) mChart.getData().getDataSetByIndex(0); set.setValues(entries); mChart.getData().notifyDataChanged(); mChart.notifyDataSetChanged(); } else { set = new BarDataSet(entries, "Sinus Function"); set.setColor(Color.rgb(240, 120, 124)); } BarData data = new BarData(set); data.setValueTextSize(10f); data.setValueTypeface(mTfLight); data.setDrawValues(false); data.setBarWidth(0.8f); mChart.setData(data); } }
@Override public void onGetHistoryRecentTicketListSuccess(List<TicketOpenData> list) { bcAvgAnalysis = BarChartHelper.getBarChartHelper().generateBarChartConfig(bcAvgAnalysis); BarData barData; if (bcAvgAnalysis.getData() != null && bcAvgAnalysis.getData().getDataSetCount() > 0) { barData = bcAvgAnalysis.getBarData(); for (int i = 0; i < barData.getDataSetCount(); i++) { BarDataSet barDataSet = (BarDataSet) barData.getDataSetByIndex(i); barDataSet.setValues(generateEntry(list)); } bcAvgAnalysis.getData().notifyDataChanged(); bcAvgAnalysis.notifyDataSetChanged(); } else { List<Integer> colorList = new ArrayList<>(); colorList.add(getResources().getColor(R.color.main_red_color)); colorList.add(getResources().getColor(R.color.main_blue_color_4c65ed)); IBarDataSet barDataSet = BarChartHelper.getBarChartHelper().generateBarDataSet(generateEntry(list), new String[]{"普通码", "特别码"}, colorList); barData = new BarData(barDataSet); bcAvgAnalysis.setData(barData); bcAvgAnalysis.getXAxis().setValueFormatter((value, axis) -> (int) value + "号"); bcAvgAnalysis.setMarker(new DataMarkView(this, (e, highlight) -> ((int) e.getX()) + "号:" + e.getY() + "次")); } bcAvgAnalysis.animateY(3000); }