MCPcopy Create free account
hub / github.com/microsoft/SandDance / configureBins

Function configureBins

docs/app/js/sanddance-app.js:130044–130070  ·  view source on GitHub ↗
(scale, _, count)

Source from the content-addressed store, hash-verified

130042 return domain;
130043}
130044function configureBins(scale, _, count) {
130045 let bins = _.bins;
130046 if (bins && !(0, _vegaUtil.isArray)(bins)) {
130047 // generate bin boundary array
130048 const domain = scale.domain(), lo = domain[0], hi = (0, _vegaUtil.peek)(domain), step = bins.step;
130049 let start = bins.start == null ? lo : bins.start, stop = bins.stop == null ? hi : bins.stop;
130050 if (!step) (0, _vegaUtil.error)("Scale bins parameter missing step property.");
130051 if (start < lo) start = step * Math.ceil(lo / step);
130052 if (stop > hi) stop = step * Math.floor(hi / step);
130053 bins = (0, _d3Array.range)(start, stop + step / 2, step);
130054 }
130055 if (bins) // assign bin boundaries to scale instance
130056 scale.bins = bins;
130057 else if (scale.bins) // no current bins, remove bins if previously set
130058 delete scale.bins;
130059 // special handling for bin-ordinal scales
130060 if (scale.type === (0, _vegaScale.BinOrdinal)) {
130061 if (!bins) // the domain specifies the bins
130062 scale.bins = scale.domain();
130063 else if (!_.domain && !_.domainRaw) {
130064 // the bins specify the domain
130065 scale.domain(bins);
130066 count = bins.length;
130067 }
130068 } // return domain cardinality
130069 return count;
130070}
130071function configureRange(scale, _, count) {
130072 var type = scale.type, round = _.round || false, range = _.range; // if range step specified, calculate full range extent
130073 if (_.rangeStep != null) range = configureRangeStep(type, _, count);

Callers 1

transformFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected