Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: How to create a chart with data from database

by terrykhatri531 (Novice)
on Jan 12, 2013 at 08:40 UTC ( #1013016=note: print w/ replies, xml ) Need Help??


in reply to Re: How to create a chart with data from database
in thread How to create a chart with data from database

Hi

First of all thank you very much, yes it does work very well and it does write the data into an excel spreadsheet, now I want to use columns Name, Surfacearea and Population into a chart to be created in the 2nd worksheet of the same excel file.

If you kindly get me going once I will be very grateful

Regards

Terry


Comment on Re^2: How to create a chart with data from database
Re^3: How to create a chart with data from database
by Anonymous Monk on Jan 12, 2013 at 08:56 UTC

      The sample script defines data for the cahrt as under

      # Add the worksheet data that the charts will refer to. my $headings = [ 'Category', 'Values 1', 'Values 2' ]; my $data = [ [ 2, 3, 4, 5, 6, 7 ], [ 1, 4, 5, 2, 1, 5 ], [ 3, 6, 7, 5, 4, 3 ], ]; $worksheet->write( 'A1', $headings, $bold ); $worksheet->write( 'A2', $data );

      Question

      How do I map my data that is retrieved from the database to the chart ?

      Regards

      Terry

        The sample script defines data for the cahrt as under

        You already have data from database, there is no more mapping left

        How do I map my data that is retrieved from the database to the chart ?

        Do you have microsoft excel installed? Have you ever created a chart using microsoft excel? Have you read http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm#Cell notation

        I suggest you drop what you're doing and create a chart using the GUI tools so you can see what is involved

        I don't have excel so I cant help

Re^3: How to create a chart with data from database
by terrykhatri531 (Novice) on Jan 12, 2013 at 20:33 UTC
    Ok, after studying how the examples work, I have figured out how to map data to the chart, here is the code for my case:
    $worksheet = $workbook->add_worksheet("Population Chart"); $worksheet->add_write_handler(qr[\w], \&store_string_widths); my $chart1 = $workbook->add_chart( type => 'bar', embedded => 1 ); # Configure the series. $chart1->add_series( categories => '=Summary!$A$2:$A$row', values => '=Summary!$G$2:$G$row', name => 'World Population', ); # Add another series. $chart1->add_series( categories => '=Summary!$A$2:$A$row', values => '=Summary!$F$2:$F$row', name => 'World Surface Area', ); # Add some labels. $chart1->set_title( name => 'Results of Population analysis' ); $chart1->set_x_axis( name => 'Countries' ); $chart1->set_y_axis( name => 'Population' ); # Insert the chart into the main worksheet. $worksheet->insert_chart( 'A2', $chart1 ); autofit_columns($worksheet);
    Thank you everyone for your help.

    Regards

    Terry

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2015-07-07 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls