Generate gif on the fly (up to 3 sec.) reading the data from a file. The file can be txt, csv etc.
#generate_gif.pl use strict; use GIFgraph::bars; use GD::Graph::colour; # the rgb.txt and data.data files must be in the same # directory as the generate_gif.pl is # # the data row from data.data file, must begin with a # tab, else the first element is ignore. :(( GD::Graph::colour::read_rgb("rgb.txt") or die "Cannot read colours from rgb.txt"; my $data_max; my @data = read_data_from_file("data.data") or die "Cannot read data from data.data"; my $my_graph = new GIFgraph::bars(800,600 ); $my_graph->set( x_label => 'Items', y_label => 'Data chart', title => 'Report Data', y_max_value => $data_max, y_tick_number => 10, y_label_skip => 2, long_ticks => 1, bar_spacing => 3, show_values => 1, legend_marker_width => 24, dclrs => [ qw( lightsteelblue limegreen blue red spr +inggreen2 yellowgreen springgreen orange) ], ); $my_graph->set_legend( 'Data1', 'Data2', 'Data3', 'Data4', 'Data5','Da +ta6','Data7', 'Data8' ); $my_graph->plot_to_gif( "Chart.gif", \@data ); exit; sub read_data_from_file { my $fn = shift; my @d = (); @d=$data_max; open(FH, $fn) || return (); while (<FH>) { chomp; my @row = split /\t/; for (my $i = 0; $i <= $#row; $i++) { undef $row[$i] if ($row[$i] eq 'undef'); push @{$d[$i]}, $row[$i]; } } close (FH); return @d; }

In reply to gif on the fly by marchitan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.