Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The source code is on lines 2997- on <a href="http://%20https://github.com/mbostock/d3/blob/master/d3.v2.js" rel="nofollow">d3.v2.js</a>:</p> <pre><code>d3.scale.category20c = function() { return d3.scale.ordinal().range(d3_category20c); }; </code></pre> <p>Which is calling:</p> <pre><code>// lines 2894-2896 d3.scale.ordinal = function() { return d3_scale_ordinal([], {t: "range", x: []}); }; </code></pre> <p>Which then calls </p> <pre><code>// lines 2903-2905 function scale(x) { return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length]; } </code></pre> <p>The parameter passed in, <code>x</code> is set to <code>d3_category20c</code> which assigns colors from the list of 20 available colors seen below:</p> <pre><code>["#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9"] </code></pre> <p>Stepping through the code I see the colors assigned like this (based on the category passed in):</p> <pre><code>cluster = 0 #3182bd graph = 1 #6baed6 optimization = 2 #9ecae1 animate = 3 #c6dbef interpolate = 4 #e6550d converters = 5 #fd8d3c data = 6 #fdae6b display = 7 #fdd0a2 flex = 8 #31a354 physics = 9 #74c476 query = 10 #a1d99b methods = 11 #c7e9c0 scale = 12 #756bb1 util = 13 #9e9ac8 heap = 14 #bcbddc math = 15 #dadaeb palette = 16 #636363 axis = 17 #969696 controls = 18 #bdbdbd render = 19 #d9d9d9 events = 0 #3182bd legend = 1 #6baed6 etc... </code></pre> <p>Note, it's using the mod operator so it can keep assigning colors if the number of passed in categories exceeds the range of 20 colors.</p> <p>Note, the colors for <code>d3_category20c</code> are defined in <a href="https://github.com/mbostock/d3/blob/master/src/scale/category.js" rel="nofollow">category.js</a>, lines 48-54.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload