#! /usr/bin/perl -w
# vim:syntax=perl
use strict;

use lib '/usr/share/perl5';

use Lire::Program qw( :msg $PROG );
use Lire::ReportParser::ChartWriter;

use Getopt::Long;

my %opts = ( format	=> "png",
	     outputdir	=> ".",
	   );
GetOptions( \%opts, "format=s", "outputdir=s" ) && @ARGV == 0
  or lr_err( "Usage $PROG [--format png|jpg|eps|gif] [--outputdir dir ] < report.xml" );

lr_info( "will generate charts for each subreports with a charttype" );

my $parser = new Lire::ReportParser::ChartWriter( %opts );
eval {
    $parser->parse(\*STDIN);
};
lr_err( $@ ) if $@;
lr_info( "parsing xml finished" );

exit 0;

__END__

=pod

=head1 NAME

lr_xml2png - generate a PNG graph of a certain subreport

=head1 SYNOPSIS

B<lr_xml2png> B<[> I<options> B<]> I<file.xml>

=head1 OPTIONS

=item B<-s> I<subreport number>

select subreports to convert

=item B<-t> I<type>

type of chart to generate

=item B<-f> I<format>

output format (png or eps)

=head1 DESCRIPTION

B<lr_xml2png> reads a raw xml report from stdin, and generates a PNG image
of the data in a given subreport in the B<file.xml> document conform the
Lire DTD. The type of chart is set with the B<-t> option and can have
the values "pie", "bar" and "line".

The CPAN perl modules GD::Graph is used.

This script gets called by lr_xml2pdf(1) and lr_xml2html(1).

=head1 EXAMPLE

A raw xml report looks like e.g.

 <?xml version="1.0"?>
 <!DOCTYPE report SYSTEM "/usr/lib/xml/dtd/lire.dtd" []>
 <report date="Wed Mar 28 10:53:43 CEST 2001">
  <!-- generated by lr_dlf2xml(1) -->
  <timespan>Tue Mar 27 - Wed Mar 28</timespan>
  <subreport superservice="www" date="Wed Mar 28 2001">
    <title>requests per clienthost, top 10</title>
    <table>
      <entry>
        <value>301</value>
        <name>6.example.com</name>
      </entry>
      <entry>
        <value>20</value>
        <name>118.example.com</name>
      </entry>
    </table>
  </subreport>
  <subreport superservice="www" date="Wed Mar 28 2001">
    <title>requested pages, top 20</title>
    <table>
      <entry>
        <value>8</value>
        <name>/debian</name>
      </entry>
    </table>
  </subreport>
  <subreport superservice="www" date="Wed Mar 28 2001">
    <title>requested pages</title>
    <table>
      <group value="301">
        <title>6.example.com</title>
        <entry>
          <value>1</value>
          <name>/icons/92.example.com</name>
        </entry>
      </group>
    </table>
  </subreport>
 </report>
 
 
Lire's lr_dlf2xml(1) creates reports in this format. 
 
=head1 SEE ALSO
 
lr_dlf2xml(1), lr_log2report(1)
 
=head1 VERSION
 
$Id: lr_xml2png.in,v 1.19 2001/08/25 19:58:50 flacoste Exp $
 
=head1 COPYRIGHT
 
Copyright (C) 2000-2001 Stichting LogReport Foundation LogReport@LogReport.org
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
=head1 AUTHOR
 
Egon Willighagen
 
=cut

# Local Variables:
# mode: cperl
# End:
