HumbleSoftware / Flotr2

Graphs and Charts for Canvas in JavaScript.
http://www.humblesoftware.com/flotr2/
MIT License
2.45k stars 528 forks source link

Add options to shift pie chart around #305

Open sambostock opened 9 years ago

sambostock commented 9 years ago

Add horizontalShift and verticalShift options for pie charts. These options accept either a number (in px), or a px or % string.

Numbers or px strings shift right for positive numbers, left for negatives.

% strings are converted to a px value equal to the percentage of the width or height.

Once values are in px, negative values shift the chart to the top/left; positive values shift the chart to the bottom/right.

The radius calculation has been updated to account for the shift. It computes the maximum radius possible which would not cause the chart to exceed the boundaries, then applies the sizeRatio to further scale the chart.

Further improvements could be made in drying up the code a little, but the function is all there.