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