Skip to content

Commit

Permalink
First attempt making dotted zero height bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
G. Wade Johnson committed May 2, 2009
1 parent d38dd3f commit a784ff0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion lib/SVG/Sparkline/RangeBar.pm
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion t/25.rangebar.t
Expand Up @@ -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>],
Expand Down

0 comments on commit a784ff0

Please sign in to comment.