Skip to content

Commit

Permalink
adds domain override to .color( ) scale (closes #523)
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Aug 12, 2016
1 parent e5a1480 commit 3133e81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core/data/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ module.exports = function(vars) {

if ( vars.dev.value ) print.time("getting color data range")

var data_range = []
vars.data.pool.forEach(function(d){
var val = parseFloat(fetchValue(vars,d,vars.color.value))
if (typeof val == "number" && !isNaN(val) && data_range.indexOf(val) < 0) data_range.push(val)
})
if (vars.color.domain.value) {
var data_range = vars.color.domain.value;
}
else {
var data_range = []
vars.data.pool.forEach(function(d){
var val = parseFloat(fetchValue(vars,d,vars.color.value))
if (typeof val == "number" && !isNaN(val) && data_range.indexOf(val) < 0) data_range.push(val)
})
}

if ( vars.dev.value ) print.timeEnd("getting color data range")

Expand All @@ -22,7 +27,7 @@ module.exports = function(vars) {

if ( vars.dev.value ) print.time("calculating color scale")

data_range = d3.extent(data_range)
data_range = d3.extent(data_range);

if (data_range[0] < 0 && data_range[1] > 0) {
var color_range = vars.color.range
Expand Down
3 changes: 3 additions & 0 deletions src/viz/methods/color.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ scale = require("../../color/scale.coffee")
module.exports =
accepted: [false, Array, Function, Object, String]
deprecates: "color_var"
domain:
accepted: [false, Array]
value: false
focus: "#444444"
heatmap: ["#282F6B", "#419391", "#AFD5E8", "#EACE3F", "#B35C1E", "#B22200"]
missing: "#eeeeee"
Expand Down

0 comments on commit 3133e81

Please sign in to comment.