PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.64k stars 9.02k forks source link

How do I display the Legend into rows and columns as in the image, it always shows in a Horizontal or Vertical, which makes it difficult for me. #3944

Closed NDTChan closed 6 years ago

NDTChan commented 6 years ago

image

almic commented 6 years ago

Issue titles should be short, concise headlines. Perhaps just "Display Legend in rows and columns" would work fine. Also, you have a big box to write more detail, put your full question in that, not the title.

Anyway, currently this library only support displaying legends in a vertical or horizontal alignment. Sorry to say, but for now you'll need to pick one if you want to use the built-in legends.

HOWEVER! You are in luck!

Personally, I draw my own legends. I like to draw the labels in their color for the data they represent, so I just stuck a TextView on top of the chart (in the xml using android:translationZ="5dp"). Drawing your own legend gives you a lot more freedom. If you want to keep the same style that MPAndroidChart uses, you can use a RelativeLayout or something similar, set it's width and height to 1 or 2dp, and make it's background color the color of the data, then snap the TextView next to it.