docs: def _gen_project_trend_graph(project, start, end, force_overwrite=False):
      """Generates a bar graph for a project
  
      Keyword arguments:
      project -- Project
      start -- start date
      end -- end date
  
      """
      filename = graphs.get_project_trend_graph_filename(project, start, end)
      csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv')
      png_filename = os.path.join(GRAPH_ROOT, filename + '.png')
  
      _check_directory_exists(csv_filename)
      _check_directory_exists(png_filename)
  
      if not settings.GRAPH_DEBUG or force_overwrite:
          if os.path.exists(csv_filename):
              if os.path.exists(png_filename):
                  return
  
      query = CPUJob.objects.filter(
          project=project,
          date__range=(start, end)
      )
      query = query.values('account', 'account__username', 'date')
      query = query.annotate(Sum('cpu_usage')).order_by('account', 'date')
  
      t_start = start
      t_end = end
  
      start_str = start.strftime('%Y-%m-%d')
      end_str = end.strftime('%Y-%m-%d')
  
      fig, ax = plt.subplots(figsize=(6, 4))
      ax.set_xlim(start, end + datetime.timedelta(days=1))
      ax.set_title('%s   %s - %s' % (project.pid, start_str, end_str))
      ax.set_ylabel("CPU Time (hours)")
      ax.set_xlabel("Date")
  
      locator = mdates.AutoDateLocator()
      ax.xaxis.set_major_locator(locator)
      ax.xaxis.set_major_formatter(mdates.AutoDateFormatter(locator))
      ax.xaxis.set_minor_locator(mdates.DayLocator())
  
      data = {}
      x_data = {}
      y_data = {}
  
      with open(csv_filename, 'w') as csv_file:
          csv_writer = csv.writer(csv_file)
          for row in query.iterator():
              csv_writer.writerow([
                  row['account__username'],
                  row['date'], row['cpu_usage__sum'] / 3600.00
              ])
  
              account = row['account']
              date = row['date']
  
              if account not in data:
                  data[account] = {}
                  x_data[account] = []
                  y_data[account] = []
  
              data[account][date] = row['cpu_usage__sum']
  
      for account, dates in six.iteritems(data):
          start = t_start
          end = t_end
          while start <= end:
              total = 0
              if start in dates:
                  total = dates[start]
              x_data[account].append(start)
              y_data[account].append(total / 3600.00)
              start = start + datetime.timedelta(days=1)
  
      del data
  
      totals = []
      start = t_start
      end = t_end
      while start <= end:
          totals.append(0)
          start = start + datetime.timedelta(days=1)
  
      count = 0
      for account in x_data.keys():
          ax.bar(
              x_data[account], y_data[account],
              bottom=totals,
              color=graphs.get_colour(count),
              edgecolor=graphs.get_colour(count),
              align='edge')
          count = count + 1
  
          i = 0
          start = t_start
          end = t_end
          while start <= end:
              totals[i] += y_data[account][i]
              i = i + 1
              start = start + datetime.timedelta(days=1)
  
      del x_data
      del y_data
      del totals
  
      fig.autofmt_xdate()
      plt.tight_layout()
      plt.savefig(png_filename)
      plt.close()