I migrated from 2.2 to 3.0.0-beta1 and im having trouble showing the Legend of line chart.
when setting position to below chart, the legend is not showing. It seems that it is drawn outside the drawing area. when i set the position over the chart it is drawn inside the x axis labels. setting to setdrawinside(false) doesnt seem to make any difference.
the code i used for the legend is:
lineChart.getLegend().setEnabled(true);
lineChart.getLegend().setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
Version 2.2 didnt have this problem. The chart was drawn a bit higher so the legend could fit below the chart.
ps. Increasing the height of the chart doesnt fix the problem.
I am facing the same problem but when you rotate the screen it would show up..
After testing with the functions i managed to find a fix for problem. if change the Y offset of the legend and i managed to make the legend appear.
lineChart.getLegend().setYOffset(20);
I hope this will help everyone till auto offsets are fixed
I'm writing to help people that might encounter this error later on.
@dpartsalidis solution works on LegendPosition.BELOW_CHART_LEFT, but i couldn't fix it using the same technique with LegendPosition.ABOVE_CHART_LEFT. I ended up using v2.2.5 to fix the label position.
I didnt try it for LegendPosition.ABOVE_CHART_LEFT , i prefer to have the legend on top. I did some testing for LegendPosition.ABOVE_CHART_LEFT and i found that the legend is displayed in the X axis labels. To fix that i did the following and it seem to work
lineChart.getLegend().setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
lineChart.setExtraTopOffset(10);
i guess we got a temp fix for BELOW_CHART_LEFT and ABOVE_CHART_LEFT till the next version fixes the offsets
Most helpful comment
After testing with the functions i managed to find a fix for problem. if change the Y offset of the legend and i managed to make the legend appear.
lineChart.getLegend().setYOffset(20);I hope this will help everyone till auto offsets are fixed