SVG-Sparkline

 view release on metacpan or  search on metacpan

lib/SVG/Sparkline/Cookbook.pod  view on Meta::CPAN

where you would like it to appear. Browsers that support <em>complex documents</em>
should display the SVG along with everything else.

=head3 I want to embed the sparkline in an SVG file.

You can copy the SVG directly from the sparkline into the SVG file. However, you
will need to make a minor change to the result. You either need to modify the
sparkline to position it in the SVG. There are basically 3 ways to accomplish this:

=over 4

=item Modify the sparkline C<svg> tag to have C<x> and C<y> attributes.

The C<x> and C<y> attributes are used to position a nested C<svg> tag within the
area of the outer C<svg> tag. By default, the sparkline's C<svg> tag would be
positioned at (0,0).

=item Modify the sparkline C<svg> tag to have a C<transform> attribute.

The C<transform> attribute can position a tag using the C<translate(x,y)>
function.  This would have the same effect as positioning the sparkline with
the C<x> and C<y> attributes. The only real reason for positioning this way is
if you wanted to provide scaling or rotation as well.

=item Surround the sparkline in a C<g> tag and position the group.

This approach has the advantage that you don't actually have to change the
sparkline.  Put the content of the sparkline inside a C<g> tag and use the
C<transform> attribute to place it.

   <g transform="translate(100,250)"><svg/></g>

where the C<< E<lt>svg/> >> is replaced with your actual sparkline.

=back

=head2 Decorations

=head3 How do I add a box around the sparkline?

As Tuft explains in I<Beautiful Evidence> this kind of decoration overwhelms the
actual data being displayed. That defeats the purpose of the sparkline. For this
reason, L<SVG::Sparkline> does not provide an automatic way to put a border
around the sparkline.

If you want to have a border despite Tuft's advice, you can use the border
attribute on the container you use for the SVG. For example, if you used the
C<iframe> approach from L</"I want to embed the sparkline in an HTML file.">

   <iframe height="12" width="36" src="rainfall_sparkline.svg"
       style="border:1 solid black;" alt="Rainfall amounts"></iframe>

Changing the border style should have the effect you want.

=head3 How do I add a grid under the sparkline?

The L<SVG::Sparkline> does not currently support grids. I am concerned that
adding a grid might also violate Tufte's intent for the sparkline.

At present, the best solution would be to generate a grid of the appropriate
dimensions and overlay it with the sparkline. This only works if the sparkline
has no background color, which leaves the background transparent.

=head1 AUTHOR

G. Wade Johnson  C<< <gwadej@cpan.org> >>

=head1 LICENCE AND COPYRIGHT

Copyright (c) 2015, G. Wade Johnson C<< <gwadej@cpan.org> >>. All rights reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl 5.8.0. See L<perlartistic>.

=head1 DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.



( run in 1.045 second using v1.01-cache-2.11-cpan-7fcb06a456a )