youcef92 / flotr

Automatically exported from code.google.com/p/flotr
0 stars 0 forks source link

Support noColumns and more options for legend rendering with HtmlText=false (Patch Included) #163

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Currently, noColumns is not supported when HtmlText=false.

Also, the legend is rendered into the plot area, which can be a problem when 
you have multiple series, as the legend can cover up the data.

Note: all my changes are only effected when HtmlText=false.

I have made some modifications to allow noColumns with HtmlText=false and for 
placing the legend either on the canvas area or on the plot area.
If the legend is placed on the canvas area, then the plot area, titles, axis 
labels, etc. will be pushed to make room for the legend.
i.e. the legend is not rendered on top of the other stuff.

The noColumns will be reduced to the min(noColumns, noSeriesWithLabels).
It will also be reduced to make sure that all the legends are visible 
horizontally. i.e. if you specify 10 columns, and because of your text, only 8 
are visible, it will set noColumns to 8, thereby increasing the number of 
needed rows to show all labels.
If the rows are so numerous that it runs out of height, nothing special is 
done. It will clip like it does today.

Also, the legend can be placed in the following positions:
'n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'
north and south will be centered horizontally with respect to the plot area.
east and west will be centered vertically with respect to either the plot area 
or canvas area depending on the configuration of the 'location' legend config.

I added a new legend config: 'location' which is either 'canvas' or 'plot' 
(default 'plot').

If it is plot, it basically does what it does today plus supporting the 'n', 
's', 'e', 'w' positions and noColumns.

If it is canvas, it will render the legend with respect to the canvas and make 
room on the canvas where the legend should be rendered.
i.e. if the legend is positioned 's', then the bottom of the plot area will be 
pushed up.
if it is 'n' the title, subtitle, and plot area will be pushed down.

Currently, if it is location: 'canvas' and position: 'se', 'sw' ,etc. 
when the legend needs to grow, it will grow vertically (i.e. the east or west 
space will be reserved for the legend).

I have tested this in IE8, Firefox 3.6.13, and Chrome 8.0.552.224.

Attached is the patch that does all of this.

If you would like to discuss the patch in further detail. Add comments and I 
will respond.

Thanks,

Justin

Original issue reported on code.google.com by justin.f...@gmail.com on 15 Dec 2010 at 8:49

Attachments: