Server IP : 180.180.241.3 / Your IP : 216.73.216.252 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/AppServ/www/app/View/Elements/Pages/Charts/ |
Upload File : |
<?php function init_chart_region( $entity_name, &$x_axis, &$y_axis, &$list_provinces, &$counters_provinces ) { $x_axis = $list_provinces; $y_axis = $counters_provinces; } function init_chart_region_years( $entity_name, &$x_axis, &$y_axis, &$all_entities, &$query ) { $year_start = ( int )$query['filter_since_year']; $year_end = ( int )$query['filter_until_year']; $x_axis = array(); $y_axis = array(); for( $i = $year_start; $i <= $year_end; $i++ ) { $x_axis[] = $i; $y_axis[] = 0; } foreach( $all_entities as $entity ) { $year = explode( '-', $entity[$entity_name]['joined'] ); $year = $year[0]; $y_axis[ $year - $year_start + 543 ]++; } } function init_chart_region_months( $entity_name, &$x_axis, &$y_axis, $year, &$all_entities ) { $x_axis = array(); $y_axis = array(); $months = Configure::read( 'MONTHS' ); // the months in bootstrap.php are indexed, starting at 1... Next time I don't listen to Arm anymore ;( foreach( $months as $month ) { $x_axis[] = $month; $y_axis[] = 0; } foreach( $all_entities as $entity ) { $month = explode( '-', $entity[$entity_name]['joined'] ); // work only on selected year if( $month[0] != $year ) { continue; } $month = $month[1]; $y_axis[ $month - 1 ]++; } } if( !empty( $this->request->query['filter_since_year'] ) ) { // two years given, show the years on the X axis if( !empty( $this->request->query['filter_until_year'] ) ) { // invalid years request -> reset to normal chart if( ( int )$this->request->query['filter_since_year'] <= ( int )$this->request->query['filter_until_year'] ) { init_chart_region_years( $entity_name, $x_axis, $y_axis, $all_entities, $this->request->query ); } else { init_chart_region( $entity_name, $x_axis, $y_axis, $list_provinces, $counters_provinces ); } // one year given, show the months } else { $year = ( int )$this->request->query['filter_since_year'] - 543; init_chart_region_months( $entity_name, $x_axis, $y_axis, $year, $all_entities ); } } else { init_chart_region( $entity_name, $x_axis, $y_axis, $list_provinces, $counters_provinces ); } $options['x_axis'] = $x_axis; $options['y_axis'] = $y_axis; echo $this->element( 'Pages/Charts/horizontal-chart', $options ); ?> <div class="container frontend-content"> <?php echo $this->element('Pages/map-nav', array('current_entities' => $tab_name)); ?> <div class="row"> <div id="container"></div> </div> </div>