Show a Min Max Text in a MPGraph in Android - android

I am trying to show a min max values in a MP graph, so I have drawn a circles in a line graph. I want to show a Text as Min and Max at that point. How should I achieve it in android.
As shown in image above, I have two circles in the graph, These circles are the min and max value in a chart. But I also want a text with these circles as "Min" and "Max" in the graph

Take a look at this documentation to get an idea how to implement this feature on the YAxis.
Always 0 as min value use setStartAtZero(boolean enabled):
If the boolean is enabled, the axis will always have it's minimum value at zero, no matter which kind of data the chart displays.
Max and Min in value:
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.
Max and Min in percent:
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.

Related

MPAndroidChart - how to draw grid line for only max and min value in y axis(left axis)?

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

MPAndroidChart / CombinedChart - bar always starts at zero

I am using MPAndroidChart and I have a CombinedChart with several lines and one bar, and even my lines started to draw in negative numbers, the bar always start in zero.
How can I draw the barChart according the begin of the chart?
The bar cannot cover the area below zero because that just would not be correct behaviour of a barchart.
If you add an entry with value 30 on the y-axis, it should cover exactly a range of 30 on the y-axis, and not 30 + whatever space is left to the bottom. That is simply not correct.
In case you still want to have the bars to fill the whole screen, you can "cheat" and use stacked bars with 2 values. The first value represents the "starting point" of the bar, and the second value the actual value.
// e.g. -100 starting point, 30 actual value
// covered area is -100 to 30 on the y-axis
BarEntry stackedEntry = new BarEntry(new float[] {-100, 30}, xIndex);

MPAndroid candlestick combined with volume bar chart height issue

I need suggestion on how to limit the MpAndroid CandleStick chart combined with volume bar chart at the bottom so that volume bar max height can be limit to below 1/3 of chart area Yaxis . From the chart attached , this is somewhere Y Max at 3million region viewport in the left Axis. The current combined chart is ruin by the volume bar chart.
Thanks
setVisibleXRangeMaximum(float maxXRange): Sets the size of the area (range on the x-axis) that should be maximum visible at once. If this is e.g. set to 10, no more than 10 values on the x-axis can be viewed at once without scrolling.
setVisibleXRangeMinimum(float minXRange): Sets the size of the area (range on the x-axis) that should be minimum visible at once. If this is e.g. set to 10, it is not possible to zoom in further than 10 values on the x-axis.
setVisibleYRangeMaximum(float maxYRange, AxisDependency axis): Sets the size of the area (range on the y-axis) that should be maximum visible at once. You also need to provide the axis this constraint should apply to.
For more info Refer this
Thanks for your comment ,I do not think setting XrangeMax or Min will help , it only limit the x-axis down to certain visible display range instead of showing the full range of the dataset points . The chart shown above has about more than 4000 data points , I have narrowed the visible x-range using set chart.setVisibleXRangeMaximum(100) and also chart.moveViewToX(3000) to optimise performance. What I need is some functional procedure to set the max Y-axis (eg left Y-axis) at certain specific offset position , so that the lower portion of the chart could be restricted to the volume bar chart by clipping the specific rectangle viewports. I am not sure if that is possible , narrowing the YVsibleYrange is not what I have in mind. What I would like to have is
That is possible. All you need to do is plot the data against two different axes (as you are already doing), and then set the top space for each axis separately.
Customizing the axis range
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.
More information in the documentation.
To workaround , I have coded the Y axis to be at 1/x1 of Y viewport height to mark the volume bar top at YMAX in the multiple of x1 where x1 variable can be ={3, 4 or 5} float ymax=barDataSet.getYMax(); float ymaxd=(float)Math.floor (ymax*x1); leftAxis.setLabelCount(x1,false); leftAxis.setAxisMaxValue(ymaxd);

MPAndroidChart how to set y-axis min and max value or set default zoom?

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

How to set gridlines for every value on the Y-axis in achartengine?

I am using achartengine 1.0 and I am trying to set the gridlines for my LineChart.
The Y-axis has a min value of 1 and a max value of 7. I need the chart to display every step in this interval, so I added a label for 1, 2,3,... with
addYTextLabel();
Now I would like to display a gridline for every value on the Y-axis.
But when I add the grid for this axis, there are only 3 lins, at 2, 4 and 6.
How can I get the grid to show a line for all values?
best regards,
htz
with setYLabels() you can set the number of displayed labels for the Y axis. With a displayed label, there comes a gridline.

Categories

Resources