Commit bda5d676 authored by Tejesh's avatar Tejesh 🖖
Browse files

reorder code

parent 18777855
Pipeline #92718 passed with stage
in 2 minutes and 25 seconds
......@@ -72,20 +72,6 @@ function backward_compat(config, _scale) {
return config
}
function scale(data, config) {
var _scale = upperFirst(config.scale || 'Linear')
config = backward_compat(config, _scale)
var result = d3['scale' + (renames[_scale] || _scale)]()
.domain(get_domain(data, config.domain, config.metric, _scale))
.range(flip(get_range(config.range, _scale), config.range.reverse === true || config.reverse))
return (scale_types[_scale] == 'continuous' && !Array.isArray(config.range)) ?
(val) => d3['interpolate' + config.range.scheme](result(typeof val === 'object' ? iteratee(config.metric)(val) : val))
: (val) => result(typeof val === 'object' ? iteratee(config.metric)(val) : val)
}
function get_domain(data, config_domain, metric, scale) {
return Array.isArray(config_domain) && scale != 'Quantile' ? config_domain
: domain_function[scale_types[scale]](data.map(iteratee(metric)))
......@@ -110,4 +96,18 @@ function get_colors_from_scheme(scheme, count) {
return Object.values(scheme).length !== scheme.length ? scheme[count ? count : scheme.length - 1] : scheme
}
function scale(data, config) {
var _scale = upperFirst(config.scale || 'Linear')
config = backward_compat(config, _scale)
var result = d3['scale' + (renames[_scale] || _scale)]()
.domain(get_domain(data, config.domain, config.metric, _scale))
.range(flip(get_range(config.range, _scale), config.range.reverse === true || config.reverse))
return (scale_types[_scale] == 'continuous' && !Array.isArray(config.range)) ?
(val) => d3['interpolate' + config.range.scheme](result(typeof val === 'object' ? iteratee(config.metric)(val) : val))
: (val) => result(typeof val === 'object' ? iteratee(config.metric)(val) : val)
}
export { scale }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment