         .attr('class', 'color')
     legend_target.append('span')
         .text((d) -> d.name)
+  
+    if params.bgcolor?
+      svg.style 'background-color', params.bgcolor
+

      values = for [value, timestamp] in s.datapoints
        time_min = Math.min timestamp, time_min ? timestamp
        time_max = Math.max timestamp, time_max
        value_min = Math.min value, value_min ? value if value?
        value_max = Math.max value, value_max
        {value, time: moment(timestamp * 1000)}

      .y((d) -> y d.value)
      .defined((d) -> d.value?)

    transform_value =
      if params.drawNullAsZero
        (v) -> v ? 0
      else
        (v) -> v

    time_min = null
    time_max = null
    value_min = null
