Changeset 387

Show
Ignore:
Timestamp:
11/23/07 17:54:27 (14 months ago)
Author:
latiass
Message:

Jesus Christ. Fixed a bug with SVG.pm that would cause the graph to be empty when 1 field had all of the data allocated to it. (part of #207, might be all SVG.pm needed)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Utils/SVG.pm

    r383 r387  
    126126         
    127127        $angle += $ratio * 2 * PI; 
     128        $angle /=2 if ($ratio == 1); #if angle is 360, make it 180 (see hack below) 
    128129        my $to_x = sprintf '%.3f', $center_x + $pie_radius * cos $angle; 
    129130        my $to_y = sprintf '%.3f', $center_y + $pie_radius * sin $angle; 
     
    134135        $svg .= qq[    <path d="]; 
    135136        $svg .= qq[ M$last_x $last_y ]; 
    136         $svg .= qq[ A$pie_radius $pie_radius 0 @{[ $ratio > 0.5 ? 1 : 0 ]} 1 $to_x $to_y ]; 
     137        # kind of hacky: if the angle is 360, draw 180 degrees of the circle, then draw the other 180 degrees 
     138        # breaks in firefox otherwise 
     139        if ($ratio == 1) { 
     140            $svg .= qq[ A$pie_radius $pie_radius 0 1,1 $to_x $to_y ]; 
     141            $svg .= qq[ A$pie_radius $pie_radius 0 1,1 $last_x $last_y ]; 
     142        } else { 
     143            $svg .= qq[ A$pie_radius $pie_radius 0 @{[ $ratio > 0.5 ? 1 : 0 ]},1 $to_x $to_y ]; 
     144        } 
    137145        $svg .= qq[ L$center_x $center_y ] unless ($ratio == 0 || $ratio == 1); 
    138146        $svg .= qq[ Z ]; 
     
    230238 
    231239        $angle += $ratio * 2 * PI; 
     240        $angle /=2 if ($ratio == 1); #if angle is 360, make it 180 (see hack below) 
    232241        my $to_x = sprintf '%.3f', $center_x + $pie_radius * cos $angle; 
    233242        my $to_y = sprintf '%.3f', $center_y + $pie_radius * sin $angle; 
     
    237246        $svg .= qq[    <path d="]; 
    238247        $svg .= qq[ M$last_x $last_y ]; 
    239         $svg .= qq[ A$pie_radius $pie_radius 0 @{[ $ratio > 0.5 ? 1 : 0 ]} 1 $to_x $to_y ]; 
     248        # kind of hacky: if the angle is 360, draw 180 degrees of the circle, then draw the other 180 degrees 
     249        # breaks in firefox otherwise 
     250        if ($ratio == 1) { 
     251            $svg .= qq[ A$pie_radius $pie_radius 0 1,1 $to_x $to_y ]; 
     252            $svg .= qq[ A$pie_radius $pie_radius 0 1,1 $last_x $last_y ]; 
     253        } else { 
     254            $svg .= qq[ A$pie_radius $pie_radius 0 @{[ $ratio > 0.5 ? 1 : 0 ]},1 $to_x $to_y ]; 
     255        } 
    240256        $svg .= qq[ L$center_x $center_y ]; 
    241257        $svg .= qq[ Z ];