MPAndroidChart - Remove Y axes first vlaue - android

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.

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

MPChart: x axis couldn't display date completely

I have a problem using MPChart :
x axis couldn't display the first date,could someone help me?thanks!
You can use the setAvoidFirstLastClipping(Boolean) from your chart to avoid your first and last labels to be truncated.
From the doc:
setAvoidFirstLastClipping(boolean enabled): If set to true, the chart will avoid that the first and last axis label entry in the x-axis "clip" off the edge of the chart or the screen.

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

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

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.

How to stop scrolling of AChartEngine dynamic line graph along the y-axis?

I have set min max range for y-axis values but graph can scroll beyond those values which hampers the look and feel of graph. I wish to control/stop scrolling of graph along the y-axis. How can I do that?
What you need is specify which axis panning is available for: mRenderer.setPanEnabled(boolean enabledX, boolean enabledY)
Click here for more
use the following for locking both x and y axis scrolling, based on our need boolean values can be specified
render.setPanEnabled(false, false);
use setPanLimits method.
mRenderer.setPanLimits(new double[]{0,10,0,5});
this code will disable panning beyond 0 to the left,10 to the right on X axis,and beyond 0 down and 5 up on Y axis.

Categories

Resources