세로 위치에 표시 될 때 정상적으로 보일 때 막대 차트가 나타납니다. renderer.setOrientation (Orientation.VERTICAL) 차트를 가로 모드로 표시하도록 동일한 차트를 설정하려면, 다음과 같이 보입니다. Android achartengine 가로 막대 차트가 압축 된 모양으로 표시됩니다.
위쪽과 아래쪽에서 압축되었습니다.
이 차트는 전체 화면의 약 0.3의 무게를 갖는 수직 LinearLayout에 추가되며,이 LinearLayout을 최대한 활용하기 위해 수평으로 만듭니다. 그러나 결과는 최적화되지 않습니다.
도와주세요. 이전에 이런 일을 봤어? 어떤 조언을 크게 주시면 감사하겠습니다.
I 차트 구성하는 데 사용되는 코드의 일부 :
renderer = new XYMultipleSeriesRenderer();
renderer.setShowLegend(false);
renderer.setMarginsColor(Color.WHITE); //does not support transparent
renderer.setOrientation(Orientation.VERTICAL); //horizontal bar-graph
renderer.setBarWidth(30f);
renderer.setMargins(new int[]{15, 0, 65, 0}); //top, left, bottom, right. Since its a horizontal bar graph, the margins has been rotated clock-wise
renderer.setYLabelsAlign(Align.RIGHT);
renderer.setXLabelsAlign(Align.RIGHT);
renderer.clearXTextLabels();
renderer.setYLabels(0); //remove units on the Y axis(the horizontal axis since the graph has been rotated 90 degree)
renderer.setXLabels(0); //removes 'values' from the X-Axis
renderer.addXTextLabel(0.92, "Average");
renderer.addXTextLabel(1.1, "Maximum");
renderer.setDisplayValues(true);
renderer.setLabelsColor(Color.BLACK);
renderer.setXLabelsColor(Color.BLACK);
renderer.setXLabelsAngle(0f);
renderer.setYAxisMin(0);
renderer.setXAxisMin(0);
renderer.setXAxisMax(2);
renderer.setPanEnabled(false, false);
renderer.setExternalZoomEnabled(false);
renderer.setZoomEnabled(false);
을 그리고있는 LinearLayout에 추가 :
LinearLayout barGraph1Layout = (LinearLayout) mainAct
.findViewById(R.id.bar_chart_layout);
barGraph1Layout.removeAllViews();
barGraph1Layout.addView(barChartView, new LayoutParams(
LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
을 그리고있는 LinearLayout :
<!-- PARENT LAYOUT -->
<LinearLayout
android:id="@+id/chart_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.85"
android:orientation="vertical"
android:visibility="invisible"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3" >
<TextView
android:id="@+id/GraphTitle1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
</TextView>
</LinearLayout>
<!-- HORIZONTAL BAR CHART LAYOUT -->
<LinearLayout
android:id="@+id/bar_chart_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:gravity="center"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1" >
</LinearLayout>
</LinearLayout>
<!-- OTHER LAYOUTS -->
수정 됨 : 스카우트 뷰로 차트 놓기
간단히 말해서, 여전히 동일하게 보입니다.
차트를 보유하기 위해 스크롤 뷰를 호스팅하고 renderer.setInScroll()을 true로 설정하고 LinearLayout.addView 섹션을 ScrollView.addView로 변경 한 LinearLayout을 수정했지만 차트는 여전히 정확하게 같은. 제 생각에는
수정 된 XML
<ScrollView
android:id="@+id/bar_chart_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
</ScrollView>
</LinearLayout>
당신은 무엇을하고 있는지 보여줄 수 있습니까? – keshav
예, 자세한 내용을 표시하도록 편집 됨 –
try dataRenderer.setOrientation (XYMultipleSeriesRenderer.Orientation.VERTICAL); – keshav