-1

I am using achartengine for rendering a pie chart, the chart rendered but together with chart a line seems on big screen devices. (like 5.5 inc). The line is in the red rectangle. (I draw the rectangle to point out unwanted line)

enter image description here

<?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);

    }
Cüneyt
  • 2,565
  • 25
  • 31
  • The LinearLayout which around textview make textview gravity center. Otherwise property gravity:"center" not working on some device like API LEVEL 18 – Cüneyt Oct 12 '15 at 11:02

1 Answers1

0

Try adding renderer.setShowLabels(false); and renderer.setShowLegend(false); to your code. This will hide the legend and labels. Labels you have made color transparent in your code, instead you may just hide them fully.

Alok Nair
  • 3,994
  • 3
  • 24
  • 30