How to use the color.x function in color

To help you get started, we’ve selected a few color examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github att / rcloud / htdocs / lib / js / dcplot.js View on Github external
bar: function() {
                        if(_.has(defn, 'centerBar'))
                            chart.centerBar(defn.centerBar);
                        if(_.has(defn, 'gap'))
                            chart.gap(defn.gap);
                        // optionally color the bars when ordinal and not stacked or one stack
                        if(_.has(defn,'x.ordinal') && defn['x.ordinal'] && defn['color.x'] && one_stack(defn)) {
                            chart.renderlet(function(chart) {
                                chart.selectAll("rect.bar").style('fill', function(d,i) {
                                    if(d3.select(this).classed(dc.constants.DESELECTED_CLASS))
                                        return null;
                                    else return chart.colors()(d.x);
                                });
                            });
                        }
                        else if(!one_stack(defn)) {
                            // dc.js does not automatically color the stacks different colors (!)
                            chart.renderlet(function(chart) {
                                chart.selectAll("g."+dc.constants.STACK_CLASS)
                                    .each(function(d,i) {
                                        var stack = defn['stack.levels'][i];
                                        d3.select(this).selectAll("rect.bar")
                                            .style('fill', function(d,i) {
github att / rcloud / htdocs / lib / js / dcplot.js View on Github external
bar: function() {
                        /* in practice, dc's xUnits seem to be based on either the bin width
                         for a histogram, or the set of ordinals */
                        if(!('x.units' in defn) && defn.group) {
                            var group = groups[defn.group];
                            if(mhas(group, 'group', 'binwidth'))
                                defn['x.units'] = dc.units.fp.precision(group.group.binwidth);
                        }
                        if(!_.has(defn, 'color.domain')) {
                            var levels;
                            if(one_stack(defn)) {
                                if(defn['color.x']) {
                                    levels = get_levels(defn.dimension);
                                    if(levels)
                                        defn['color.domain'] = levels;
                                }
                            }
                            else {
                                levels = get_levels(defn.stack);
                                if(levels)
                                    defn['color.domain'] = levels;
                            }
                        }
                    },
                    line: function() {
github att / rcloud.dcplot / inst / www / dcplot.js View on Github external
infer: function(definition, name, frame, defn, dims, groups, errors) {
            /* in practice, dc's xUnits seem to be based on either the bin width
             for a histogram, or the set of ordinals */
            if(!('x.units' in defn) && defn.group) {
                var group = groups[defn.group];
                if(dcplot.mhas(group, 'group', 'binwidth'))
                    defn['x.units'] = dc.units.fp.precision(group.group.binwidth);
            }
            if(!_.has(defn, 'color.domain')) {
                var levels;
                if(this.one_stack(defn)) {
                    if(defn['color.x']) {
                        levels = dcplot.get_levels(frame, dims, defn.dimension);
                        if(levels)
                            defn['color.domain'] = levels;
                    }
                }
                else {
                    levels = dcplot.get_levels(frame, dims, defn.stack);
                    if(levels)
                        defn['color.domain'] = levels;
                }
            }
        },
        create: function(definition, object, groupname, frame, defn, dims, groups, errors) {
github att / rcloud.dcplot / inst / www / dcplot.js View on Github external
create: function(definition, object, groupname, frame, defn, dims, groups, errors) {
            if(_.has(defn, 'centerBar'))
                object.chart.centerBar(defn.centerBar);
            if(_.has(defn, 'gap'))
                object.chart.gap(defn.gap);
            // optionally color the bars when ordinal and not stacked or one stack
            if(_.has(defn,'x.ordinal') && defn['x.ordinal'] && defn['color.x'] && this.one_stack(defn)) {
                object.chart.renderlet(function(chart) {
                    chart.selectAll('rect.bar').style('fill', function(d,i) {
                        if(d3.select(this).classed(dc.constants.DESELECTED_CLASS))
                            return null;
                        else return chart.colors()(d.x);
                    });
                });
            }
            else if(!this.one_stack(defn)) {
                // dc.js does not automatically color the stacks different colors (!)
                object.chart.renderlet(function(chart) {
                    chart.selectAll('g.'+dc.constants.STACK_CLASS)
                        .each(function(d,i) {
                            var stack = defn['stack.levels'][i];
                            d3.select(this).selectAll('rect.bar')
                                .style('fill', function(d,i) {