Subject: | Pie graph incorrectly displays large (>50%) wedges |
SVG-TT-Graph 0.03
perl, v5.8.0 built for i386-linux-thread-multi
Linux zooter 2.4.19-16mdk
Adobe SVG Viewer 2.0
Pie chart elements greater than 50% of the pie are rendered in SVG with an incorrect 'large-arc-flag' in the arc.
I've attached a patch that works in the (few!) cases that I have at hand.
Problem first discovered with a pie chart with first value > 50%.
665,666c670,672
< <path d="M[% px_start + xe %] [% pmin_scale_value + ye %] A[% r %] [% r %], 0,
< [% IF degrees > 180 && py_end < y %]0[% ELSIF degrees > 180 %]1[% ELSE %]0[% END %], 1, [% x + px_end + xe %] [% y + py_end + ye %] L[% x + xe %] [% y + ye %], Z" class="fill[% count %]"/>
---
>
> <path d="M[% px_start + xe %] [% pmin_scale_value + ye %] A[% r %] [% r %], 0,
> [% IF percent >= 50 %]1[% ELSE %]0[% END %], 1, [% x + px_end + xe %] [% y + py_end + ye %] L[% x + xe %] [% y + ye %], Z" class="fill[% count %]"/>
671,675c677,681
< [% re = r / e %]
< [% xe = re * cos(radians_half) FILTER format('%02.10f') %]
< [% ye = re * sin(radians_half) FILTER format('%02.10f') %]
< <path d="M[% px_start + xe %] [% pmin_scale_value + ye %] A[% r %] [% r %], 0,
< [% IF degrees > 180 && py_end < y %]0[% ELSIF degrees > 180 %]1[% ELSE %]0[% END %], 1, [% x + px_end + xe %] [% y + py_end + ye %] L[% x + xe %] [% y + ye %], Z" class="fill[% count %]"/>
---
> [% re = r / e %]
> [% xe = re * cos(radians_half) FILTER format('%02.10f') %]
> [% ye = re * sin(radians_half) FILTER format('%02.10f') %]
> <path d="M[% px_start + xe %] [% pmin_scale_value + ye %] A[% r %] [% r %], 0,
> [% IF percent >= 50 %]1[% ELSE %]0[% END %], 1, [% x + px_end + xe %] [% y + py_end + ye %] L[% x + xe %] [% y + ye %], Z" class="fill[% count %]"/>
678c684
< [% IF degrees > 180 && py_end < y %]0[% ELSIF degrees > 180 %]1[% ELSE %]0[% END %], 1, [% x + px_end %] [% y + py_end %] L[% x %] [% y %], Z" class="fill[% count %]"/>
---
> [% IF percent >= 50 %]1[% ELSE %]0[% END %], 1, [% x + px_end %] [% y + py_end %] L[% x %] [% y %], Z" class="fill[% count %]"/>
681a688
> <!-- degrees [% degrees %] -->
683c690
< [% IF degrees > 180 && py_end < y %]0[% ELSIF degrees > 180 %]1[% ELSE %]0[% END %], 1, [% x + px_end %] [% y + py_end %] L[% x %] [% y %], Z" class="fill[% count %]"/>
---
> [% IF percent >= 50 %]1[% ELSE %]0[% END %], 1, [% x + px_end %] [% y + py_end %] L[% x %] [% y %], Z" class="fill[% count %]"/>