Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: How to create a chart with data from database

by pvaldes (Chaplain)
on Jan 12, 2013 at 12:31 UTC ( #1013034=note: print w/replies, xml ) Need Help??

in reply to How to create a chart with data from database

I wonder why to use excel here.

The data are yet in the best place, a database.

You have the tool to retrieve the desired data from database to a perl "object". Easy to print and to manipulate.

And in cpan you will find many modules to make graphics without the need of excel.

If your goal is simply to create a lot of graphics you are using a lot of unnecesary extra space spend in (mostly unused) spreadsheets. Is this what you really want?.

Adapted from the documentation of the module Chart::Base:

use Chart::Bars; $g = Chart::Bars->new(600,500); # chart size $g->add_dataset ('Berlin', 'Paris', 'Rome', 'London', 'Munich'); # nam +e of the five items $g->add_dataset (10, 40, 60, 70, 12); # surface area $g->add_dataset (18, 20, 30, 30, 40); # population (Thousands) %hash = ('title' => 'Sold Cars in 2001', 'text_space' => 5, 'grey_background' => 'false', 'integer_ticks_only' => 'true', 'x_label' => 'City', 'y_label' => 'Number of Cars', 'legend' => 'bottom', 'legend_labels' => ['surface' , 'population'], 'min_val' => 0, 'max_val' => 70, 'grid_lines' =>'true', 'colors' => {'title' => 'red', 'x_label' => 'blue', 'y_label' => 'blue'} ); $g->set (%hash); $g->png ("bars.png"); # print chart to the file bars.png

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013034]
[atcroft]: PriNet: Those code bits worked for me, with test hashes, but I didn't test it with more than a few simple test cases. *shrug* Had hoped it would help, at least.
[PriNet]: i think i found the problem, the "source" array that sets the individual key values isn't being cleared, it's keeping the previous values...
[atcroft]: PriNet: You might consider posting a small, self-contained snippet of that segment of your code, and see if someone else has a better idea.....
[atcroft]: PriNet: Ahhh... interesting.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-06-28 03:12 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (619 votes). Check out past polls.