错误显示GraphView(android)

时间:2015-02-26 11:19:53

标签: java android android-graphview

抱歉我的英文。我不知道为什么我没有正确显示消息GraphView。现在在下面的图表中不断显示1,1,1,1 ......虽然会有1,2,3,4 ......并且评价都是1. A将图表显示为10.为什么会这样,请告诉我

enter image description here

GraphViewSeriesStyle seriesStyle = new GraphViewSeriesStyle();

         BarGraphView graphView = new BarGraphView(this, "test");

         //Our vertical graph
         graphView.setVerticalLabels(new String[] { "10", "9", "8", "7", "6",
                    "5", "4", "3", "2", "1" });

         //listMarks its ArrayList whith Marks
         String[] array = new String[ listMarks.size() ];

         //add marks in array
         for(int i = 0; i < listMarks.size(); i++) {
             array[i] = "1";
         }

        graphView.setHorizontalLabels(array); 

         seriesStyle.setValueDependentColor(new ValueDependentColor() {
             @Override
             public int get(GraphViewDataInterface data) {
                  return Color.rgb((int)(22+((data.getY()/3))), (int)(160-((data.getY()/3))), (int)(134-((data.getY()/3))));
             }
         });


        GraphViewData[] data = new GraphViewData[array.length];

        for (int a = 0; a < array.length; a++) {
            data[a] = new GraphView.GraphViewData(a, Double.parseDouble(array[a]));
        }

        GraphViewSeries series = new GraphViewSeries("aaa", seriesStyle, data);

        graphView.setManualYMinBound(0);
        graphView.addSeries(series);
        LinearLayout layout = (LinearLayout) findViewById(R.id.subLayout);
        layout.addView(graphView);

1 个答案:

答案 0 :(得分:0)

变化:

array[i] = "1";

为:

array[i] = ""+i;

在以下循环中“

//add marks in array
         for(int i = 0; i < listMarks.size(); i++) {
             array[i] = "1";
         }