GraphView不绘制所有点

时间:2018-06-27 08:16:12

标签: android android-graphview

因此,我正在使用com.jjoe64.graphview.GraphView绘制图形。并且从我的API仅传递了最后6个值。但是问题是它没有绘制全部6个图,只绘制了4个点,我也不知道为什么。 下面的代码是我的Asynctask类中的onPostExecute方法中的一部分代码。

                    if (valuationList.size() >6){
                        valuationList = valuationList.subList(valuationList.size() -6,valuationList.size());
                       totalUnitPoint = new ArrayList<>(totalUnitPoint.subList(totalUnitPoint.size() - 6, totalUnitPoint.size()));
                       currentValuePoint = new ArrayList<>(currentValuePoint.subList(currentValuePoint.size() - 6, currentValuePoint.size()));
                    }
                    DataPoint [] cummuDataPointArr = totalUnitPoint.toArray(new DataPoint[totalUnitPoint.size()]);
                    LineGraphSeries<DataPoint> cummulativeSeries = new LineGraphSeries<>(cummuDataPointArr);

                    StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(cummulativeChart);
                    staticLabelsFormatter.setHorizontalLabels(valuationList.toArray(new String[valuationList.size()]));
                    //staticLabelsFormatter.setVerticalLabels(new String[] {"low", "middle", "high"});
                    cummulativeChart.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);

                    cummulativeChart.addSeries(cummulativeSeries);
                    cummulativeSeries.setColor(R.color.royal_blue);
                    cummulativeChart.setTitle("Units Acquired");
                    cummulativeChart.getGridLabelRenderer().setVerticalAxisTitle("Cummulative Units");
                    cummulativeChart.getGridLabelRenderer().setHorizontalAxisTitle("Months");

                    cummulativeSeries.setDrawDataPoints(true);
                    cummulativeSeries.setDataPointsRadius(10);
                    cummulativeSeries.setThickness(2);

                    DataPoint [] currentDataPointArr = currentValuePoint.toArray(new DataPoint[currentValuePoint.size()]);
                    LineGraphSeries<DataPoint> currentSeries = new LineGraphSeries<>(currentDataPointArr);

                    StaticLabelsFormatter currentFormatter = new StaticLabelsFormatter(currentChart);
                    currentFormatter.setHorizontalLabels(valuationList.toArray(new String[valuationList.size()]));
                    currentChart.getGridLabelRenderer().setLabelFormatter(currentFormatter);

                    currentChart.addSeries(currentSeries);
                    currentSeries.setColor(R.color.green);
                    currentChart.setTitle("RSA Balance (Naira)");
                    currentChart.getGridLabelRenderer().setVerticalAxisTitle("Current Value");
                    currentChart.getGridLabelRenderer().setHorizontalAxisTitle("Months");
                    currentSeries.setDrawDataPoints(true);
                    currentSeries.setDataPointsRadius(10);
                    currentSeries.setThickness(2);

请帮助我解决此问题This the current graph results am getting it only plots 4 out of 6 points.

0 个答案:

没有答案