...
 
Commits (2)
......@@ -50,28 +50,14 @@ function scale(data, config) {
}
if (config.scheme) {
config.range = {scheme: config.scheme}
config.range = { scheme: config.scheme }
if (continous_scales.indexOf(scale) < 0 && config.count) {
config.range.count = config.count
}
}
}
if (!config.domain) {
config.domain = {metric: config.metric}
}
// Range Resolver
if (!Array.isArray(config.range)) {
// if Continous scale
if (continous_scales.indexOf(scale) >= 0) {
range = [0, 1]
} else {
// discrete without config.count (provide default count)
d3_scheme = d3['scheme' + config.range.scheme]
config.count = config.range.count ? config.range.count : d3_scheme.length
// for schemeBlues kind of discrete ranges, the k value is [3, 9].
// First 3 values are empty
range = typeof d3_scheme[0] == 'string' ? d3_scheme : d3_scheme[config.count]
}
config.domain = { metric: config.metric }
}
// Domain Resolver
......@@ -88,6 +74,21 @@ function scale(data, config) {
}
}
// Range Resolver
if (!Array.isArray(config.range)) {
// if Continous scale
if (continous_scales.indexOf(scale) >= 0) {
range = [0, 1]
} else {
// discrete without config.count (provide default count)
d3_scheme = d3['scheme' + config.range.scheme]
config.count = config.range.count ? config.range.count : d3_scheme.length
// For discrete colors ranges like schemeBlues, the k value is [3, 9].
// First 3 values are empty (non-string types)
range = typeof d3_scheme[0] == 'string' ? d3_scheme : d3_scheme[config.count]
}
}
if (config.reverse) {
// Quantize/Quantile/Threshold scales sorts the domain by ascending order
// So, no point in reversing domain. Instead reverse color scheme range
......