mpandroidchart

MpAndroidChart HorizontalBarChart Customize label

徘徊边缘 提交于 2019-12-04 07:08:28
问题 I want to add my bar values to the left of the bar and the bar labels to the right of the bar. Below is the code that initilizes HorizontalBarChart HorizontalBarChart mChart = (HorizontalBarChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); mChart.setDrawBarShadow(false); mChart.setDrawValueAboveBar(true); mChart.setDescription(strHeading); mChart.setMaxVisibleValueCount(60); mChart.setPinchZoom(false); mChart.setDrawGridBackground(false); XAxis xl = mChart

How to set labels and values in horizontal bar charts?

一笑奈何 提交于 2019-12-04 06:43:57
问题 I am using MPAndroidChart. Please check my below code activity_main.xml <?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/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity

MPAndroidChart: Hide 0 value labels in a stacked bar chart [closed]

江枫思渺然 提交于 2019-12-04 06:42:47
I am using MPAndroidChart to show a stacked bar chart containing two sets of data (Income and Expenditure). I'm having an issue when the value is 0 the label overlap other x axis values. In the case of the screenshot you can see that the bars which have values have overlapping values for the following dates: 14/4, 15/4 and 16/4. How can I hide the 0 values to stop the overlapping issue? Philipp Jahoda Use the IValueFormatter interface. Example: public class MyValueFormatter implements IValueFormatter { private DecimalFormat mFormat; public MyValueFormatter() { mFormat = new DecimalFormat("###,

how to remove lines if values is 0 % in pie chart

北城余情 提交于 2019-12-04 04:46:24
问题 I'm working on a pie chart, for that, i'm using MPAndroidChart library, the values may contain 0% for any data or more than one data and I'm displaying values outside of piechart using setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE) . I don't want to display 0% values in a pie chart, I got a solution for that to use value formatted. public class CustomPercentFormatter implements IValueFormatter { private DecimalFormat mFormat; public CustomPercentFormatter() { mFormat = new

MPAndroidChart BarChart horizontal / vertical

烂漫一生 提交于 2019-12-04 03:01:41
I am using the MPAndroidChart library. In BarChart by-default all the bars are vertical (bottom-up), how to display it in horizontally? There are two types of bar-charts in terms of orientation. The normal/vertical bar-chart (bars go bottom-up), class BarChart , looks e.g. like this: The horizontal bar-chart (bars go left-right), class HorizontalBarChart , looks like this: In addition to that, there are also so called stacked-bars (multiple values in a single bar), which can be used in both horizontal- and vertical BarChart . Entries for stacked bars can be created via constructor of the

MPAndroidChart: How to customise bar value labels

安稳与你 提交于 2019-12-04 01:18:41
问题 I am using MPAndroidChart in my Android app. I use a BarChart composed of BarEntry . I also enabled the y-values to be displayed on top of the bar. My issue is that I want the values on top of the bars to be whole numbers like 5 . But currently the values display as 5.00 . So how do I make 5.00 display as 5 ? 回答1: Values are formatted using the IValueFormatter interface. Here's a simple formatter that converts all values to integers: public class IntValueFormatter implements IValueFormatter {

How to set the x-axis label with MPAndroidChart

Deadly 提交于 2019-12-04 00:20:56
问题 I use MPAndroidChart for my app like this: but I can not add tag like that 回答1: Do you need your tag instead of those values ? If so, then here it goes the method to do so. Add your XAxis labels to an ArrayList final ArrayList<String> xLabel = new ArrayList<>(); xLabel.add("9"); xLabel.add("15"); xLabel.add("21"); xLabel.add("27"); xLabel.add("33"); // or use some other logic to save your data in list. For ex. for(i=1; i<50; i+=2) { xLabel.add(""+3*i); } then use this label in the

MPAndroidChart - First and last bars not rendering correctly

风流意气都作罢 提交于 2019-12-04 00:18:35
问题 In the bar chart I am creating the first and last rows are consistently being cut in half (even if I add additional bars). This also causes the values above the bars to be out of place. I am inflating this within a fragment. The axis are also only increasing by 0.9 instead of 1. To fix this do I need to implement the AxisValueFormatter interface? Image: Code: .java chart = (BarChart) view.findViewById(R.id.chart1); // Chart settings chart.setDrawGridBackground(false); chart

How to show labels on right and values to left side in HorizontalBarChart?

旧街凉风 提交于 2019-12-03 22:21:42
问题 Drawing a horizontal bar chart using MPAndroidChart 3.0.2. the values are shown on the right of the bars. I could use setValueFormatter and use IAxisValueFormatter interface to display the labels on the right. But the values are not displayed now. { HorizontalBarChart barChart = (HorizontalBarChart) itemView.findViewById(R.id.barChart); BarData data = new BarData(); ArrayList<BarEntry> valueSet1 = new ArrayList<>(); ArrayList<String> labels = new ArrayList<>(); labels.add("January"); labels

MpChart Draw icons as labels in Xaxis of bar chart

倖福魔咒の 提交于 2019-12-03 16:41:10
Hi I would like to draw icons in xaxis of the bar chart instead of values. Like the chart below you have to create your own custom renderer and apply it to your chart. Here's a rough implementation. XML <?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/activity_main" android:layout_width="match_parent" android:layout_height="250dp" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="