MPAndroidChart: How do I remove gridlines? - android

In my LineChart beside the lines that are shown on the full numbers parallel to the x-axis, many horizontal gridlines are shown:
How can I get rid of these lines?

Those look like axis lines. You can toggle the axis lines by calling setDrawGridLines(false) on each Chart axis. For example, to clear all of them simply do something like this.
LineChart myChart = ...;
myChart.getXAxis().setDrawGridLines(false);
myChart.getAxisLeft().setDrawGridLines(false);
myChart.getAxisRight().setDrawGridLines(false);

Related

Add a vertical dash and dash line to a LineChart (mpandroidchart)

Label done with ValueFormatter.
LineChart with:
chart.xAxis.setDrawGridLinesBehindData(false)
Makes a line to the whole Y Axis.
I need something like that. I think I've tried everything.
You can use LimitLine and call enableDashedLine() to draw the vertical dashed line.

How to set padding between value labels and line for MPAndroidChart LineChart

When I create a line chart with values for each point, the values on the chart overlap the line, as shown in the screenshot. Is there a function to add padding to the values to raise them up so that this doesn't happen? I've looked all over the place for an answer to this or even someone else having the same issue and haven't found what I'm looking for.
My current chart:
I figured it out.
Based on this line in the source code:
int valOffset = (int) (dataSet.getCircleRadius() * 1.75f);
The padding is calculated based on the radius of the circle on the line, so my solution is to increase the size of the circle, set the outer radius to be transparent, and set the hole color to be the same as the line, which accomplishes what I want. This may not work for everyone, depending on what you're trying to do, but it worked in my case.

Ho to set MPAndroid piechart no lable

I'v used MPAndroid PieChart and want to show only percent values without labels. When I remove labels then colored guide below of chart also is without label. How to remove labels from pichart without removing guide labels?
set setDrawLabels(false) for the axis.
setDrawLabels(boolean enabled): Set this to true to enable drawing the labels of the axis.

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);

How to add extra labels at specified points in LineChart?

I would like to add some extra labels to a LineChart (MPAndroidChart) like in the image below. Notice the "Advanced", "Novice" etc labels.
How could I add those to specified y-axis positions so they will always show up like y-axis labels but perhaps on the inside of the graph as shown - or on the right side if necessary?
Update:
All I needed to get what I needed was some LimitLines like this:
LimitLine noviceline = new LimitLine( SSGlobals.getWeightinPreferredUnits_fromPounds(standardweightsarr[2]) , getString(R.string.novice));
noviceline.setLineColor(ContextCompat.getColor(getActivity(), R.color.accentline));
noviceline.setTextColor(ContextCompat.getColor(getActivity(), R.color.accentline));
noviceline.setTextSize(12);
noviceline.setLineWidth(4);
I might style it up a bit more but so far the result looks like so:
There are a couple of options here.
You can see if the LimitLines will fit your purpose - they are able to be configured with a label like this:
LimitLine llXAxis = new LimitLine(10f, "Index 10");
llXAxis.setLineWidth(4f);
llXAxis.enableDashedLine(10f, 10f, 0f);
llXAxis.setLabelPosition(LimitLabelPosition.RIGHT_BOTTOM);
llXAxis.setTextSize(10f);
xAxis.addLimitLine(llXAxis);
You could also use a FrameLayout with over the chart with TextViews for the extra info you want to add. See this
question for something similar and also this question for how to convert between chart values and on-screen pixel co-ordinates.
Alternatively, you can extend the renderer itself to draw your custom text. Please see How do MPAndroidChart renderers work and how do I write a custom renderer? if you wish to attempt that.

Categories

Resources