Values under xAxis doesn't display in LineChart MPAdroidChart - android

I have created such chart, but problem is that values under xAxis doesn't displays fully, so there should be "2017-08-10", instead I see "20", If I zoom that chart, I can see all data under the xAxis. How to see all values?
I have also tried to change RotationAngle to 25 and 90, but still no results.
XAxis xAxis = chart.getXAxis();
xAxis.setValueFormatter(new MyXAxisValueFormatter(datesArray));
xAxis.setLabelRotationAngle(45);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
chart.getDescription().setEnabled(false);
I have also removed xAxis.setLabelRotationAngle(45);But, in that case dates overlap each other.

Set bottom padding to chart using setExtraOffsets like.
setExtraOffsets(float left, float top, float right, float bottom)

Related

bar line mpandroid chart

I have a chart and use mpandroidchart
the shape is as shown below
how can my line be neat and not too sideways?
If you are using version above 3 then you need to modify your xAxis as follows and last two lines of code will solve your issue:
// xAxis customization
XAxis xAxis = combinedChart.getXAxis();
// Following code have no effect but you can change it if required
xAxis.setGranularity(1f);
xAxis.setGranularityEnabled(true);
xAxis.setCenterAxisLabels(false);
xAxis.setDrawGridLines(false);
//xAxis.setXOffset(2);
// Setting maximum limit of xAxis
xAxis.setAxisMaximum(barData().getEntryCount());
// Setting position of xAxis
xAxis.setPosition(XAxis.XAxisPosition.BOTH_SIDED);
// This is used to fix bar width of first bar
**xAxis.setSpaceMin(barData().getBarWidth() / 2f);
xAxis.setSpaceMax(barData().getBarWidth() / 2f);**
I'm not sure but its worked for me.
This error comes from X Axis starting point.
Set starting point as 1.
xAxis.setAxisMinimum(1); // or xAxis.setAxisMinimum(2);

How to draw Range Chart MpAndroidChart with negative and positive value?

I'm using MPAndroidChart to draw Chart in my App. I have a problem when my Chart display data with value from negavite to positive.I reseached example of this lib by using BarChart but have not solution.
E.g. Column 1 will draw from -10 to 30. (has minValue and maxValue)
I don't know how to do that, BarChart is always draw from zero line.
I am setting like below:
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setAxisMaximum(100);
leftAxis.setAxisMinimum(-100);
float[] data = new float[]{-10f, 30f};
values.add(new BarEntry(1, data));
But have not effect. Please help me.
I want to draw chart like this image bellow:

MPAndroidchart : xaxis labels leaves more empty space at bottom

I want the xaxis labels to come down. Those large labels pushes the graph on top where i am not able to view the graph itself as shown in the figure given below. There is lot of space between the xaxis labels and legends(Legends not shown in figure below). I want to overcome this and view the chart. Find my code below
barChart.getAxisLeft().setAxisMinimum(-1.0f);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisRight().setEnabled(false);
barChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
barChart.getXAxis().setDrawGridLines(false);
barChart.getXAxis().setLabelRotationAngle(-90.0f);
barChart.getXAxis().setLabelCount(12);
barChart.getXAxis().setCenterAxisLabels(true);
barChart.getXAxis().setGranularityEnabled(true);
barChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(xAxisLabelList));
barChart.getXAxis().setAxisMaximum(12f);
barChart.groupBars(1f, 0.5f, 0f);
barChart.invalidate();
You can use barChart.setExtraBottomOffset(-10f); to reduce extra white-space below labels.
And increase your chart height in xml file.

How to hide graph bottom labels in HorizontalBarChart?

I'm trying to hide the bottom labels from the HorizontalBarChart graph (in black border) using MPAndroidChart.
I tried setDrawLabels(false) for XAxis, YAxis left, YAxis right with no success.
What parameter should i change and set to false to hide this line?
It work when i disable the axis right from my horizontal bar chart.
// Right Y Axis
YAxis yr = chart.getAxisRight();
yr.setEnabled(false);
// yr.setDrawGridLines(false);
// yr.setDrawAxisLine(false);
// yr.disableGridDashedLine();
Try:
XAxis xl = chart.getXAxis();
//This will stop the grid lines from being drawn
xl.setDrawGridLines(false);
//This Will stop the labels from being drawn
xl.setDrawLabels(false);

XAxis label angle in MPAndroidChart

I am using MPAndroidChart library for my project.
Is it possible to rotate the labels of the XAxis by 270 degrees so that I can fit more text?
Original answer:
Unfortunately it is currently not possible to rotate the values on the x-axis of a chart to a certain degree / angle.
You will have to implement such a feature yourself.
UPDATE:
As of v2.1.5 this feature is now available:
XAxis xAxis = chart.getXAxis();
xAxis.setLabelRotationAngle(...);
do it simply by
XAxis xAxis=barChart.getXAxis();
xAxis.setLabelRotationAngle(-45);

Categories

Resources