/**
* Returns a new categorical color encoding using the specified colors. The
* arguments to this method are an array of colors; see {@link pv.color}. For
* example, to create a categorical color encoding using the species
* attribute:
*
*
pv.colors("red", "green", "blue").by(function(d) d.species)
*
* The result of this expression can be used as a fill- or stroke-style
* property. This assumes that the data's species attribute is a
* string.
*
* @param {string} colors... categorical colors.
* @see pv.Scale.ordinal
* @returns {pv.Scale.ordinal} an ordinal color scale.
*/
pv.colors = function() {
var scale = pv.Scale.ordinal();
scale.range.apply(scale, arguments);
return scale;
};
/**
* A collection of standard color palettes for categorical encoding.
*
* @namespace A collection of standard color palettes for categorical encoding.
*/
pv.Colors = {};
/**
* Returns a new 10-color scheme. The arguments to this constructor are
* optional, and equivalent to calling {@link pv.Scale.OrdinalScale#domain}. The
* following colors are used:
*
* #1f77b4
* #ff7f0e
* #2ca02c
* #d62728
* #9467bd
* #8c564b
* #e377c2
* #7f7f7f
* #bcbd22
* #17becf
*
* @param {number...} domain... domain values.
* @returns {pv.Scale.ordinal} a new ordinal color scale.
* @see pv.color
*/
pv.Colors.category10 = function() {
var scale = pv.colors(
"#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
"#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf");
scale.domain.apply(scale, arguments);
return scale;
};
/**
* Returns a new 20-color scheme. The arguments to this constructor are
* optional, and equivalent to calling {@link pv.Scale.OrdinalScale#domain}. The
* following colors are used:
*
* #1f77b4
* #aec7e8
* #ff7f0e
* #ffbb78
* #2ca02c
* #98df8a
* #d62728
* #ff9896
* #9467bd
* #c5b0d5
* #8c564b
* #c49c94
* #e377c2
* #f7b6d2
* #7f7f7f
* #c7c7c7
* #bcbd22
* #dbdb8d
* #17becf
* #9edae5
*
* @param {number...} domain... domain values.
* @returns {pv.Scale.ordinal} a new ordinal color scale.
* @see pv.color
*/
pv.Colors.category20 = function() {
var scale = pv.colors(
"#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c",
"#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5",
"#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f",
"#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5");
scale.domain.apply(scale, arguments);
return scale;
};
/**
* Returns a new alternative 19-color scheme. The arguments to this constructor
* are optional, and equivalent to calling
* {@link pv.Scale.OrdinalScale#domain}. The following colors are used:
*
* #9c9ede
* #7375b5
* #4a5584
* #cedb9c
* #b5cf6b
* #8ca252
* #637939
* #e7cb94
* #e7ba52
* #bd9e39
* #8c6d31
* #e7969c
* #d6616b
* #ad494a
* #843c39
* #de9ed6
* #ce6dbd
* #a55194
* #7b4173
*
* @param {number...} domain... domain values.
* @returns {pv.Scale.ordinal} a new ordinal color scale.
* @see pv.color
*/
pv.Colors.category19 = function() {
var scale = pv.colors(
"#9c9ede", "#7375b5", "#4a5584", "#cedb9c", "#b5cf6b",
"#8ca252", "#637939", "#e7cb94", "#e7ba52", "#bd9e39",
"#8c6d31", "#e7969c", "#d6616b", "#ad494a", "#843c39",
"#de9ed6", "#ce6dbd", "#a55194", "#7b4173");
scale.domain.apply(scale, arguments);
return scale;
};