How to make Grid Lines invisible in Android GraphView? - android

I just want to show only X Y axes and labels on these axes and don't want to show grid lines in Android GraphView. How can I do that?
Thanks in advance.

I believe the following call should do the trick :
your_graph.getGridLabelRenderer().setGridStyle( GridLabelRenderer.GridStyle.NONE );
Please do note I haven't tested the above call :)

If you use this all the grid lines will be Removed
your_graph.getGridLabelRenderer().setGridStyle( GridLabelRenderer.GridStyle.NONE );
For Setting Horizontal Line visible
your_graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.HORIZONTAL);
For Vertical Line visible
your_graph.getGridLabelRenderer().setGridStyle( GridLabelRenderer.GridStyle.VERTICAL);

The following code will remove the grid and then show the X and Y axis
graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE);
graph.getViewport().setDrawBorder(true);

Related

MPAndroidChart, The x-axis line and the grid line overlap?

so how to render only the x axis and not the grid line on top of that. As can be seen in the picture attached the I've set the width of the axis line to be 4 and the gridline width to be 2 .
So the black line shows up on white axis line. I want to just show the axis line. How do I do that.
As it's said in the docs, in order to not draw that gridlines you can try:
chart.getAxisLeft().setDrawGridLines(false)
chart.getAxisRight().setDrawGridLines(false)
Hope it helps :)

How to solve below chart problems with `MPChartAndroid`?

I have 3 issue related to MPChartAndroid.
How to make chart to see selected values.
1. Add space to the left of LeftAxis and to the right of rightAxis to fully see the values.
2. how to make first and last chart value to fully see the values.
3. Add space under xAxis to see the cut text.
To overcome issue with cutoff x-Axis label, you need to set some extra space on bottom of your chart view.
mLineChart.setExtraOffsets(left,top,right,bottom); try code below
mLineChart.setExtraOffsets(0,0,0,10);
For overcome issue with overlapping value on axis line you need to set some spacing (start position of lines) on x-Axis, try code below
xAxis.setSpaceMax(0.01f);
xAxis.setSpaceMin(0.01f);
also try xAxis.setAvoidFirstLastClipping(true);

MPAndroidChart Remove space when right axis is disabled

I use this code to hide right axis:
linechart.getAxisRight().setEnabled(false);
but it has a space like margin of chart (Line chart width is match_parent without margin)
Is there any way to remove this space and make the chart fill to the right edge of screen?
Actually, this space is better for keep. But if you really want to remove, I found this method that can help:
chart.setViewPortOffsets(leftOffset,topOffset,rightOffset,bottomOffset);
You can try this method by custom the view port to remove the blank space.
Firstly you disable the right axis by using
// Java
linechart.getAxisRight().setEnabled(false);
// Kotlin
linechart.axisRight.isEnabled = false
After disabling the right axis there will still be some blank space remaining. All the surrounding padding of the chart can be removed using:
// Java
linechart.setMinOffset(0f);
// Kotlin
linechart.minOffset = 0f
Please also make sure that you don't have any extra offset set by using one of these earlier:
// Kotlin
lineChart.extraLeftOffset
lineChart.extraTopOffset
lineChart.extraRightOffset
lineChart.extraBottomOffset

How to show grid for a custom x axis label: achartengine

I want a functionality where if user clicks on the the graph and if the x co ordinate is close to our point on XY line graph then I want to show a vertical grid for that point.
The only function that seems related is
mRenderer.setShowCustomTextGridY(boolean showGrid)
But for which value should the grid be shown is not clear in the documentation.
Please help. Which function should I use?
You need to use:
renderer.setShowCustomTextGrid(true);
Once you have the X axis value, you can add a custom text label this way:
renderer.addXTextLabel(x, "label");
Then, if you call a mChartView.repaint(), the custom text grid will be displayed.

How to add custom view at particular point in relative layout in android?

Hi am developing android application with graph view. i got an open source graph application to show my values with graph lines. Here i am face problem while adding view. i am not able to add my custom view properly with relative layout.
Here i attached my custom view alignment .
In that image point 1. is my result while trying to add mt custom view.
But i need to add that as shown in 2. part.
my custom view is like shown in 3 .part
I am getting that line starting x,y and ending x,y values. I tried with that values but i got result as 2 part. Please provide me any suggestion
Or let me know is there any alignments required.
My code is like
View View v1=infalter.inflate(R.layout.bullet, null);
RelativeLayout.LayoutParams rl=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rl.setMargins(myX,myY, 0, 0);
mRelative.addView(v1,rl);
You are setting the margins for the x, y point that you got, so the view will start at x, y at the top left, which is what you got. You want to align the bottom center of the view, so you need to calculate this.
So:
top= y - viewHeight
left= x - viewWidht/2
I don't know what your values of myX and myY are, but it looks like you're trying to align the top right with your x and y margins applied to the right and top respectively. If this is indeed the case, you're probably better off with something like this:
rl.setMargins(0, 0, myX, myY);
rl.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
The arguments to setMargins go in order as follows: left, top, right, bottom. If your myX value is the right margin and you want the object right aligned, the code above will specify these two preferences.
While playing with a relative layout to provide a help screen overlay I ran into weird things and had to set margins relative to the bottom right and not upper left. So I had a rule to align the view at the bottom and the right + the margins.
Maybe that will help.

Categories

Resources