docs: def _gen_trend_graph(start, end, force_overwrite=False):
      """ Total trend graph for machine category. """
      filename = graphs.get_trend_graph_filename(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(
          date__range=(start, end)
      )
      query = query.values('date').annotate(Sum('cpu_usage'))
      query = query.order_by('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)
      ax.set_title('%s - %s' % (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['date'], row['cpu_usage__sum'] / 3600.00
              ])
  
              date = row['date']
  
              data[date] = row['cpu_usage__sum']
  
      start = t_start
      end = t_end
      while start <= end:
          total = 0
          if start in data:
              total = data[start]
          x_data.append(start)
          y_data.append(total / 3600.00)
          start = start + datetime.timedelta(days=1)
  
      del data
  
      ax.plot(x_data, y_data)
  
      del x_data
      del y_data
  
      fig.autofmt_xdate()
      plt.tight_layout()
      plt.savefig(png_filename)
      plt.close()