code: def draw_resource_bar(
      start_time,
      finish_time,
      time_series,
      space_between_minutes,
      minute_scale,
      color,
      left,
      resource,
  ):
      """ """
  
      # Memory header
      result = "<p class='time' style='top:198px;left:%dpx;'>%s</p>" % (
          left,
          resource,
      )
      # Image scaling factors
      scale = space_between_minutes / minute_scale
      space_between_minutes = space_between_minutes / scale
  
      # Iterate through time series
      ts_items = time_series.items()
  
      ts_len = len(time_series)
      for idx, (ts_start, amount) in enumerate(ts_items):
          if idx < ts_len - 1:
              ts_end = time_series.index[idx + 1]
          else:
              ts_end = finish_time
          # Calculate offset from start at top
          offset = (
              (ts_start - start_time).total_seconds() / 60.0
          ) * scale * space_between_minutes + 220
          # Scale duration
          duration_mins = (ts_end - ts_start).total_seconds() / 60.0
          height = duration_mins * scale * space_between_minutes
          if height < 5:
              height = 5
          height -= 2
  
          # Bar width is proportional to resource amount
          width = amount * 20
  
          if resource.lower() == "memory":
              label = "%.3f GB" % amount
          else:
              label = "%d threads" % amount
  
          # Setup dictionary for bar html string insertion
          bar_dict = {
              "color": color,
              "height": height,
              "width": width,
              "offset": offset,
              "left": left,
              "label": label,
              "duration": duration_mins,
              "start": ts_start.strftime("%Y-%m-%d %H:%M:%S"),
              "finish": ts_end.strftime("%Y-%m-%d %H:%M:%S"),
          }
  
          bar_html = (
              "<div class='bar' style='background-color:%(color)s;"
              "height:%(height).3fpx;width:%(width).3fpx;"
              "left:%(left)dpx; top:%(offset).3fpx;'"
              "title='%(label)s\nduration:%(duration).3f\n"
              "start:%(start)s\nend:%(finish)s'></div>"
          )
          # Add another bar to html line
          result += bar_html % bar_dict
  
      # Return bar-formatted html string
      return result
  
file_path: nipype/nipype/utils/draw_gantt_chart.py
imports: import sys
  import random
  import datetime
  import simplejson
  from collections import OrderedDict
label_desc: Use image node_id 6 for calling a global function with example usage: draw_resource_bar(start_time, finish_time, time_series, space_between_minutes, minute_scale, color, left, resource) and returns: result