I'm using the great mpandroidchart libs for drawing various graph in our apps and first of all I'm deeply sorry if this question will be redundat or stupid.
Anyway, I have this BarChart which is drawing great except to the fact that i can't find a way to force the drawing of ALL XLabels. It just draw some of them and obviously if I pinch the view they are coming up but i would like to show them always, without the needs of zooming.
Hope is much clear. Thanks
Unfortunately there is no way to force draw all x-axis-labels. The chart will prevent overlapping labels from being drawn.
What you can do is reduce the space between the labels to the absolute minimum by calling:
XAxis xa = chart.getXAxis();
xa.setSpaceBetweenLabels(0); // space in characters
This will make sure the space between the labels is kept to a minimum. Default space between labels is 4 characters.
I know the question is a bit older... But the posted solution didn't work for me.
I used:
XAxis xa = chart.getXAxis();
xa.setLabelsToSkip(0);
And this worked perfectly! Hope it helps somebody ;)
Related
I am creating a line chart using MPAndroidChart, all is working great, but I've noticed that at the labels often become bunched up. I know there is a way to prevent this (I've seen other apps that don't have this issue,) but I don't know what setting to enable.
There are a couple of ways you could make the labels fit better.
Decrease the text size of the X axis labels with mChart.getXAxis().setTextSize(float)
Set a label count limit for the X axis using mChart.getXAxis().setLabelCount(int). This should work fine, as you are already not showing one label per data point.
Change the date format of your label.
Some, all or none of these might help you, depending on your requirements. Good luck!
I built a graph using MPAndroidChart, but there is a problem - values on x-axis overlap.
Is there a way to fix it? Something like a margin between x-axis values?
It's been a while since you've posted your question and probably by now you found your way around this problem, however, I'm posting this answer for anyone else who has faced this issue.
Setting
chart.getXAxis().setSpaceMin(0.5f);
would add space between the X-axis line and the chart itself. you can also use
chart.getXAxis().setSpaceMax(0.5f);
for adding space between the last value and the right X-axis of the chart.
Here is an example of a normal chart and this one is a chart
with min and max space of 1.5.
By the way, I'm using MPAndroidChart V3.0.2.
Try
XAxis xAxis = chart.getXAxis();
xAxis.setSpaceBetweenLabels(int characters) //Sets the space that should be left out between the x-axis labels in characters, default: 4.
I have about 12 domain labels in single graph. They overlap one another. I am not able to change their orientation. Please suggest a solution which will work with Android v2.2 and beyond.
Try this way,
plot.getGraphWidget().setDomainLabelOrientation(-45);
Here is the solution to rotate domain labels so that they don't overlap each others:
plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).setRotation(-45);
This works using the newer version of AndroidPlot (1.0 and above)
I realize you asked this quite awhile ago, but this might help someone out there.
You can create your own labels as seen here: AndroidPlot : setting the labels on the X-axis
Or if you want to just have less domain value, you can set the domain values by using this:
yourPlotName.setDomainStepValue(NumberOfValuesDesired);
On Androidplot my Axis Vals are cut off, so the last values are only shown half.
How to fix this issue?
In case the solution by Coretek doesn't work for you, as it did not for me, I found this solution to produce the desired output:
YOURPLOT.getGraphWidget().setGridPaddingRight(AmountOfSpaceDesired);
YOURPLOT.getGraphWidget().setGridPaddingTop(AmountOfSpaceDesired);
This will not just move your axis to no longer be cut off, but also your graph. I wanted a little extra space on the top where I previously had a point touching along with the right side where another point was touching.
I hope this can help someone as it has helped me.
dynamicPlot.getGraphWidget().setMarginTop(4);
dynamicPlot.getLegendWidget().setHeight(14);
Luckly I still found something in the androidplot forums cache.
I am using AndroidPlot and am having a problem with the chart. As my data grows, I would like the chart for older data to move beyond the screen area. Users can use scroll for viewing chart for older data. Can someone help me in achieving this?
I am not entirly clear what you mean but I think looking at the Multi-touch zoom and scroll example will probobly help.