Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: How to calculate the column and print it in pie chart format using perl?

by finddata (Sexton)
on Mar 22, 2017 at 05:35 UTC ( [id://1185406]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to calculate the column and print it in pie chart format using perl?
in thread How to calculate the column and print it in pie chart format using perl?

sub print_overall_summary { my $str = shift; $DBH = &connect or die "Cannot connect to the sql server \n"; $DBH->do("USE $str;"); my $stmt="select distinct * from summary order by time desc ;"; ; my $sth = $DBH->prepare( $stmt ); $sth->execute() or print "Could not in7sert_overall_summarydata"; print "<script language=\"javascript\" type=\"text/javascript\"> \ +n"; print "\$(document).ready(function(){ \n"; %TABLE_DATA =(); print "var data_running=[[\"Adice \($TABLE_DATA{1}{'ENTRY'}\)\",$TABLE +_DATA{5}{'ENTRY'}],\ [\"Incisive \($TABLE_DATA{1}{'ENTRY'}\)\",$TABLE_ +DATA{5}{'ENTRY'}],\ [\"Vcs \($TABLE_DATA{1}{'ENTRY'}\)\",$TABLE_DATA{ +5}{'ENTRY'}], \n"; print "var data_pending=[[\"Adice \($TABLE_DATA{1}{'ENT +RY'}\)\",$TABLE_DATA{4}{'ENTRY'}],\ [\"Incisive \($TABLE_DATA{1}{'ENTRY'}\)\",$TABLE_ +DATA{4}{'ENTRY'}],\ [\"Vcs \($TABLE_DATA{1}{'ENTRY'}\)\",$TABLE_DATA{ +4}{'ENTRY'}],\n"; + [download] print " \n + pieChart(\"placeholder39\",data_running,{title:\"<b><center>Jobs Run +ning</center></b>\"});\n"; print " \n pieChart(\"placeholder41\",data_pending,{title:\"<b>< +center>Jobs Pending</center></b>\"});\n"; [download] print " \n pieChart(\"placeholder30\",data_machine,{title:\"<b>< +center>Machine Status<center></b>\"});"; print " \n pieChart(\"placeholder29\",data_cpu,{title:\"<b><cent +er>CPU Slots</center></b>\"});\n"; print " \n pieChart(\"placeholder39\",data_running,{title:\"<b>< +center>Jobs Running</center></b>\"});\n"; print " \n pieChart(\"placeholder41\",data_pending,{title:\"<b>< +center>Jobs Pending</center></b>\"});\n"; print "});"; print "</script>"; }
  • Comment on Re^3: How to calculate the column and print it in pie chart format using perl?
  • Download Code

Replies are listed 'Best First'.
Re^4: How to calculate the column and print it in pie chart format using perl?
by huck (Prior) on Mar 22, 2017 at 06:01 UTC

    You didn not answer the question: Which javascript package do you expect to make the pie chart for you?

    You seem to be missing anything that gets the data, $sth->execute() does not return any data. you need something like my $table = $sth->fetchall_hashref; to actualy get the data. That returns an array reference such that $table->[0] has the first row of data and $table->[0]{queue_name} has the value of the queue_name column in the first row. That in no way matches your attempts to use something like $TABLE_DATA{1}{'ENTRY'} as a variable name where 1 is taken as a key to the hash %TABLE_DATA and ENTRY is taken as key to the hash %{$TABLE_DATA{1}}.

Re^4: How to calculate the column and print it in pie chart format using perl?
by Anonymous Monk on Mar 22, 2017 at 16:07 UTC
    This should be easy, first, rename the subroutine print_overall_summary to print_pie_chart and then just implement the new subroutine.

    Oh, by the way ... did you check the CPAN? SVG::TT::Graph::Pie.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found