Example #1
0
 {x_buckets.map(function(xb, i) {
     if (i < x_limit) {
         var value = yb[x_grouping][i];
         var color = seriesColor.clone();
         // scale color between white and the series color
         color.lightness(color.lightness() + (1 - value / matrix.max_cell_doc_count) * (100 - color.lightness()));
         var href = search_base + '&' + secondary_y_grouping + '=' + encodeURIComponent(yb.key)
                                + '&' + x_grouping + '=' + encodeURIComponent(xb.key);
         var title = yb.key + ' / ' + xb.key + ': ' + value;
         return <td key={xb.key} style={{backgroundColor: color.hexString()}}>
             {value ? <a href={href} style={{color: '#000'}} title={title}>{value}</a> : ''}
         </td>;
     } else {
         return null;
     }
 })}
Example #2
0
export function weatherColor(temp) {
  if(isNaN(temp)) {
    return 'white'
  }

  var result = start.clone()

  var ratio = scale(temp)

  var newHue = lerp(start.hue(), end.hue(), ratio)
  var newSaturation = lerp(start.saturation(), end.saturation(), ratio)
  var newLightness = lerp(start.lightness(), end.lightness(), ratio)

  result.hue(newHue)
  result.saturation(newSaturation)
  result.lightness(newLightness)
  contrast(result)
  // result.alpha(0.3)

  return result.hslaString()
}