How to use the d3-color.rgb function in d3-color

To help you get started, we’ve selected a few d3-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 vega / vega / packages / vega-geo / src / Heatmap.js View on Github external
function color_(color, _) {
  let f;
  if (isFunction(color)) {
    f = obj => rgb(color(obj, _));
    f.dep = dependency(color);
  } else {
    // default to mid-grey
    f = constant(rgb(color || '#888'));
  }
  return f;
}
github darosh / angular-swagger-ui-material / lib / api-models-rainbows / index.js View on Github external
.on('parsed', function () {
                        console.log(name);
                        colors[key] = colorgram.extract({
                            data: this.data,
                            width: this.width,
                            height: this.height,
                            channels: 4
                        }, bgColor ? (COLORS - 1) : COLORS);

                        if (bgColor) {
                            var r = d3Color.rgb(bgColor);
                            colors[key].push([r.r, r.g, r.b, 1]);
                        }

                        colors[key].forEach(function (c) {
                            c.pop();

                            var n = d3Color.rgb(c[0], c[1], c[2], 1);
                            var h = d3Color.cubehelix(n);
                            h.s = Math.max(h.s, 1);
                            h.l = Math.max(h.l, 0.8);
                            h.l = Math.min(h.l, 1.2);

                            c[0] = h.h;
                            c[1] = h.s;
                            c[2] = h.l;
                        });
github khartec / waltz / waltz-ng / client / common / colors.js View on Github external
.range([red, amber, green, grey.darker()]);


export const authoritativeRatingBackgroundColorScale = scaleOrdinal()
    .domain(["DISCOURAGED", "SECONDARY", "PRIMARY", "NO_OPINION"])
    .range([redBg, amberBg, greenBg, greyBg]);


export const environmentColorScale = scaleOrdinal()
    .domain(["DEV", "PREPROD", "PROD", "QA", "UAT", "DR"])
    .range([green, amber, gold, purple, pink, blue]);


export const operatingSystemColorScale = scaleOrdinal()
    .domain(["Windows", "Linux", "AS/400", "OS/390", "AIX", "Solaris"])
    .range([blue, green, rgb("#777"), rgb("#555"), rgb("#473"), amber]);


export const lifecyclePhaseColorScale = scaleOrdinal()
    .domain(["PRODUCTION", "CONCEPTUAL", "DEVELOPMENT", "RETIRED"])
    .range([gold, blue, green, grey]);

export const attestationStatusColorScale = scaleOrdinal()
    .domain(["ATTESTED", "NEVER_ATTESTED"])
    .range([green, grey]);


export const criticalityColorScale = scaleOrdinal()
    .domain(["LOW", "MEDIUM", "HIGH", "VERY_HIGH", "NONE", "UNKNOWN"])
    .range([green, amber, red, red.darker(), grey, grey.darker()]);
github plouc / nivo / packages / colors / src / inheritedColor.js View on Github external
return datum =>
                    modifiers
                        .reduce((color, modify) => modify(color), rgb(getColor(datum)))
                        .toString()
            }
github d2bjs / d2b / src / scripts / svg / point.js View on Github external
.addPropFunctor('stroke', function (d, i) {
      return rgb($$.fill.call(this, d, i)).darker(0.3);
    })
    .addPropFunctor('strokeWidth', '1px');
github conversationai / perspectiveapi-authorship-demo / src / app / modules / convai-checker / convai-checker.component.spec.ts View on Github external
function verifyColorsAlmostEqual(color1: string, color2: string, maxDistance = 1) {
  const rgb1 = d3.rgb(color1);
  const rgb2 = d3.rgb(color2);
  expect(Math.sqrt(Math.pow(rgb1.r - rgb2.r, 2)
                   + Math.pow(rgb1.g - rgb2.g, 2)
                   + Math.pow(rgb1.b - rgb2.b, 2)))
    .toBeLessThanOrEqual(maxDistance);
}
github BigFatDog / auth-flow-react-apollo-saga / app / containers / Vartan / algs.js View on Github external
const toVectorColor = colorStr => {
  const _rgb = rgb(colorStr);
  return [_rgb.r / 255, _rgb.g / 255, _rgb.b / 255];
};
github d3 / d3-hsv / src / hsv.js View on Github external
function hsv2rgb(r1, g1, b1, m, a) {
  return rgb((r1 + m) * 255, (g1 + m) * 255, (b1 + m) * 255, a);
}
github hpcc-systems / Visualization / packages / form / src / ColorInput.ts View on Github external
e.on("change", function (w) {
                if (idx === 0) {
                    context._inputElement[1].property("value", d3Rgb(context._inputElement[0].property("value")).toString());
                    context.value(context._inputElement[0].property("value"));
                } else {
                    context._inputElement[0].property("value", context._inputElement[1].property("value"));
                    context.value(d3Rgb(context._inputElement[1].property("value")).toString());
                }
                w.change(w, true);
            });
        });
github khartec / waltz / waltz-ng / client / common / colors.js View on Github external
*
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific
 *
 */
import {rgb} from "d3-color";
import {scaleOrdinal, schemeCategory20c} from "d3-scale";
import _ from "lodash";

export const black = rgb("#000");
export const amber = rgb("#D9923F");
export const green = rgb("#5BB65D");
export const red = rgb("#DA524B");
export const pink = rgb("#ffcffc");
export const grey = rgb("#939393");
export const lightGrey = rgb("#d1d1d1");
export const blue = rgb("#5271CC");
export const purple= rgb("#B687CC");
export const gold = rgb("#b7b04e");
export const actor = rgb("#d7bbdb");

export const amberBg = rgb("#FCF2D7");
export const greenBg = rgb("#DFF1D2");
export const redBg = rgb("#F2D7D7");
export const greyBg = rgb("#F5F5F5");
export const actorBg = rgb("#ede5ee");

d3-color

Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).

ISC
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis