AChartEngine : Align Y-Axis Labels on right side of Axis itself - android

i am using aChartEngine for android. i have a problem with the y-axis, when the values reaches 10000 or more, the left digit is disappeared (Check the photo) in the photo the values are 7000-11500 but the values appearing above 10000 are 0000,0500, . . . etc
I would like to set the y-axis labels on the right side of the axis or something like that
can anyone help ?
knowing that i used
renderer.setYLabelsAlign(Align.RIGHT);

renderer.setYLabelsAngle(angle)
To view the Y axis date if the margins are fixed, so that the data will be displayed in tilted format,in which more characters will be seen.
Else the margins spacing have to be set for viewing the y axis labels.

You can tweak the margins of your chart:
renderer.setMargins(margins);
where margins is an array of [top, left, bottom, right]
If you want to set the alignment on the right side of the grid, just set Align.LEFT, which means they are align on the left.

multiRenderer.setYLabelsAlign(Paint.Align.RIGHT);
multiRenderer.setMargins(new int[]{0, 100, 0, 0});
multiRenderer.setYLabelsPadding(20);
Use Above code to align Y axis right with padding.

Related

MPAndroidChart: How to create dual axis?

I am using MPAndroidChart for drawing line chart.
I need to draw a Dual YAxis Line chart (i.e. with 2 Y Axis, one on left and other on right). But when I draw the graph it is being drawn from left. It takes into consideration the Left YAxis values rather than the Right YAxis values.
I am drawing Weights(kg) on right side and Heights(ft) on the left side.
As weights will be in terms of 40s, 50s etc and heights in terms of 5, 6 etc... The Line being drawn for Height takes left reference, which has 50s, 60s and hence never comes up.
Please let me know how to direct to draw considering the right Y Axis for Height rather than left Y Axis.
You can just use the setAxisDependency function in order to let a DataSet depend on a given axis. In your case it should be set to right:
LineDataSet set = new LineDataSet(data, "Your Label");
set.setAxisDependency(YAxis.AxisDependency.RIGHT); // plot this set against the right axis

MPAndroidChart - Remove Y axes first vlaue

I am using MPAndroidChart (Line chart). In that my y-Axes values are (0,10,20,30,40,50) vertically. I want to hide first value (here :0 is first value)?
In chart i have left Axes and Bottom Axes, both are containing 0 value at first position.
Y -axes(0,10,20,30,40,50)
X- axes(0,10,20,30,40,50)
at the bottom left corner two '0' are coming so i want to keep only single '0' for both X & Y Axes.
is there any possibility to do this?
You can try below code by which you can hide left axis.
LineChart chart_line;
chart_line.getLegend().setEnabled(false);
chart_line.getAxisLeft().setEnabled(false);
// dont forget to refresh the drawing
chart_line.invalidate();
But if you want to hide single value from array that not possible.
You need to remove that value from array.

How to Increase X or Y axis label sizes in AChartEngine in Android and Enable zoom

I have the whole line chart working. However the fonts are really small for the labels in x axis and y axis and also on the points where it is plotted. I've circled them in the picture in order to let you know what labels I am talking about.
Also I have disabled the zoom buttons, however we can still zoom using our fingers on the screen. When I zoom in the chart gets messed up. How do I not allow any kind of zooming?
You can set labels size in pixels for 2 axis together
renderer.setLabelsTextSize(float textSize)
Also you can set label color, align gor X and Y axis, for example:
renderer.setXLabelsColor(Color color);
renderer.setYLabelsAlign(Paint.Align.RIGHT);

Android achartengine text label margin and padding

Hi developers, I have a question: how can I make the gap between labels and bars smaller, I've tried setting the margin of XYMultipleSeriesRenderer to a different range(both positive and negative), but that doesn't affect the gap between labels and bars. And also passing negative value into renderer.setXLabelPadding() seems to be ignored - the text labels are on the X axis since the graph is rotated 90%
I am using achartengine 1.1.0, which should be the latest.
Here's a section of the code that I used to manipulate the apperance:
renderer.setOrientation(Orientation.VERTICAL); //horizontal bar-graph
renderer.clearXTextLabels();
renderer.setYLabels(0); //remove units on the Y axis(the horizontal axis since the graph has been rotated 90 degree)
renderer.setXLabels(0); //removes 'values' from the X-Axis
renderer.setMargins(new int[]{10, 0, 90, 0}); //top, left, bottom, right. Since its a horizontal bar graph, the margins has been rotated clock-wise. setting them to negative doesn't solve my problem.
renderer.addXTextLabel(0.9, "Average");
renderer.addXTextLabel(1.2, "Maximum");
renderer.setXLabelsPadding(-200f); //no effect
renderer.setYLabelsPadding(-200f); //no effect
try render.setBarSpacing(float); for spacing between bars. I used this and it worked.

AChartEngine Scroll Area

Is there any way to limit the scroll area of AChartEngine? I have a graph of stats for a team where the X-axis represents time and the Y-axis represents score and it doesn't make sense to have negative for either. I'd like to make it so that the farthest that the user can scroll down and to the left would put the origin in the bottom left corner of the screen. I appreciate any assistance.
Try using setPanLimits() method ..
double[] panLimits={0,10,0,50}; // [panMinimumX, panMaximumX, panMinimumY, panMaximumY]
mRenderer2.setPanLimits(panLimits);
where mRenderer2 is XYMultipleSeriesRenderer .

Categories

Resources