I have the problem, with MPAndroidChart BarChart, I want to display the x-axis values between the 2 lines not on the top of the line like this:
0,1,2, are months, so I wan't to write down the months between 0 and 1 for example, so the bar will be drown on the middle
Related
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
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);
I am using the MPAndroidChart library.
I have multiple scattercharts in a ListView.
Every chart contains 365 xvalues (every day of the year).
The yvalues vary from 1 to 5.
The height of the charts is 150dp.
I would like to be able to zoom in, so I can see every single day.
But when I zoom in, the yvalues get out of range of the chart.
Is there a way to keep the yvalues within range of the chart?
I tried it with the next settings:
holder.chart.setTouchEnabled(true);
holder.chart.setDragEnabled(true);
holder.chart.setScaleEnabled(false);
holder.chart.setScaleMinima(3f, 0f);
holder.chart.centerViewPort(xIndex, 3);
But when I drag from left to right or right to left, values just disappear from the chart, even when in range.
Has anyone any idea how to accomplish this?
This is your issue:
holder.chart.setScaleMinima(3f, 0f);
You are setting the scale value of the y-axis to zero. By doing that, you practically zoom out the chart into infinity. If you do not want to manipulate the zoom/scale of the y-axis, set the y-scale to 1f. Like this:
holder.chart.setScaleMinima(3f, 1f);
Try to invalidate the chart after centerViewPort, worked for me.
holder.chart.invalidate();
What i want is a line chart that on the x-axis goes from 0 to 15 and has vertical grid lines on every integer from 0 to 15. I don't want any labels or legends or titles.
Code snippet:
//don't want legend showing
mRenderer.setShowLegend(false);
//this is the only way i can force it to have grid lines every integer (note: if i make this number 14 then the graph puts only 8 labels ie 0, 2, 4, 6, 8, 10, 12, 14)
mRenderer.setXLabels(15);
//this removes all labels from y axis
mRenderer.setYLabels(0);
//i have to do this otherwise the setShowGridY statement is worthless
mRenderer.setShowLabels(true);
//i do want a grid on the y-plane (not x-plane)
mRenderer.setShowGridY(true);
//forces x axis to span from 0 to 15
mRenderer.setXAxisMax(15);
mRenderer.setXAxisMin(0);
What this code does is show grid lines and labels. I only want gridlines but if i do this:
mRenderer.setShowLabels(false);
then the labels dissapear as well as the gridlines.
It seems to me that you can only have gridlines if labels are enabled.
Can anyone help me with this?
Thanks,
Tim
Try renderer.setShowGrid(true) instead of setShowGridY(true)
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.