     palette = palettes[opts.palette ? "Spectral11"].map(num2hexcolor)
 
   colors = ( palette[i % palette.length] for i in [0...normalized_values.length] )
+  text_colors = colors.map((c) -> if is_dark(hexcolor2rgb(c)) then "white" else "black")
 
   to_cartesian = (r, alpha) -> [r*Math.cos(alpha), r*Math.sin(alpha)]
 

  return result

num2hexcolor = (num) -> sprintf("#%06x", num)

pie = (data, opts) ->
  labels = _.clone(data.labels)

      end_angles: end_angles,
      text_angles: text_angles,
      colors: colors,
      text_colors: text_colors,
      text_cx: text_cx,
      text_cy: text_cy,
    }
