hi, I would like to achieve the following using the bar chart. I went through the docs and I could not find an option to add x axis at the top of the bar chart and at the bottom of as well. So the dates would be at the bottom x axis and the day would be at the top. Is this possible at the moment?
Please let me know how I can achieve the following?

Thanks for your help! Really awesome library :)
Hey could someone help? Is this even possible?
No help?????
I have seen others asking the same thing a while back and it was said that it was not supported yet but it will be in the future. Could someone let me know if this is possible or not?
private XAxis xAxis = new XAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTH_SIDED);
this will give you x axis on both sides for customizing them you can try
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return ;
}
});
Hey I have the following code implemented for the XAxis:
IAxisValueFormatter xAxisFormatter = new DayAxisValueFormatter(barChart);
XAxis xAxisBottom = barChart.getXAxis();
xAxisBottom.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxisBottom.setTypeface(tf);
xAxisBottom.setDrawGridLines(false);
xAxisBottom.setGridColor(ContextCompat.getColor(activity, R.color.color_graph_grid));
xAxisBottom.setGridLineWidth(0.01f);
xAxisBottom.setGranularity(0.01f); // only intervals of 1 day
int size = new Float(entries.get(entries.size()-1).getX() - entries.get(0).getX()).intValue();
xAxisBottom.setLabelCount(size);
xAxisBottom.setAxisMinimum(entries.get(0).getX());
xAxisBottom.setDrawLabels(true);
xAxisBottom.setTextColor(ContextCompat.getColor(activity, R.color.color_graph_x_axis));
xAxisBottom.setTextSize(new Float(activity.getResources().getDimension(R.dimen.font_xxxxxsmall)));
xAxisBottom.setValueFormatter(xAxisFormatter);
xAxisBottom.setAxisLineColor(ContextCompat.getColor(activity, R.color.color_graph_grid));
I have a Custom class defined for IAxisValueFormatter. How would I implement separate IAxisValueFormatter for top & separate one for bottom?
I have the same question.
I am able to set X axis on top and bottom using XAxisPosition.BOTH_SIDED
But, is it possible to set different ValueFormatter, with different data, for each side?
That would be very useful.
I know it might be a bit late for you but I found a solution for this in case someone else needed to do it:
https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd
It renders bottom labels from the default valueformatter and top labels from custom formatter passed to the constructor. Use it like this:
chart.setXAxisRenderer(new DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(), chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return whateverYouWant
}
}));
@ezamelczyk , Showing error on screen in android studio, Can not resolve symbol "DoubleXLabelAxisRenderer" and "whateverYouWant"
Well because implementation of DoubleXLabelAxisRenderer is in the gist I've provided in my answer and "whateverYouWant" is exactly what it says. Whatever you want to be there. You must calculate the label yourself.
@ezamelczyk : Ok, thanks for your effort, Let me try this in My Code, I am looking for some requirement that matches this case.
Thanks.
@anitaa1990 design requests are rarely accepted, but I think this is something that should be added in some way. I'm adding this to the list.
I know it might be a bit late for you but I found a solution for this in case someone else needed to do it:
https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd
It renders bottom labels from the default valueformatter and top labels from custom formatter passed to the constructor. Use it like this:
chart.setXAxisRenderer(new DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(), chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { return whateverYouWant } }));
very smart!
I know it might be a bit late for you but I found a solution for this in case someone else needed to do it:
https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd
It renders bottom labels from the default valueformatter and top labels from custom formatter passed to the constructor. Use it like this:
chart.setXAxisRenderer(new DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(), chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter() { @Override public String getFormattedValue(float value, AxisBase axis) { return whateverYouWant } }));
For example, i have an arraylist label. How can i use it in this code
In place of "whateverYouWant" just fetch an item from your list depending
on the value.
niedz., 20 paź 2019, 13:45 użytkownik Tuan Dinh Minh <
[email protected]> napisał:
I know it might be a bit late for you but I found a solution for this in
case someone else needed to do it:https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd
It renders bottom labels from the default valueformatter and top labels
from custom formatter passed to the constructor. Use it like this:chart.setXAxisRenderer(new DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(), chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return whateverYouWant
}
}));For example, i have an arraylist label. How can i use it in this code
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/PhilJay/MPAndroidChart/issues/3536?email_source=notifications&email_token=ACHMYSNXEGA3ZBSLXQ2EYU3QPRAF5A5CNFSM4EBVJZJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYIIHI#issuecomment-544244765,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACHMYSPLJSPZ2CAQT2UW5TTQPRAF5ANCNFSM4EBVJZJQ
.
In place of "whateverYouWant" just fetch an item from your list depending on the value. niedz., 20 paź 2019, 13:45 użytkownik Tuan Dinh Minh < [email protected]> napisał:
…
I know it might be a bit late for you but I found a solution for this in case someone else needed to do it: https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd It renders bottom labels from the default valueformatter and top labels from custom formatter passed to the constructor. Use it like this: chart.setXAxisRenderer(new DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(), chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter() { @override public String getFormattedValue(float value, AxisBase axis) { return whateverYouWant } })); For example, i have an arraylist label. How can i use it in this code — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3536?email_source=notifications&email_token=ACHMYSNXEGA3ZBSLXQ2EYU3QPRAF5A5CNFSM4EBVJZJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYIIHI#issuecomment-544244765>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHMYSPLJSPZ2CAQT2UW5TTQPRAF5ANCNFSM4EBVJZJQ .
I have tried returning a value in my label list but nothing happen on my chart

