Permalink
Browse files

First attempt making dotted zero height bar.

  • Loading branch information...
1 parent d38dd3f commit a784ff0ed52ff39ac747647baac19acfbd8a5adc G. Wade Johnson committed May 2, 2009
Showing with 14 additions and 2 deletions.
  1. +13 −1 lib/SVG/Sparkline/RangeBar.pm
  2. +1 −1 t/25.rangebar.t
@@ -56,7 +56,19 @@ sub make
# Move from previous x,y to low value
$path .= 'm'. _f($args->{thick}+$gap) .','. _f($yscale*($v->[0]-$prev));
my $vert = _f( $yscale * ($v->[1]-$v->[0]) );
- $path .= "v${vert}h$args->{thick}v". _f(-$vert)."h-$args->{thick}";
+ if($vert)
+ {
+ $path .= "v${vert}h$args->{thick}v". _f(-$vert)."h-$args->{thick}";
+ }
+ else
+ {
+ $path .= 'v-0.5';
+ foreach my $i (1 .. $args->{thick}-1)
+ {
+ $path .= 'h1v' . ($i%2? 1 :-1);
+ }
+ $path .= 'h1v'. ($args->{thick}%2?0.5: -0.5) . "h-$args->{thick}";
+ }
$prev = $v->[0];
}
$path = _clean_path( $path );
View
@@ -116,7 +116,7 @@ my $path = 'M0,-2v-2h3v2h-3m3,-1v-3h3v3h-3m3,2v-2h3v2h-3m3,-4v-5h3v5h-3m3,5v-6h3
{
my @values = ( [2,4], [3,6], [2,2], [5,10], [0,6] );
- my $path = 'M0,-2v-2h3v2h-3m3,-1v-3h3v3h-3m3,1v0h3v0h-3m3,-3v-5h3v5h-3m3,5v-6h3v6h-3';
+ my $path = 'M0,-2v-2h3v2h-3m3,-1v-3h3v3h-3m3,1v-0.5h1v1h1v-1h1v0.5h-3m3,-3v-5h3v5h-3m3,5v-6h3v6h-3';
my $rb = SVG::Sparkline->new( RangeBar => { -nodecl=>1, values=>\@values } );
is( "$rb",
qq[<svg height="12" viewBox="0 -11 15 12" width="15" xmlns="http://www.w3.org/2000/svg"><path d="$path" fill="#000" stroke="none" /></svg>],

0 comments on commit a784ff0

Please sign in to comment.