0

What can I do to fix the legend overlapping in androidplot?

Can I manipulate the legend placement?

Nick
  • 8,181
  • 4
  • 38
  • 63
Arian
  • 3,183
  • 5
  • 30
  • 58
  • what do you need for a detail? the X-Axis legend is overlapping because the names are too many/long/whatever. – Arian May 15 '12 at 12:44

2 Answers2

3

You can use this to enlarge the legend:

myPlot.getLegendWidget().setSize(new SizeMetrics(15, SizeLayoutType.ABSOLUTE, 200, SizeLayoutType.ABSOLUTE));

15 is the height and 200 the width.
Change the legend position:

myPlot.position(
        myPlot.getLegendWidget(),
            0,
            XLayoutStyle.ABSOLUTE_FROM_RIGHT,
            0,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
            AnchorPosition.RIGHT_BOTTOM);

And reposition the domain label if you need to:

myPlot.position(myPlot.getDomainLabelWidget(),                     
            0,                                    
            XLayoutStyle.ABSOLUTE_FROM_LEFT,       
            15,                                     
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM,     
            AnchorPosition.LEFT_BOTTOM);
blackwolf
  • 927
  • 2
  • 11
  • 23
  • 1
    SizeMetrics is not available in android plot any more. I got this using "new Size(.. " instead of SizeMetrics. – shshnk Feb 23 '16 at 08:43
0

Some of the methods used in the above answer did not work for me. I guess things have changed in 4 years. Following code worked for me.

    dynamicPlot.getLegendWidget().setSize(new Size(25, SizeLayoutType.ABSOLUTE, 400, SizeLayoutType.ABSOLUTE));

    dynamicPlot.getLegendWidget().position(0,
            XLayoutStyle.ABSOLUTE_FROM_RIGHT,
            0,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
            AnchorPosition.RIGHT_BOTTOM);

    dynamicPlot.getDomainLabelWidget().position(0,
            XLayoutStyle.ABSOLUTE_FROM_LEFT,
            30,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
            AnchorPosition.LEFT_BOTTOM);`

change the layoutStyle and offsets as per your needs.

shshnk
  • 1,621
  • 14
  • 26