Well GitHub issue is not a good place to discuss it. Please post your
question on stackoverflow and include your code. We'll figure it out from
there.
niedz., 20 paź 2019, 14:23 użytkownik Tuan Dinh Minh <
[email protected]> napisał:
In place of "whateverYouWant" just fetch an item from your list depending
on the value. niedz., 20 paź 2019, 13:45 użytkownik Tuan Dinh Minh <
[email protected]> napisał:
… <#m_-228851059372895287_>
I know it might be a bit late for you but I found a solution for this in
case someone else needed to do it:
https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd It
renders bottom labels from the default valueformatter and top labels from
custom formatter passed to the constructor. Use it like this:
chart.setXAxisRenderer(new
DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(),
chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter()
{ @override https://github.com/override public String
getFormattedValue(float value, AxisBase axis) { return whateverYouWant }
})); For example, i have an arraylist label. How can i use it in this code
— You are receiving this because you were mentioned. Reply to this email
directly, view it on GitHub <#3536
https://github.com/PhilJay/MPAndroidChart/issues/3536?email_source=notifications&email_token=ACHMYSNXEGA3ZBSLXQ2EYU3QPRAF5A5CNFSM4EBVJZJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYIIHI#issuecomment-544244765>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACHMYSPLJSPZ2CAQT2UW5TTQPRAF5ANCNFSM4EBVJZJQ
.I have tried returning a value in my label list but nothing happen on my
chart
[image: Screenshot_20191020_191809_com example datn_tuandm_1534560]
https://user-images.githubusercontent.com/33822487/67159433-dbbc1780-f36e-11e9-9948-fd5ac51bb919.jpg—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/PhilJay/MPAndroidChart/issues/3536?email_source=notifications&email_token=ACHMYSOECFUBDA2LTOBAR43QPRESVA5CNFSM4EBVJZJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYI4AQ#issuecomment-544247298,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACHMYSPG2GTI4PJVSX2JOOTQPRESVANCNFSM4EBVJZJQ
.
Well GitHub issue is not a good place to discuss it. Please post your question on stackoverflow and include your code. We'll figure it out from there. niedz., 20 paź 2019, 14:23 użytkownik Tuan Dinh Minh < [email protected]> napisał:
…
In place of "whateverYouWant" just fetch an item from your list depending on the value. niedz., 20 paź 2019, 13:45 użytkownik Tuan Dinh Minh < @.*> napisał: … <#m_-228851059372895287_> I know it might be a bit late for you but I found a solution for this in case someone else needed to do it: https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd It renders bottom labels from the default valueformatter and top labels from custom formatter passed to the constructor. Use it like this: chart.setXAxisRenderer(new DoubleXLabelAxisRenderer(chart.getViewPortHandler(), chart.getXAxis(), chart.getTransformer(YAxis.AxisDependency.LEFT), new IAxisValueFormatter() { @override https://github.com/override public String getFormattedValue(float value, AxisBase axis) { return whateverYouWant } })); For example, i have an arraylist label. How can i use it in this code — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3536 <#3536>?email_source=notifications&email_token=ACHMYSNXEGA3ZBSLXQ2EYU3QPRAF5A5CNFSM4EBVJZJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYIIHI#issuecomment-544244765>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHMYSPLJSPZ2CAQT2UW5TTQPRAF5ANCNFSM4EBVJZJQ . I have tried returning a value in my label list but nothing happen on my chart [image: Screenshot_20191020_191809_com example datn_tuandm_1534560] https://user-images.githubusercontent.com/33822487/67159433-dbbc1780-f36e-11e9-9948-fd5ac51bb919.jpg — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3536?email_source=notifications&email_token=ACHMYSOECFUBDA2LTOBAR43QPRESVA5CNFSM4EBVJZJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYI4AQ#issuecomment-544247298>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHMYSPG2GTI4PJVSX2JOOTQPRESVANCNFSM4EBVJZJQ .
Thank u so much for ur helps
@ezamelczyk Its not working for horizontal bar chart. please see this thread https://gist.github.com/ezamelczyk/4bd1f9a8abf1156dc62c4d00555f60cd and I am also not getting where to iterate the list for bottom axis and for top axis and what changes need to be done in your gist, please explain a bit more.
@suvDev Had the same problem as you. The code just copies just the logic from the XAxisRenderer class and renders different labels. For the horizontal use-case you can just extend from XAxisRendererHorizontalBarChart instead and modify the part in renderAxisLabels where the labels are drawn for the left and right side with your own label rendering function.
Here is my Gist: https://gist.github.com/Himbiss/293548d4c566c58a35917103b2b6a79e
Most helpful comment
I have the same question.
I am able to set X axis on top and bottom using XAxisPosition.BOTH_SIDED
But, is it possible to set different ValueFormatter, with different data, for each side?
That would be very useful.