без сенсорных меток оси x и меток оси y с количеством не изменяется в android для гистограммы с помощью MpAndroidChart - PullRequest
0 голосов
/ 17 апреля 2020

Привет в приведенном ниже коде. Dynami c Значения по оси X и по оси Y. На основе количества меток по оси X требуется изменить количество меток по оси Y. Без графика Ontouch не загружается.

Значения, которые нужно установить на основе меток оси x count.dynaимеально нужно проверить положение меток на оси x, а затем установить метки и числа на оси Y.

может мне помочь

if (name.equals("outcome")) {
                               outcome = String.valueOf(values);
                               outcome_list.add(outcome);

                               xAxis.setValueFormatter(new ValueFormatter() {
                                   @Override
                                   public String getFormattedValue(float value) {

                                       if (value < 0 || value > outcome_list.size() - 1) {
                                           return "";
                                       }
                                       String valueStr = String.valueOf(outcome_list);
                                       String[] outcomeList = valueStr.replace("[", "").replace("]", "").split(",");
                                       return outcomeList[(int) value];
                                   }
                               });
                               xAxis.setGranularity(1);
                               xAxis.setTextSize(10f);
                               xAxis.setLabelRotationAngle(-90f);
                               xAxis.setLabelCount(outcome_list.size());
                               xAxis.setGranularityEnabled(true);
                               String outcome1 = String.valueOf(values);
                               outcome_list1.add(outcome1);
                               Count_Followup = Collections.frequency(outcome_list1, "Follow-up");
                               System.out.println("Count of Followup is:  "+ Count_Followup);
                               Count_OrderClosed = Collections.frequency(outcome_list1, "Order Closed");
                               System.out.println("Count of OrderClosed is:  "+ Count_OrderClosed);
                               Count_Interested1 = Collections.frequency(outcome_list1, "Interested");
                               System.out.println("Count of Interested is:  "+ Count_Interested1);
                               Count_Done = Collections.frequency(outcome_list1, "Done");
                               System.out.println("Count of Done is:  "+ Count_Done);
                               Count_Collected = Collections.frequency(outcome_list1, "Collected");
                               System.out.println("Count of Collected is:  "+ Count_Collected);
                               Count_NotInterested = Collections.frequency(outcome_list1, "Not Interested");
                               System.out.println("Count of NotInterested is:  "+ Count_NotInterested);
                               float barSpace = 0f;
                               float barWidth = 0.7f;
                               ArrayList<BarEntry> values = new ArrayList<>();
                               values.add(new BarEntry(0, Count_Interested1));
                               values.add(new BarEntry(1, Count_Followup));
                               values.add(new BarEntry(2, Count_OrderClosed));
                               values.add(new BarEntry(3, Count_Done));
                               values.add(new BarEntry(4, Count_Collected));
                               values.add(new BarEntry(5, Count_NotInterested));
                               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, "Outcome");

                                   int endColor1 = ContextCompat.getColor(getContext(), R.color.linecolor);


                                   set1.setColors(endColor1);
                                   set1.setDrawIcons(false);

                                   dataSets = new ArrayList<>();
                                   dataSets.add(set1);
                                   MyDecimalValueFormatter formatter = new MyDecimalValueFormatter();
                                   BarData data = new BarData(dataSets);
                                   data.setValueTextSize(12f);
                                   data.setValueFormatter(formatter);
                                   data.setValueTypeface(tfLight);
                                   data.setBarWidth(barWidth);
                                   chart.setData(data);
                               }
                           }
...