2014-12-22 4 views
1

안녕하세요, 저는 안드로이드 GraphView를 사용하여 막대 그래프가 있습니다. 이안드로이드 GraphView 가로 막 대형 차트

를 보여줍니다 그래서

try{ 
        JSONArray graphArray = returnGraphyArray(statistics); 
        if(graphArray != null){ 
         int graphLength = graphArray.length(); 
         GraphViewData[] calls = new GraphViewData[graphLength]; 
         GraphViewData[] length = new GraphViewData[graphLength]; 
         GraphViewData[] transfered = new GraphViewData[graphLength]; 

         for(int r = 0; r < graphLength; r++){ 
          JSONObject row = graphArray.getJSONObject(r); 
          calls[r] = new GraphViewData(r,Integer.parseInt(row.getJSONObject("data").getString("total_calls"))); 
          length[r] = new GraphViewData(r,Integer.parseInt(row.getJSONObject("data").getString("avg_call_length"))/60); 
          transfered[r] = new GraphViewData(r,Integer.parseInt(row.getJSONObject("data").getString("calls_transferred"))); 
         } 

         GraphViewSeries totalCallsSeries = new GraphViewSeries("Total Calls", new GraphViewSeriesStyle(getResources().getColor(R.color.pink), 5),calls); 
         GraphViewSeries totalCallLengthSeries = new GraphViewSeries("Total Call Length", new GraphViewSeriesStyle(getResources().getColor(R.color.green), 5),length); 
         GraphViewSeries totalCallsTransSeries = new GraphViewSeries("Calls Transfered", new GraphViewSeriesStyle(getResources().getColor(R.color.blue), 5),transfered); 

         BarGraphView graphView = new BarGraphView(context, ""); 
         graphView.addSeries(totalCallLengthSeries); 
         graphView.addSeries(totalCallsTransSeries); 
         graphView.addSeries(totalCallsSeries); // data 
         graphView.setHorizontalLabels(bottomlabels); 
         graphView.setShowLegend(false); 
         graphView.setLegendAlign(LegendAlign.TOP); 
         graphView.setLegendWidth(SM_Global.pxFromDp(context, 100)); 
         graphView.getGraphViewStyle().setNumHorizontalLabels(6); 
         layout.addView(graphView); 
        }else{ 
         layout.setVisibility(View.GONE); 
         ImageView legend = (ImageView)v.findViewById(R.id.graph_legend); 
         legend.setVisibility(View.GONE); 
        } 
SOFAR가 heres는 무엇 막대의 폭을 변경하는 방법이 내가 서로에 그것을하지만 현재 그리기 3 시리즈에 전달해야 3 시리즈를
+0

예, GraphView 4.0의 – appsthatmatter

답변

0

GraphView 웹 사이트 : "참고 : 현재 여러 개의 막대 차트를 그릴 수는 없습니다. 더 자세히 말하면 : 가능하지만 막대는 같은 위치에 렌더링되어 중복됩니다. . "

대신 AChartEngine을 사용하는 것이 좋습니다. 여기에 단지에 대한 링크가 https://code.google.com/p/achartengine/downloads/list

파일이고 여기에 하나 개의 막대 시리즈를 처리 할 수있는 예를 http://wptrafficanalyzer.in/blog/android-drawing-bar-chart-using-achartengine/