I assume that you just want to use a different color to represent anomalies in your data. If so, you do not need to create a domain and range.
You can simply create a custom color palette as follows:
var custom_colors = ['#ef3b2c', '#084594', '#2171b5', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef', '#deebf7', '#f7fbff', '#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'];
This color palette was built using the palette on this page with the addition of additional red color to the end.
Then just call custom colors like this:
d3.select("#testdiv") .selectAll(".horizon") ... .call(context.horizon() .colors(custom_colors) ));
Play with colors until you find the combination you like. In the above example, only the outlier will be red, and the rest will be blue and green.
Hope this helps!
user2286078
source share