I am using MPAndroidChart library. Anybody has this problem? When I put the labels in BOTTOM position, these are cut.
Thank you
When you have a look at the Legend class you will notice that it has member variables for colors and labels. You can retrieve those arrays ( getColors (), getLegendLabels ()) and use them to be displayed in the ListView. Show activity on this post. Please look for the given answer MPAndroidChart - Legend labels are being cut off.
By default, all chart types support legends and will automatically generate and draw a legend after setting data for the chart. The Legend usually consists of multiple entries each represented by a label an a form/shape.
The number of entries the automatically generated legend contains depends on the number of different colors (across all DataSet objects) as well as on the DataSet labels. The labels of the Legend depend on the labels set for the used DataSet objects in the chart.
Option 1 - Increase height of chart control until all the labels fit in (make sure label texts are not too long else the height wont be able to fit in your screen size) Option 2 - try changing the XLabelAngle property to see if a different angle works better Option 3 - Change the size property of the chart to see if your labels fit it Regards,
This seems to be a new feature since June (2015):
chart.getLegend().setWordWrapEnabled(true);
Javadoc:
/** * Should the legend word wrap? / this is currently supported only for: * BelowChartLeft, BelowChartRight, BelowChartCenter. / note that word * wrapping a legend takes a toll on performance. / you may want to set * maxSizePercent when word wrapping, to set the point where the text wraps. * / default: false * * @param enabled */ public void setWordWrapEnabled(boolean enabled) { mWordWrapEnabled = enabled; }
They are cut because your text is too long and the library does not support "wrapping" of the labels to a new line.
You will either have to shorten your legend labels or implement the desired functionality yourself.
UPDATE:
Word wrapping for the Legend
is now supported.
chart.getLegend().setWordWrapEnabled(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With