Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
color: function() {
// i am cool with dc.js's color accessor
if(_.has(defn, 'color'))
chart.colorAccessor(key_value(accessor(defn.color)));
// however i don't understand why dc chooses to use a
// "color calculator" when a d3 scale seems like it ought
// to serve the purpose. so just plug a d3 scale into colors
// and override the calculator to use it
// also default to category10 which seems better for discrete colors
var scale = defn['color.scale'];
if(_.has(defn, 'color.domain'))
scale.domain(defn['color.domain']);
if(_.has(defn, 'color.range'))
scale.range(defn['color.range']);
chart.colors(scale);
chart.colorCalculator(function(x) { return chart.colors()(x); });
},
stackable: function() {
color: function() {
// i am cool with dc.js's color accessor
if(_.has(defn, 'color'))
chart.colorAccessor(key_value(accessor(defn.color)));
// however i don't understand why dc chooses to use a
// "color calculator" when a d3 scale seems like it ought
// to serve the purpose. so just plug a d3 scale into colors
// and override the calculator to use it
// also default to category10 which seems better for discrete colors
var scale = defn['color.scale'] || d3.scale.category10();
if(_.has(defn, 'color.domain'))
scale.domain(defn['color.domain']);
else if(mhas(defn, 'color', 'attrs', 'levels'))
scale.domain(defn.color.attrs.levels);
if(_.has(defn, 'color.range'))
scale.range(defn['color.range']);
chart.colors(scale);
chart.colorCalculator(function(x) { return chart.colors()(x); });
},
stackable: function() {
create: function(definition, object, groupname, frame, defn, dims, groups, errors) {
if(_.has(defn, 'color'))
object.chart.colorAccessor(dcplot.key_value(dcplot.accessor(frame, defn.color)));
var scale = defn['color.scale'];
if(_.has(defn, 'color.domain'))
scale.domain(defn['color.domain']);
if(_.has(defn, 'color.range'))
scale.range(defn['color.range']);
object.chart.colors(scale);
}
},