Welcome Guest, Not a member yet? Register   Sign In
getting user data for graph
#1

[eluser]riwakawd[/eluser]
What is the best way to create a function on the controller that can count the number of users that joined for that month and gets the total and then each column represents a month.

Can not seem to work it out how to do it so then could be the script could get the data from controller.

Code:
<!-- Links Work OK -->
    [removed][removed]
    [removed][removed]
    
    <!-- To Do First -->
    
    <div class="panel panel-default">
    <div class="panel-heading">
    <h3 class="panel-title"><i class="fa fa-bar-chart-o"></i> &lt;?php echo $heading_title; ?&gt;</h3>
    </div>
    <div class="panel-body">
    <div id="chart"  100%; height: 260px;"></div>
    </div>
    </div>
    
    [removed]
    $(document).ready(function () {
       /* var example : [month, totalusersjoined].*/
    
       /* Example Data Testing Only */ var data = [[0, 7], [1, 6], [2, 3], [3, 4], [4, 9], [5, 8], [6, 12], [7, 10], [8, 7], [9, 14],[10, 14],[11, 5]];
    
        //var example :
    
        $.plot($("#chart"), [data], {
            series: {
                shadowSize: 1,
                colors: '#1065D2',
                bars: {
                  show: true,
                  fill: true,
                  lineWidth: 1
                },
                grid: {
                  backgroundColor: '#FFFFFF',
                  hoverable: true
                }
            }
        });
    });
    [removed]

Code:
class Chart extends MX_Controller {

public function __construct() {
  parent::__construct();
  if (!$this->user->logged()) {
   redirect('admin');
  }

  $this->lang->load('admin/dashboard/chart', 'english');
  $this->load->model('admin/report/model_report_user');
  $this->load->library('request');
}

public function index() {
  $data['heading_title'] = $this->lang->line('heading_title');

  $data['heading_title_client'] = $this->lang->line('heading_title_client');
  
  $data['text_day'] = $this->lang->line('text_day');
  $data['text_week'] = $this->lang->line('text_week');
  $data['text_month'] = $this->lang->line('text_month');
  $data['text_year'] = $this->lang->line('text_year');
  $data['text_view'] = $this->lang->line('text_view');

  return $this->load->view('dashboard/chart', $data);
}

}
#2

[eluser]InsiteFX[/eluser]
Add a user_joined date field to your users table then it should be easy to do the calculations.




Theme © iAndrew 2016 - Forum software by © MyBB