Androidplot legend overlapping

旧城冷巷雨未停 提交于 2019-12-08 09:41:52

问题


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

Can I manipulate the legend placement?


回答1:


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);



回答2:


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.



来源:https://stackoverflow.com/questions/10600178/androidplot-legend-overlapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!