Changeset 1372


Ignore:
Timestamp:
02/19/2010 12:08:26 PM (2 years ago)
Author:
Xiping.Wang
Message:

[trunk] merged from omcollab_chart

Location:
trunk
Files:
10 edited
30 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/_InstallationResources

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/blogs

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/home/contribution/teamContributionStatistic.php

    r1144 r1372  
    5151                $endDate1 = date('Y-m-d',mktime(0, 0, 0, date("m"), 0,   date("Y"))); 
    5252                $endDate2 = date('Y-m-d',mktime(0, 0, 0, date("m")-1, 0,   date("Y"))); 
     53                 
     54                # get contribition score from 2000-01-01 to current date 
    5355                $contributionScoreForEachUser  = $this->getCommunityContributionScore($startDate, $endDate); 
    5456                $score = array(); 
    5557                $teams = array(); 
    5658                foreach ($contributionScoreForEachUser as $key => $row) { 
    57             $score[$key]  = $row['score']; 
    58             $teams[$key] = $row['team_name']; 
    59                 } 
     59                $score[$key] = $row['score']; 
     60                $teams[$key] = $row['team_name']; 
     61                } 
     62                 
     63                # get top 5 team contribution records 
    6064                array_multisort($score, SORT_DESC, $teams, SORT_ASC, $contributionScoreForEachUser); 
    6165                $sliceLength = sizeof($contributionScoreForEachUser) >= 5 ? 5 : sizeof($contributionScoreForEachUser); 
    6266                $top5 = array_slice($contributionScoreForEachUser, 0, $sliceLength); 
    63                 $result = array(); 
    6467                 
    6568                if(count($top5)!=0) 
     
    6770                else 
    6871                        $max_score = 0;  
     72 
     73                $result = array(); 
    6974                $tempSplit = 0; 
    7075                $maxYAixs = $max_score<=100?100:(100*ceil($max_score/100)); 
     
    7883//              } 
    7984                $splitHTML .= '|0|'.($scaleRate*10).'|'.(20*$scaleRate).'|'. 
    80                 (30*$scaleRate).'|'.(40*$scaleRate).'|'.(50*$scaleRate).'|'. 
    81                 (60*$scaleRate).'|'.(70*$scaleRate).'|'.(80*$scaleRate).'|'. 
    82                 (90*$scaleRate).'|'.(100*$scaleRate); 
     85                        (30*$scaleRate).'|'.(40*$scaleRate).'|'.(50*$scaleRate).'|'. 
     86                        (60*$scaleRate).'|'.(70*$scaleRate).'|'.(80*$scaleRate).'|'. 
     87                        (90*$scaleRate).'|'.(100*$scaleRate); 
    8388                $colors = array('FF0000','00FF00','0F5600','01EFF0','56FFFF'); 
    84                 $xAxisHTML = '&chxl=0:|'.date('Y-m',mktime(0, 0, 0, date("m")-1, 0,   date("Y"))). 
    85                 '|'.date('Y-m',mktime(0, 0, 0, date("m"), 0,   date("Y"))).'|'.date('Y-m').'|'; 
    86                 $reslutHtml = "http://chart.apis.google.com/chart?cht=lxy". 
     89                $xAxisHTML = '&chxl=0:' 
     90                        .'|'.date('Y-m',mktime(0, 0, 0, date("m")-1, 0,   date("Y"))) 
     91                        .'|'.date('Y-m',mktime(0, 0, 0, date("m"), 0,   date("Y"))) 
     92                        .'|'.date('Y-m').'|'; 
     93                $reslutHtml = "http://chart.apis.google.com/chart?cht=lxy" 
    8794                //"&chm=N*f0*,FF0000,0,3,11|N*f0*,00FF00,1,3,11|N*f0*,0F5600,2,3,11|N*f0*,01EFF0,3,3,11|N*f0*,56FFFF,4,3,11". 
    88                 "&chs=350x300&chxt=x,y&chco=FF0000,00FF00,0F5600,01EFF0,56FFFF". 
    89                 $xAxisHTML.$splitHTML."&chd=t:"; 
     95                        ."&chs=350x300&chxt=x,y&chco=FF0000,00FF00,0F5600,01EFF0,56FFFF" 
     96                        .$xAxisHTML 
     97                        .$splitHTML 
     98                        ."&chd=t:"; 
    9099                 
    91100                $teamHtml = '&chdl='; 
     
    95104                        $temp2 = $this->getCommunityContributionScore($startDate, $endDate2,$row['team_id']); 
    96105                        $temp1 = $this->getCommunityContributionScore($startDate, $endDate1,$row['team_id']); 
    97                         $result[$row['team_id']] = array('team_name'=>$row['team_name'],$endDate=>$row['score'],$endDate1=>$temp1['score'], 
    98                         $endDate2=>$temp2['score']); 
     106                        $result[$row['team_id']] = array('team_name'=>$row['team_name'], 
     107                                                $endDate=>$row['score'], 
     108                                                $endDate1=>$temp1['score'], 
     109                                                $endDate2=>$temp2['score']); 
    99110                        $teamHtml .= $row['team_name']; 
    100111                        $labelHTML .= 'f'.$row['score'].','.$colors[$ii-1].','.($ii-1).',3,11'; 
     
    113124                return $reslutHtml.$teamHtml.$labelHTML; 
    114125        } 
     126         
     127        /* 
     128         *  Generate Team Contribution Chart based on Fusion Chart  
     129         */ 
     130        public function _GetTop5ContributionThisMonth_v2(){ 
     131                # Use FusionChart to generate data xml cache file                
     132                include_once(dirname(__file__)."/../../common/chart/Class/FusionCharts_Gen.php"); 
     133                $FC = new FusionCharts("Pie3D","360","300"); 
     134 
     135                # Set chart attributes 
     136                $FC->setChartParam("caption","Top 5 Team Contribution"); 
     137                $FC->setChartParam("showNames","1"); 
     138                $FC->setChartParam("showValues","1"); 
     139                $FC->setChartParam("showPercentageValues","1"); 
     140                $FC->setChartParam("showPercentageInLabel","1"); 
     141                $FC->setChartParam("pieYScale","45"); 
     142                $FC->setChartParam("pieBorderAlpha","40"); 
     143                $FC->setChartParam("pieFillAlpha","70"); 
     144                $FC->setChartParam("pieSliceDepth","15"); 
     145//              $FC->setChartParam("pieRadius","100"); 
     146                $FC->setChartParam("decimalPrecision","0"); 
     147                $FC->setChartParam("canvasBorderColor","666666"); 
     148                $FC->setChartParam("baseFontColor","666666"); 
     149                $FC->setChartParam("showColumnShadow","1"); 
     150                $FC->setChartParam("formatNumberScale","0"); 
     151 
     152                # Get week records of previous month 
     153                $startDate = '2000-01-01'; 
     154                $endDate = date('Y-m-d'); 
     155                $endDate1 = date('Y-m-d',mktime(0, 0, 0, date("m"), 0,   date("Y"))); 
     156                $endDate2 = date('Y-m-d',mktime(0, 0, 0, date("m")-1, 0,   date("Y"))); 
     157                 
     158                # get contribition score from 2000-01-01 to current date 
     159                $contributionScoreForEachUser  = $this->getCommunityContributionScore($startDate, $endDate); 
     160                $score = array(); 
     161                $teams = array(); 
     162                foreach ($contributionScoreForEachUser as $key => $row) { 
     163                        $score[$key] = $row['score']; 
     164                        $teams[$key] = $row['team_name']; 
     165                } 
     166                # get top 5 team contribution records 
     167                array_multisort($score, SORT_DESC, $teams, SORT_ASC, $contributionScoreForEachUser); 
     168                 
     169                # set the chart data 
     170                $other_team_score = 0; 
     171                $i=0; 
     172                foreach ($contributionScoreForEachUser as $key => $row) { 
     173                        $i++; 
     174                        if($i<=5) { 
     175                                $FC->addChartData($row['score'],"name=".$row['team_name']); 
     176                        } else { 
     177                                # group the others as a team 
     178                                $other_team_score += $row['score']; 
     179                        } 
     180                } 
     181                if($i>5) $FC->addChartData($row['score'],"name=Other team"); 
     182                         
     183                 
     184                # Render chart xml 
     185                return $FC->getXML(); 
     186                 
     187        }        
    115188         
    116189        public function getAllTeam(){ 
     
    230303                 
    231304                $factSql = ''; 
    232                 //ŒÆËãžÃʱŒä¶ÎÄÚ×ܵČÆÊýÖµ 
    233305                switch ($contributionFactor){ 
    234306                        case 'WikiNew': 
  • trunk/home/portlets/PortletsClass.php

    r1217 r1372  
    150150                          FROM ".OMWIKI_DB_TABLE_PREFIX ."page p,".OMWIKI_DB_TABLE_PREFIX ."revision r  
    151151                         WHERE r.rev_page=p.page_id  
    152                        AND r.rev_timestamp < ". $a_date ." AND "." r.rev_timestamp> ".$a_date = date("Ymd", $start_t) . '000000';;  
     152                       AND r.rev_timestamp < ". $a_date ." AND "." r.rev_timestamp > ".date("Ymd", $start_t) . '000000';;  
    153153                         
    154154                $res = $this->oDb->GetRows( $sSql ); 
     
    208208 
    209209 
    210                 $result.='<img src="' . $this->generate_google_chart($ary_dates, $ary_edits, $ary_pages) .'"/>'; 
    211                          
    212                 //Add help text 
    213                 $result.='<hr/><ul><li><span style="color:red;">Red</span> Y axis shows individual user incremental edits statistics.</li> 
    214                                            <li><span style="color:blue;">Blue</span> Y axis shows individual user incremental pages statistics.</li> 
    215                                 </ul>'; 
    216                 return $result; 
     210                # Use FusionChart to generate data xml cache file                
     211                include_once(dirname(__file__)."/../../common/chart/Class/FusionCharts_Gen.php"); 
     212                $FC = new FusionCharts("MSColumn2D","360","300"); 
     213 
     214                # Set chart attributes 
     215                $FC->setChartParam("caption","Articles Edit Count Chart of this month"); 
     216                $FC->setChartParam("rotateNames","1"); 
     217//              $FC->setChartParam("showNames","0"); 
     218                $FC->setChartParam("showValues","0"); 
     219                $FC->setChartParam("decimalPrecision","0"); 
     220                $FC->setChartParam("xAxisName","Date"); 
     221//              $FC->setChartParam("yAxisName","Edits"); 
     222                $FC->setChartParam("showAlternateHGridColor","1"); 
     223                $FC->setChartParam("divLineColor","ff5904"); 
     224                $FC->setChartParam("divLineAlpha","20");  
     225                $FC->setChartParam("alternateHGridAlpha","5'");  
     226                $FC->setChartParam("canvasBorderColor","666666"); 
     227                $FC->setChartParam("baseFontColor","666666"); 
     228                $FC->setChartParam("showColumnShadow","1"); 
     229                 
     230                $i=0; 
     231                # Add category names 
     232                foreach( $ary_dates as $d) { 
     233                        if($i % 7 ==0 || $ary_edits[$i]!=0) 
     234                                $FC->addCategory($d,"showName=1"); 
     235                        else 
     236                                $FC->addCategory($d,"showName=0"); 
     237                        $i++;            
     238                }        
     239                 
     240                # Create second dataset 
     241                $FC->addDataset("Edit Pages"); 
     242                # Add chart values for the second dataset 
     243                foreach( $ary_pages as $p) 
     244                        $FC->addChartData($p); 
     245                 
     246                # Create a new dataset 
     247                $FC->addDataset("Edit Counts"); 
     248                # Add chart values for the above dataset 
     249                foreach( $ary_edits as $e) 
     250                        $FC->addChartData($e); 
     251                 
     252 
     253                # Render chart xml 
     254                return $FC->getXML(); 
     255 
    217256        } 
    218257 
     
    328367                .'    GROUP BY s.s_id' 
    329368                .'    ORDER BY s_count DESC LIMIT 10) t' 
    330                 .'        ORDER BY t.s_description'; 
     369                .'        ORDER BY t.s_count DESC'; 
    331370                else 
    332371                $sSql = 'SELECT * FROM (SELECT s.s_id,s.s_description,s.s_type,count(*) as s_count ' 
     
    336375                .'    GROUP BY s.s_id' 
    337376                .'        ORDER BY s_count DESC LIMIT 10) t' 
    338                 .'    ORDER BY t.s_description'; 
     377                .'    ORDER BY t.s_count DESC'; 
    339378 
    340379                $rows = $this->oDb->GetRows( $sSql ); 
    341380 
     381/*               
    342382                $skills = array(); 
    343383                $weight = array(); 
     
    363403                        chs=300x120& 
    364404                        chl='.$skill_str.'"/>'; 
    365  
     405*/ 
     406                 
     407                include_once(dirname(__file__)."/../../common/chart/Class/FusionCharts_Gen.php"); 
     408                $FC = new FusionCharts("Pie2D","360","300"); 
     409 
     410                # Set chart attributes 
     411                $FC->setChartParam("caption","Top 10 skills from MIKE2 community"); 
     412//              $FC->setChartParam("subCaption"," --"); 
     413                $FC->setChartParam("showNames","1"); 
     414                $FC->setChartParam("showValues","0"); 
     415                $FC->setChartParam("decimalPrecision","0"); 
     416                $FC->setChartParam("divLineColor","ff5904"); 
     417                $FC->setChartParam("divLineAlpha","20");  
     418                $FC->setChartParam("alternateHGridAlpha","5'");  
     419                $FC->setChartParam("canvasBorderColor","666666"); 
     420                $FC->setChartParam("baseFontColor","666666"); 
     421                $FC->setChartParam("showColumnShadow","1"); 
     422                 
     423//              $FC->setChartParam("rotateNames","1"); 
     424//              $FC->setChartParam("xAxisName","Skills"); 
     425//              $FC->setChartParam("yAxisName","Rate Counts"); 
     426//              $FC->setChartParam("showAlternateHGridColor","1"); 
     427         
     428                # add chart values and category names 
     429                foreach($rows as $row){ 
     430                        $FC->addChartData($row['s_count'],"name=".$row['s_description']); 
     431                } 
     432   
     433                # Render Chart 
     434                return $FC->getXML(); 
    366435        } 
    367436 
  • trunk/home/portlets/community_chart/Portlet.php

    r995 r1372  
    55require_once( FS_COMMON_DIRECTORY.'/utils.php'); 
    66require_once(dirname(__file__).'/../../includes/config.php'); 
     7# Include FusionCharts PHP Class 
     8include_once(dirname(__file__)."/../../../common/chart/Class/FusionCharts_Gen.php"); 
    79?> 
    810 
    911<div id="accordion" class="accordion"> 
    10         <h3><a href="#">Articles Usage Chart of this month</a></h3> 
     12        <h3><a href="#">Articles Edit Count Chart of this month</a></h3> 
    1113        <div> 
    12                 <p><?php include('../../omcache/'.UserUsage.'.html'); ?></p> 
     14            <script language='javascript' src='<?php echo RR_COMMON_DIRECTORY ?>chart/FusionCharts/FusionCharts.js'></script> 
     15<?php 
     16  # Create Column3D chart Object 
     17  $FC = new FusionCharts("MSColumn2D","340","250"); 
     18  # set the relative path of the swf file 
     19  $FC->setSWFPath(RR_COMMON_DIRECTORY."chart/FusionCharts/"); 
     20  # Render Chart 
     21  $FC->renderChartFromExtXML(file_get_contents(dirname(__file__).'/../../omcache/'.UserUsage.'.html')); 
     22?> 
    1323        </div> 
    1424        <h3><a href="#">Articles Contribution Scores this month(Top 10)</a></h3> 
  • trunk/home/portlets/skill/Portlet.php

    r1084 r1372  
    55require_once( FS_COMMON_DIRECTORY.'/utils.php'); 
    66require_once(dirname(__file__).'/../../includes/config.php'); 
    7  
    87session_start(); 
    9  
    10  
    11  
     8# Include FusionCharts PHP Class 
     9include_once(dirname(__file__)."/../../../common/chart/Class/FusionCharts_Gen.php"); 
    1210 
    1311$bIsLoggedOn = GetLoggedInStateFromWikiCookies(); 
     
    3230        </ul> 
    3331        <div id="tabs3-1"> 
     32            <script language='javascript' src='<?php echo RR_COMMON_DIRECTORY ?>chart/FusionCharts/FusionCharts.js'></script> 
    3433<?php 
    35     include('../../omcache/'.SkillChart.'.html'); 
     34  # Create Column3D chart Object 
     35  $FC = new FusionCharts("Pie2D","350","260"); 
     36  # set the relative path of the swf file 
     37  $FC->setSWFPath(RR_COMMON_DIRECTORY."chart/FusionCharts/"); 
     38  # Render Chart 
     39  $FC->renderChartFromExtXML(file_get_contents(dirname(__file__).'/../../omcache/'.SkillChart.'.html')); 
     40 
    3641?></div> 
    3742<?php 
  • trunk/home/portlets/team/Portlet.php

    r1221 r1372  
     1 
    12<?php 
    23require_once( dirname(__file__) . '/../../../common/omconfig.php' ); 
     
    67require_once(dirname(__file__).'/../../includes/config.php'); 
    78 
     9# Include FusionCharts PHP Class 
     10include_once(dirname(__file__)."/../../../common/chart/Class/FusionCharts_Gen.php"); 
     11?> 
     12<div style="text-align:center"> 
     13<script language='javascript' src='<?php echo RR_COMMON_DIRECTORY ?>chart/FusionCharts/FusionCharts.js'></script> 
     14 
     15<?php 
    816$bIsLoggedOn = GetLoggedInStateFromWikiCookies(); 
    917if($bIsLoggedOn ){  
     
    1220 
    1321 
    14  
     22  # Create Column3D chart Object 
     23  $FC = new FusionCharts("Pie3D","360","260"); 
     24  # set the relative path of the swf file 
     25  $FC->setSWFPath(RR_COMMON_DIRECTORY."chart/FusionCharts/"); 
     26  # Render Chart 
     27  $FC->renderChartFromExtXML(file_get_contents(dirname(__file__).'/../../omcache/'.TeamContribution.'.html')); 
     28   
    1529?> 
    16  
    17 <div id="tabs3" class="tabs"> 
    18         <ul> 
    19                 <li><a href="#tabs3-1">Top 5 Team</a></li>       
    20         </ul> 
    21         <div id="tabs3-1"> 
     30</div> 
     31<?php      
     32  if($bIsLoggedOn) {  
     33?> 
     34        <p><a href="<?php echo OMWIKI_SCRIPT_PATH;?>/index.php/Special:TeamArrangement">Manage my teams</a></p> 
    2235<?php 
    23     include('../../omcache/'.TeamContribution.'.html'); 
    24 ?></div> 
    25 </div> 
    26 <?php 
    27     if($bIsLoggedOn) {  
     36  }  
    2837?> 
    29 <p> 
    30 <a href="<?php echo OMWIKI_SCRIPT_PATH;?>/index.php/Special:TeamArrangement">Manage my teams</a> 
    31 </p> 
    32 <?php 
    33     }  
    34 ?> 
    35 <script> 
    36         jQuery('#skill #tabs3 div a').css('font-weight','bold'); 
    37 </script> 
  • trunk/home/team_contribution_cron.php

    r1069 r1372  
    2727$oDb          = &newDb( 'wiki',true ); 
    2828$TeamContributionStatistics = new TeamContributionStatistics($oDb); 
    29 saveCache(TeamContribution,"<img src='".$TeamContributionStatistics->_GetTop5ContributionThisMonth()."' />"); 
     29saveCache(TeamContribution,$TeamContributionStatistics->_GetTop5ContributionThisMonth_v2()); 
    3030 
    3131 
  • trunk/wiki

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.