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

Re^5: Unable to create a Pivot chart with visiable Columns

by poj (Abbot)
on Sep 10, 2018 at 20:51 UTC ( [id://1222086]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Unable to create a Pivot chart with visiable Columns
in thread Unable to create a Pivot chart with visiable Columns

I'm sorry I don't understand your requirement. Do you mean adding a line on the chart like this ?


 5 |      y
 4 |  y   y  x            x app1
 3 |  y  xy  x        y   y app2
 2 |  yz xy  xy   y   yz  z app3
 1 | xyz xyz xyz xyz xyz
   ------------------------------
     com lap tab br1 br2 
      insert line here ?
         Device/Browser
poj
  • Comment on Re^5: Unable to create a Pivot chart with visiable Columns

Replies are listed 'Best First'.
Re^6: Unable to create a Pivot chart with visiable Columns
by chandantul (Scribe) on Sep 10, 2018 at 21:09 UTC

    Thanks for your responses! As per your example, com lap tab br1 br2 should be showing as browsers. The sections for different devices will be looking like below and just above Chart in Chart Table at last line after counts there would be total counts of hits for different applications by different browsers as GRAND TOTAL without breaking earlier codes . Like below. Grand Total 5 | y 4 | y y x x app1 3 | y xy x y y app2 2 | yz xy xy y yz z app3 1 | xyz xyz xyz xyz xyz -------------------------------------------------------------------- br1 br2 br3 br4 etc br1 br2 br3 br4 etc br1 br2 br3 br4 etc Computer Tablet Mobile Device/Browser

      Grand Total
      
       5 |      y
       4 |  y   y  x            x app1
       3 |  y  xy  x        y   y app2
       2 |  yz xy  xy   y   yz  z app3
       1 | xyz xyz xyz xyz xyz
         --------------------------------------------------------------------
           br1 br2 br3 br4 etc   br1 br2 br3 br4 etc     br1 br2 br3 br4 etc 
            Computer                   Tablet                  Mobile
                                  Device/Browser
      

      I suggest you create a separate graph for each device.

      poj

        That's great .. You got me but its my requirement showing like below. If I need to keep this in single graph what code changes is required in the chart section and table? I am sharing the current code with you. App 1 App 2 App 3 Device 1 ( bold) Total Hits Count Total Hits Count Total Hits Count Browser 1 Hits Count Hits Count Hits Count Borwser 2 Hits Count Hits Count Hits Count Browser 3 Hits Count Hits Count Hits Count Device 2 ( bold) Total Hits Count Total Hits Count Total Hits Count Browser 1 Hits Count Hits Count Hits Count Borwser 2 Hits Count Hits Count Hits Count Browser 3 Hits Count Hits Count Hits Count Device 3 ( bold) Total Hits Count Total Hits Count Total Hits Count Browser 1 Hits Count Hits Count Hits Count Borwser 2 Hits Count Hits Count Hits Count Browser 3 Hits Count Hits Count Hits Count Grand Total Total Hits Total Hits Total Hits 5 | y 4 | y y x x 3 | y xy x y y 2 | yz xy xy y yz z 1 | xyz xyz xyz xyz xyz -------------------------------------------------------------------- br1 br2 br3 br4 etc br1 br2 br3 br4 etc br1 br2 br3 br4 etc Computer Tablet Mobile Device/Browser

        $strExcelFilename = "D:/PERL/" . "DEVICE-BROWS +ER-REPORT" . ".xlsx"; #$workbook1 = Spreadsheet::WriteExcel->new($strExcelFilename); $workbook1 = Excel::Writer::XLSX->new($strExcelFilename); #$worksheet1 = $workbook1->addworksheet("DEVICE-BROWSER-LIST") +; $worksheet1 = $workbook1->add_worksheet('Data'); #$worksheet2 = $workbook1->add_worksheet('Summary'); $row1= 1; #$chart = $workbook1->add_chart( type => 'column', embedded => + 1 ); foreach $worksheet1 ($workbook1->sheets()) { if( $worksheet1->get_name() eq $SUCCESS_COUNT_SHEET_NAME ) { $format = $workbook1->add_format(%header); $worksheet1->write(0,0, "User Id", $format); $worksheet1->write(0,1, "User Display Name", $format); $worksheet1->write(0,2, "User Email Id", $format); $worksheet1->write(0,3, "Device", $format); $worksheet1->write(0,4, "Browser", $format); $worksheet1->write(0,5,"Application Name", $format); $worksheet1->write(0,6,"TimeStamp", $format); #$worksheet1->write(0,7, "EMAIL--ITUSER-STATUS", $format); } } for ($k = 0; $k <= $#responseid; $k++) { $worksheet1->write($row1,0, $responseid[$k]); $worksheet1->write($row1,1, $responsdisp[$k]); $worksheet1->write($row1,2, $responsalter[$k]); $worksheet1->write($row1,3, $responseclientdevice[$k]); $worksheet1->write($row1,4, $responseclientbrowser[$k]); $worksheet1->write($row1,5, $responseapps5[$k]); $worksheet1->write($row1,6, $estdate[$k]); $app = $responseapps5[$k]; $device = $responseclientdevice[$k]; $browser = $responseclientbrowser[$k]; $userid = $responseid[$k]; ++$pivot{$app}{$device}{$browser}; #++$pivot{$app}{$browser}; ++$categ{'device'}{$device}; ++$categ{'browser'}{$browser}; ++$app{$app}; $row1++; #print Dumper $app; } $worksheet2 = $workbook1->add_worksheet('Summary'); my @device = sort keys %{$categ{'device'}}; my @browser = sort keys %{$categ{'browser'}}; my @applist = sort keys %app; $row1 = 0; for my $device (@device){ $worksheet2->write($row1++,0,[$device,@applist]); for my $browser (@browser){ my $col = 0; $worksheet2->write($row1,0,$browser); for my $app (@applist){ $worksheet2->write($row1,++$col,$pivot{$app}{$device}{$browser}) +; } ++$row1; } ++$row1; } my $chart = $workbook1->add_chart( type => 'column', embedded => 1 ); my $col = 'B'; for my $app (sort keys %app){ $chart->add_series( name => $app, categories => '=Summary!$A2:$A'.$row1, values => '=Summary!$'.$col.'$2:$'.$col.$row1, ); ++$col; } $chart->set_title ( name => 'Results of sample analysis' ); $chart->set_x_axis( name => 'Device/Browser' ); $chart->set_y_axis( name => 'User Count' ); #$chart->set_style( 11 ); # add chart $worksheet2->insert_chart( 'A'.($row1+2), $chart, 0, 0 ); $workbook1->close();

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found