Ignore:
Timestamp:
Jun 5, 2024, 2:44:06 PM (4 weeks ago)
Author:
roby
Message:
  • CLIENT

-- Modifica alla funzione rss per gestire consultazioni con spoglio non ancora iniziato
-- Aggiunto grafico a torta per le voci del menu Grafici, utile in particolare per il tema tour

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/modules/Elezioni/grafici.php

    r417 r421  
    2424list($id_cons) = $res->fetch(PDO::FETCH_NUM);
    2525
    26 
    27 if($flash=='1') include "class/charts.php";
    2826
    2927/***********************************
     
    102100                        echo  "<tr><td>&nbsp;"._AVENTI.": </td><td><img src=\"modules/Elezioni/images/barre/leftbar.jpg\" height=\"$l_size[1]\" width=\"$l_size[0]\" alt=\"elettori\" /><img src=\"modules/Elezioni/images/barre/mainbar.jpg\" alt=\"elettori\" height=\"$m_size[1]\" width=\"".(100 * 2)."\" /><img src=\"modules/Elezioni/images/barre/rightbar.jpg\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"elettori\" /> 100 % ($tot_gen)</td></tr></table>";
    103101                         echo "</td></tr></table>";
    104                 }       
     102                }
    105103    }
     104         $gruppi=array('Hanno votato','Non hanno votato');
     105         $resto=100-$perc;
     106         $valori=array($perc,$resto);
     107         echo "<center>";
     108         torta($gruppi,$valori);
     109         echo "</center>";             
    106110}
    107111
     
    111115
    112116function graf_votanti(){
    113 global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$flash,$tour,$tema,$copy;
     117global $op, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$tipo_cons,$id_comune,$id_cons_gen,$id_circ,$csv,$w,$l,$siteistat,$tour,$tema,$copy;
    114118
    115119
     
    128132        modules.php?name=Elezioni&amp;op=come&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;info=votanti\">"._DETTAGLIO." "._VOTANTI."<img class=\"image\" src=\"modules/Elezioni/images/dettagli.png\" alt=\"votanti\" /></a>
    129133        <a href=\" modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti&amp;csv=1&amp;flash=\">"._VER_STAMPA." <img class=\"image\" src=\"modules/Elezioni/images/printer.png\" alt=\"stampa\" /></a>";
    130         if($flash==1)
    131                 echo "<a href=\" modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti&amp;csv=&amp;anim=$anim\">$versione <img class=\"image\" src=\"modules/Elezioni/images/grafici.gif\" alt=\"flash\" /></a>";
     134#       if($flash==1)
     135#               echo "<a href=\" modules.php?name=Elezioni&amp;file=index&amp;id_cons_gen=$id_cons_gen&amp;id_comune=$id_comune&amp;op=graf_votanti&amp;csv=&amp;anim=$anim\">$versione <img class=\"image\" src=\"modules/Elezioni/images/grafici.gif\" alt=\"flash\" /></a>";
    132136        echo "</div>";
    133137      }
     
    345349
    346350function graf_gruppo($visgralista){
    347 global $admin, $bgcolor1, $bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$flash,$tema,$copy;
     351global $admin, $bgcolor1, $bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$tema,$copy;
    348352        if ($siteistat==$id_comune) $logo=$siteistat; else $logo=''; // logo per il  comune
    349353        $logo=verificasimbolo(); // carica_logo da funzioni.php
     
    456460                                        // variabili stampa flash
    457461                                        $e=0;
    458                                         $gruppos[$e]="";
    459                                         $pre[$e]="";
    460                                         $e=1;
     462#                                       $gruppos[$e]="";
     463#                                       $pre[$e]="";
     464#                                       $e=1;
    461465                                        // fine
    462466                                $gruppinum=$res->rowCount();
     
    487491                                // funz per il taglio corretto della frase 13 feb 2007
    488492                                //$descrizione=taglio(4,$descrizione);
    489                                
    490                                 $gruppo[$i]=(substr($descrizione,0,21));
    491                                 $gruppos[$e]=(substr($descrizione,0,21)); //flash
    492 
    493                                
    494 
    495                                 if (strlen($descrizione)>21) $gruppo[$i].="...";
    496                                 if (strlen($descrizione)>21) $gruppos[$e].="...";
     493                                if (strlen($descrizione)<18){
     494                                        $gruppo[$i]=(substr($descrizione,0,18));
     495                                        $gruppos[$e]=(substr($descrizione,0,18)); //flash                               
     496                                }else{
     497                                        $gruppo[$i]=(substr($descrizione,0,15));
     498                                        $gruppos[$e]=(substr($descrizione,0,15)); //flash
     499                                }
     500                               
     501
     502                                if (strlen($descrizione)>16) $gruppo[$i].=".";
     503                                if (strlen($descrizione)>16) $gruppos[$e].=".";
    497504                                $pro[$i]=number_format($arperc[$id],2);
    498505                                $pre[$e]=number_format($arperc[$id],2); //flash
     
    560567                echo "</td></tr></table><table><tr><td>";
    561568                # grafico flash
    562                 if($flash=='1') flash_torta($gruppos,$pre,40,145);
     569                torta($gruppos,$pre);
    563570                                $uno='';
    564571                                foreach($gruppos as $k=>$v) $uno.="- $v";
     
    633640                               
    634641
    635                                 if($flash=='1')flash_torta($gruppos,$pre,20,70);
     642                                torta($gruppos,$pre);
    636643
    637644
     
    746753
    747754
    748 
    749 function flash_torta($gruppos,$pre,$y,$x){
    750 //if (!defined('FLASH')) die();
    751 include_once ("class/charts.php");
    752 // inizio grafico torta flash
    753                
    754                
    755                
    756                 $chart[ 'chart_data' ] = array ($gruppos, $pre);
    757 //              $chart[ 'chart_data' ] = array ( array ("","Ciao", "Bella"), array ( "",40, 60));
    758                 $chart[ 'chart_grid_h' ] = array ( 'thickness'=>0 );
    759                 $chart[ 'chart_pref' ] = array ( 'rotation_x'=>60 );
    760                 $chart[ 'chart_rect' ] = array ( 'x'=>$x, 'y'=>$y, 'width'=>350, 'height'=>200, 'positive_alpha'=>0 );
    761                 $chart[ 'chart_transition' ] = array ( 'type'=>"spin", 'delay'=>.5, 'duration'=>.75, 'order'=>"category" );
    762                 $chart[ 'chart_type' ] = "3d pie";
    763                 $chart[ 'chart_value' ] = array ( 'color'=>"000000", 'alpha'=>150, 'font'=>"arial", 'bold'=>true, 'size'=>10, 'position'=>"inside", 'prefix'=>"", 'suffix'=>"", 'decimals'=>2, 'separator'=>"", 'as_percentage'=>true );
    764 
    765                 $chart[ 'draw' ] = array ( array ( 'type'=>"text", 'color'=>"000000", 'alpha'=>4, 'size'=>40, 'x'=>50, 'y'=>260, 'width'=>500, 'height'=>50, 'text'=>"56789012345678901234", 'h_align'=>"center", 'v_align'=>"middle" )) ;
    766 
    767                 $chart[ 'legend_label' ] = array ( 'layout'=>"horizontal", 'bullet'=>"circle", 'font'=>"arial", 'bold'=>true, 'size'=>10, 'color'=>"000000", 'alpha'=>85 );
    768                 $chart[ 'legend_rect' ] = array ( 'x'=>0, 'y'=>45, 'width'=>50, 'height'=>210, 'margin'=>10, 'fill_color'=>"00ff00", 'fill_alpha'=>30, 'line_color'=>"000000", 'line_alpha'=>0, 'line_thickness'=>0 ); 
    769                 $chart[ 'legend_transition' ] = array ( 'type'=>"dissolve", 'delay'=>0, 'duration'=>4 );
    770 
    771                 $chart[ 'series_color' ] = array ( "00ff88", "ffaa00","44aaff", "aa00ff" );
    772                 $chart[ 'series_explode' ] = array ( 25, 75, 0, 0 );
    773                 $fileout="";
    774 /////////////////////////////// MODIFICHE PER TOGLIERE FILETEMP
    775 //              $fileout=SendChartData ( $chart );
    776                 $xml=SendChartData ( $chart );
    777                 $max=isset($_SESSION['max']) ? $_SESSION['max']:0;
    778                 $max++;
    779                 $cur="xml$max";
    780                 $_SESSION[$cur]=$xml;
    781                 $_SESSION['max']=$max;
    782                 $fileout="modules.php?file=graf&pos=$cur";
    783 ///////////////////////////////
    784                 echo InsertChart ( "class/charts.swf", "class/charts_library","$fileout" );
    785                
    786                 // Fine Grafico torta flash
    787                 echo "<noembed>Elemento non supportato!<br/>Grafico a torta</noembed>";
     755function torta($gruppos,$pre){
     756        echo '<div id="piechart" style="width:1000px; height:500px;text-align:center;"></div>';
     757
     758        echo '<script>google.charts.load("current", {"packages":["corechart"]});
     759        google.charts.setOnLoadCallback(drawChart);
     760
     761        function drawChart() {           
     762          var data = google.visualization.arrayToDataTable([
     763                ["Task", "Affluenze"]';
     764                $x=0;
     765                foreach($gruppos as $key=>$val)
     766                                        echo ',["'.$val.' '.$pre[$x].'%", '.$pre[$x++].']';
     767                                       
     768                echo ']);
     769          var options = {
     770                title: "",
     771                is3D:true,
     772                 pieSliceText: "label",
     773                 pieSliceTextStyle: {
     774                        color: "#000",
     775                        bold:true,
     776                        fontSize:9
     777                  },
     778                 slices: {
     779                        0: { color: "#ff0000", textStyle:{color:"#fff"}},
     780                        1: { color: "#ffff00" }
     781                  }
     782          };
     783          var chart = new google.visualization.PieChart(document.getElementById("piechart"));
     784
     785          chart.draw(data, options);
     786        }</script>';
    788787 
    789788
     
    794793
    795794
    796 
    797 
    798795?>
    799796
Note: See TracChangeset for help on using the changeset viewer.