MpAndroidChart Piechart传奇切割问题位于底部中心 [英] MpAndroidChart Piechart legends cutting issue at the bottom center
问题描述
我已附上使用情况图表的屏幕截图.在红色框中显示传奇人物,他们正在削减饼形图. 下面是我的代码:
I have attached the screenshot of my usage chart. In red box display the legends and they are cutting in pie chart. Below is my code:
pieChart.setUsePercentValues(false);
pieChart.getDescription().setEnabled(false);
pieChart.setDragDecelerationFrictionCoef(0.95f);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleColor(Color.WHITE);
pieChart.setTransparentCircleAlpha(110);
pieChart.setHoleRadius(55f);
pieChart.setTransparentCircleRadius(57f);
pieChart.setDrawCenterText(true);
pieChart.setRotationAngle(0);
// enable rotation of the chart by touch
pieChart.setRotationEnabled(true);
pieChart.setHighlightPerTapEnabled(true);
// add a selection listener
pieChart.setOnChartValueSelectedListener(this);
pieChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
Legend l = pieChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setForm(Legend.LegendForm.CIRCLE);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
l.setWordWrapEnabled(true);
l.setDrawInside(false);
l.getCalculatedLineSizes();
// entry label styling
pieChart.setEntryLabelColor(Color.WHITE);
pieChart.setEntryLabelTextSize(12f);
有人知道答案吗?请帮助我解决此问题.谢谢.
更新:
下面是我要显示图表的xml文件.
Below is my xml file to dispaly chart.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppTheme"
tools:context="com.visualogyx.app.activity.SettingsActivity$PlaceholderFragment">
<RelativeLayout
android:id="@+id/linear_change_usage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relative_text_dropdown_arraow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_grey">
<TextView
android:id="@+id/textview_usage_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginTop="16dp"
android:text="Tasks"
android:textColor="@color/black"
android:textSize="17sp" />
<ImageView
android:id="@+id/dropdown_arraow"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginRight="20dp"
android:layout_marginTop="16dp"
android:src="@drawable/ic_arrow_drop_down_black_24dp" />
</RelativeLayout>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relative_text_dropdown_arraow" />
</RelativeLayout>
<ProgressBar
android:id="@+id/display_chart_progress"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
问题 -每当我填充图形时,图形图例都会自动从底部裁剪.如果我将相同的图例放在中间,则工作正常,但问题仅在底部发生.
Issue - Whenever I populate the graph, the graph legends is automatically cropped from bottom. If i put the same legends in center then it is working fine but issue occurs in bottom only.
推荐答案
您是否尝试过使用xml属性android:translationY="-10dp"
进行自定义?
have you tried customizing with xml attribute android:translationY="-10dp"
?
或view.setExtraOffsets(...);
您可以相应地管理dp
.
更新
l.setYOffset(10f);
这篇关于MpAndroidChart Piechart传奇切割问题位于底部中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!