Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
vega-scale
Advanced tools
Scales and color schemes for visual encoding.
This module provides scale and scheme methods for
managing scale mappings and color schemes. By default, the scale and
scheme registries include all scale types and color schemes provided
by the D3 4.0 d3-scale and
d3-scale-chromatic modules.
In addition, this module provides a new 'index'
scale type for
supporting mappings from a sorted ordinal domain to a continuous range.
Internally, an index scale maps an ordinal domain to a range of
consecutive integer values, which in turn can map to a continuous
output range such as a color ramp or sequential color scheme.
# vega.scale(type[, scale]) <>
Registry function for adding and accessing scale constructor functions.
The type argument is a String indicating the name of the scale type.
If the scale argument is not specified, this method returns the matching
scale constructor in the registry, or null
if not found.
If the scale argument is provided, it must be a scale constructor function
to add to the registry under the given type name.
By default, the scale registry includes entries for all scale types provided
by D3 4.0's d3-scale module. Scales created
using the constructor returned by this method have an additional type
property indicating the scale type. All scales supporting either an invert
or invertExtent
method are augmented with an additional invertRange
function that returns an array of corresponding domain values for a given
interval in the scale's output range.
Scale constructors returned by this method accept two optional parameters:
a scheme string, indicating a valid scheme name applicable to
either 'ordinal'
or 'sequential'
scales; and a reverse boolean,
indicating if a sequential color scheme should be reversed.
// linear scale
var linear = vega.scale('linear');
var scale = linear().domain([0, 10]).range([0, 100]);
scale.type; // 'linear'
scale.invertRange([0, 100]); // [0, 10]
var ordinal = vega.scale('ordinal');
// ordinal scale
var scale1 = ordinal().domain(['a', 'b', 'c']).range([0, 1, 2]);
scale1.type; // 'ordinal'
// ordinal scale with range set to the 'category20' color palette
var scale2 = ordinal(vega.scheme('category20'));
var seq = vega.scale('sequential');
// sequential scale, using the plasma color palette
var scale1 = seq(vega.scheme('plasma'));
scale1.type; // 'sequential'
// sequential scale, using a reversed viridis color palette
var scale2 = seq(vega.scheme('viridis'), true);
# vega.scheme(name[, scheme]) <>
Registry function for adding and accessing color schemes.
The name argument is a String indicating the name of the color scheme.
If the scheme argument is not specified, this method returns the matching
scheme value in the registry, or null
if not found.
If the scheme argument is provided, it must be a valid color array or
interpolator
to add to the registry under the given name.
By default, the scheme registry includes entries for all scheme types
provided by D3 4.0's d3-scale and
d3-scale-chromatic module.
Valid schemes are either arrays of color values (applicable to
'ordinal'
scales) or
interpolator
functions (applicable to 'sequential'
scales.)
FAQs
Scales and color schemes for visual encoding.
The npm package vega-scale receives a total of 70,867 weekly downloads. As such, vega-scale popularity was classified as popular.
We found that vega-scale demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.