contex icon indicating copy to clipboard operation
contex copied to clipboard

❓ [QUESTION] What is the best way to handle long text in legend?

Open enkr1 opened this issue 3 years ago • 7 comments

I have a long text for my legend and it shows up being cut. I was trying to play around with the :legend_setting like legend_setting: :legend_bottom but couldn't make it work except :legend_right ...

image

I am wondering if there are any other options or alternatives to solve long text in legend.

Thank you so much in advance. ❤️

Best regards, Jing Hui P.

enkr1 avatar Nov 24 '22 09:11 enkr1

Good question - looking through the legend code it appears there is a TODO for the :legend_top setting to work. I should have a chance early next week to put in the remaining legend options - there is nothing too difficult in there.

mindok avatar Nov 25 '22 04:11 mindok

Good question - looking through the legend code it appears there is a TODO for the :legend_top setting to work. I should have a chance early next week to put in the remaining legend options - there is nothing too difficult in there.

Thank you so much @mindok, will be waiting for your PR then! :D

enkr1 avatar Nov 25 '22 04:11 enkr1

Ok, turned out to be a bit more fiddly than I thought - changes aren't pushed yet, but it is looking like this: image

Currently there will be only :legend_top in addition to :legend_right, but things are now in place to add bottom & left. Also, there is strange behaviour if there isn't enough room to display the legend and plot content, but I won't address that yet. Finally, the legend isn't smart enough to put two entries on one line for the top legend.

mindok avatar Nov 29 '22 03:11 mindok

Ok, turned out to be a bit more fiddly than I thought - changes aren't pushed yet, but it is looking like this: image

Currently there will be only :legend_top in addition to :legend_right, but things are now in place to add bottom & left. Also, there is strange behaviour if there isn't enough room to display the legend and plot content, but I won't address that yet. Finally, the legend isn't smart enough to put two entries on one line for the top legend.

that's nice! I would be using the :legend_bottom (it would be bottom left right?) once u merge it.

enkr1 avatar Nov 29 '22 04:11 enkr1

:legend_bottom just committed. Pie charts with a title start looking slightly strange depending on the size of the SVG view - the title is placed at the middle of the calculated content area, but if height is a lot less than width, the content area is then shrunk in width. Anyway, a problem for another day!

You will need to point your reference to Contex in mix.exs to GitHub (e.g. {:contex, git: "https://github.com/mindok/contex"},) to take advantage of the changes until another release is made.

image

mindok avatar Nov 29 '22 05:11 mindok

PS - you will need to do mix deps.update contex after updating your mix.exs

mindok avatar Nov 29 '22 05:11 mindok

Hi @mindok, thank you so much last year for the speed response and fixes.

I have a request if there is any possibility that you can make it centre? image

Thank you so much!

enkr1 avatar Feb 08 '23 07:02 enkr1