I use MPAndroidChart to check the graph of the polonomial equation.
I want to get the maximum and minimum values in the graph obtained, but grid line of y axis(left axis) like this.Current Chart
Unlike the above figure, I would like to draw the y grid line of the graph as follows.The chart I want to get
Is there any way to display grid line of max and min value?
I tried to solve it using the setValueFormatter function, but I do not know how to approach it.
https://weeklycoding.com/mpandroidchart-documentation/axis-general/
You can use setShowOnlyMinMax(boolean enabled)
That is used to showing min / max label
Now i'm using MP android chart to show the kilowatt per hour data, this requirement need set the benchmark to 100 kwh, if the value is bigger than 100, the line will been draw above the benchmark, if the value is smaller than 100, of course it's below the benchmark.
I want to change the benchmark from 0 to 100 on y axis, but i didn't find any useful information from the doc. can someone give any advice on this?
This might help.
YAxis y = chart.getAxisLeft();
y.setAxisMaxValue(100);
y.setAxisMinValue(0);
Reference Documentation: https://github.com/PhilJay/MPAndroidChart/wiki/YAxis
Add Something LIke this
yAxis.setAxisMinValue(0);`
use same 100 as Maximum.Refer MPAndroid Documentation
I want to set a label in the x-axis for every y-value I have in my LineChart. I want to obtain this result:
Can someone help me in finding the correct way of doing this in MPAndroidChart?
You may be looking for granularity - see the wiki page for the axis and the javadoc.
Calling like this:
mChart.getXAxis().setGranularity(0.3f);
mChart.getXAxis().setGranularityEnabled(true);
will ensure that 0.3 is the minimum interval on the axis when you are zoomed in. Apart from that you may have to tweak the the scale of the x-axis by calling:
mChart.getXAxis().setAxisMinValue(10.01f); //experiment with these values
mChart.getXAxis().setAxisMaxValue(10.14f);
mChart.getXAxis().setLabelCount(5);
I use MPAndroidChart to display the stock chart, but the Y line value is so close,the chart is like this
I can use finger zoom like this way
Which is I want the default looks like
Is there any way to set Y line max and min value or set default zoom.
I tried the lib function , but it does not work
Take a look at the documentation of the YAxis. There are various methods that allow you to control the axis range.
setStartAtZero(boolean enabled): If this is enabled, this axis will always have it's minimum value at zero (0), no matter which kind of data the chart displays.
setAxisMaxValue(float max): Set a custom maximum value for this axis. If set, this value will not be calculated automatically depending on the provided data.
setAxisMinValue(float min): Set a custom minimum value for this axis. If set, this value will not be calculated automatically depending on the provided data.
setSpaceTop(float percent): Sets the top spacing (in percent of the total axis-range) of the highest value in the chart in comparison to the highest value on the axis.
setSpaceBottom(float percent): Sets the bottom spacing (in percent of the total axis-range) of the lowest value in the chart in comparison to the lowest value on the axis.
There is a kind of dependency between left and right axises. I had only right axis enabled and set
chart.getAxisRight().setStartAtZero(false);
but that didn't work till I set the same parameter to my leftYAxis, which was disabled. So I have now
chart.getAxisLeft().setStartAtZero(false);
chart.getAxisRight().setStartAtZero(false);
edit:
setStartAtZero is deprecated, the code recommends using setAxisMinimum instead.
* This method is deprecated.
* Use setAxisMinimum(...) / setAxisMaximum(...) instead.
You can find more on that in the documentation.
You can also use the
mChart.setVisibleYRangeMaximum(150, AxisDependency.LEFT);
method to set highest visible value on y axis.
use setScaleMinima()
and chart.moveViewToY(max), YAxis.AxisDependency.LEFT);
is the best solution.
please try this , i am not sure that what your want.when i face minim zoom level in MPAndroidChart i used this method like this,
mChart.setPinchZoom(true);
mChart.setScaleMinima(200,200); //for min and max value for zoom
i
Hope to be ok for your problem
None of the other answers worked for me (I'm not sure why). However, I made it work using:
ratingTracker.getAxisLeft().mAxisMaximum = max;
ratingTracker.getAxisLeft().mAxisMinimum = min;
Hope this works for you!
Mp Android Line chart in this fix the Y-Axis Minimum and maximum value so your graph line value start middle of the graph chart.
use this function so your problem will solve
yAxis.setAxisMinimum();
yAxis.setAxisMaximum();
in this code you can put any value you want and your graph Y-axis line
Minimum and Maximum value
Try below line of code :
YAxis yAxis = chart.getAxisLeft();
yAxis.setEnabled(false);
yAxis.setAxisMinimum(-400);
yAxis.setAxisMaximum(400);
I am making line chart using achartengine. I draw real time graph and values are updating with interval of 10 second. my Y axis is changing the scale which I do not want as my value will always from 10 to 180 so I want to have fixed y axis always. I am trying to make it work using this
renderer.setYAxisMin(10, 1);
renderer.setYAxisMax(180, 1);
In addition I want to reduce the space of my x -axis and screen bottom and border too.
Thanks
AchartEngine provides you api to set the range for Y axis and it is correct just you have to use it like this,
renderer.setYAxisMin(-125, 1);
renderer.setYAxisMax(-10, 1);
It is minor issue but takes time to recognize, I spent 15-30 mins to figure it out.
I hope I am not late