我正在使用achartengine渲染饼图,渲染的图表与图表一起在大屏幕设备上显示一条线。 (如5.5公司)。 该线条位于红色矩形中。 (我绘制矩形以指出不需要的线)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@drawable/item_selector_of_lists"
android:layout_margin="10dp">
<RelativeLayout
android:layout_width="60dp"
android:layout_height="60dp"
android:paddingTop="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/chart_layout"/>
<RelativeLayout
android:layout_width="60dp"
android:layout_height="60dp"
android:clickable="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center"
android:id="@+id/dummyLayout" >
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@drawable/ic_tic"
android:visibility="gone"
android:id="@+id/tick_image" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/helper"
android:layout_toRightOf="@+id/chart_layout"
android:layout_alignParentTop="true"
android:layout_alignBottom="@+id/chart_layout"
android:layout_toLeftOf="@+id/date_tv"
android:layout_toStartOf="@+id/date_tv"
android:gravity="center|left">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Large Text"
android:layout_gravity="center"
android:textColor="@android:color/black"
android:id="@+id/list_name"
android:gravity="center_vertical"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="@+id/date_tv"
android:textStyle="italic"
android:textColor="@color/gray"
android:layout_marginRight="10dp"
android:layout_alignBottom="@+id/helper"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Java Code Section:
private void initData(RelativeLayout chartLayout, double uncompleted, double completed) {
if (uncompleted == 0) {
completed = 1;
}
double[] values = {uncompleted,completed };
String[] colors = {//uncompleted, completed
"#82CA9C", "#F5F0ED"
};
CategorySeries series = new CategorySeries("");
int length = values.length;
for (int i = 0; i < length; i++) {
series.add(values[i]);
}
DefaultRenderer renderer = new DefaultRenderer();
for (int i = 0; i < length; i++) {
SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();
seriesRenderer.setColor(Color.parseColor(colors[i]));
renderer.addSeriesRenderer(seriesRenderer);
}
// renderer.setAxesColor(Color.TRANSPARENT);
// renderer.setBackgroundColor(Color.parseColor("#82CA9C"));
renderer.setLabelsColor(Color.TRANSPARENT);
drawChart(series, renderer, chartLayout);
}
private void drawChart(CategorySeries series,
DefaultRenderer renderer, RelativeLayout chartLayout) {
GraphicalView mGraphView = null;
mGraphView =
ChartFactory.getPieChartView(context, series, renderer);
chartLayout.addView(mGraphView);
}
答案 0 :(得分:0)
尝试在代码中添加renderer.setShowLabels(false);
和renderer.setShowLegend(false);
。这将隐藏图例和标签。您在代码中使颜色透明的标签,而不是完全隐藏它们。