I'm using GraphView to draw graphs in my android app, but I'm not able to set axis labels on the X and Y axis which denote what they represent. I checked the documentation, but couldn't find anything useful. How can I do it?
you're right. there is no build in method to do it. You have to place your label views yourself at the left resp. bottom of the graphview. This can be done for example with RelativeLayout.
Related
I ma using MPAndroidChart bubble chart. when I run the app it shows x axis values hidden. like I have x-axis label January, February, march, April, may,june. but when app run it shows January , April
and June. on double tape on label it zoom the chart and show hidden labels. I want to show all in a sequence so that user troll horizontal and view all. no need to double tap
You can determinate the numbers of labels to display. This prevents them from hiding automatically.
XAxis xAxis = bubbleChart.getXAxis();
xAxis.setLabelCount(data.length);
Not sure why would you do that. The library does a great job in automatically deciding how many labels to show on either X or Y axis to make the chart nice and readable.
If the chart is narrow, it might happen that your values will overlap, that's why the library skips a few, to make the chart look good.
If that still doesn't help, you can play around with the spacings between axis labels - check out the library's documentation for these specific items
Other solution may be to rotate the labels of the X axis with the help of
xAxis.setLabelRotationAngle(35);
I found the solution after expanding MP Android Chart documentation.
you can do so set thee labels to skip 0. It will skip no label from xAxis.
XAxis xAxis = bubbleChart.getXAxis();
xAxis.setLabelsToSkip(0);
I am working and android chart library using MPAndroidChart .
I am using HorizontalBarChart to display chart.
Please see the attached image and I want do decrease x axis width or want to display x axis text in two lines is there any way to this ?
Any help will get appreciate.
There is currently no way to draw the x-axis labels in multiple lines.
What you can do to decrease the space the labels consume is to simply provide shorter labels. A axis label of the length you are showing above is too long for a chart to be easily readable anyway.
I'm having trouble getting AChartEngine to center the actual visible axises on Origo instead of having them along the left- and bottom of the chart.
I need to have the axises like so:
Any ideas?
(This question is similar to question #2 [2]: Make x-axis in vertical center using AChartEngine but I thought that a more specific question might get an answer)
I made some modifications to AChartEngine 1.0.0 to make it possible to display axises in the center of the plot.
Use code below to set the axises to center.
XYMultipleSeriesRenderer.setXAxisAlign(Align.CENTER, 0);
XYMultipleSeriesRenderer.setYAxisAlign(Align.CENTER, 0);
XYMultipleSeriesRenderer.patch
XYChart.patch
And here is an example on how it may look
There isn't a better answer than the one you mentioned. Just make sure that you calculate X and Y ranges such as your data fits inside and also make sure that the range you set is centered on the 0 point:
renderer.setXAxisMin(-value);
randerer.setXAxisMax(value);
and the same for the Y axis.
I'm using achartengine to show a temperature graph. on X axis I put dates, to fit them I call setXLabelsAngle(45); this is the result:
As you can see, the labels are placed too high and go over the x-Axis. How could I fix this? I'm already using setMargins(), but labels don't move, only legend does.
This will help:
renderer.setXLabelsAlign(Align.LEFT);
I am able to display the AChartEngine's TimeChartView to user, but when the graph renders, the grid lines (vertical - set by showGridLines(true)) and the line drawn on graph to display corresponding y-axis value (time in secs) against the dates on x-axis don't intersect with each other.
The y-axis value pt shows up either before the x-axis value or after it, but not exactly on it.
Please suggest, if there's any achartengine property which needs to be set to get this done / any other thing that needs to be done for getting this done.
Thanks
Omkar Ghaisas
Sample Image --
As can be seen, the points marked with ovals don't coincide with the vertical grid lines and with x axis values, but start before that. E.g the first y value for 7200 should start at vertical line of 02/03/2012, but instead starts before that. Similarly for all other data points.
This was fixed in the AChartEngine SVN.
Please see this for extra information.