Androidplot legend overlapping

2019-06-13 16:25发布

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

Can I manipulate the legend placement?

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-13 17:08

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);
查看更多
来,给爷笑一个
3楼-- · 2019-06-13 17:08

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.

查看更多
登录 后发表回答