MCPcopy Create free account
hub / github.com/idank/explainshell / d3_time_scale

Function d3_time_scale

explainshell/web/static/js/d3.v3.js:8292–8329  ·  view source on GitHub ↗
(linear, methods, format)

Source from the content-addressed store, hash-verified

8290 d3.time.months = d3.time.month.range;
8291 d3.time.months.utc = d3.time.month.utc.range;
8292 function d3_time_scale(linear, methods, format) {
8293 function scale(x) {
8294 return linear(x);
8295 }
8296 scale.invert = function(x) {
8297 return d3_time_scaleDate(linear.invert(x));
8298 };
8299 scale.domain = function(x) {
8300 if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
8301 linear.domain(x);
8302 return scale;
8303 };
8304 scale.nice = function(m) {
8305 return scale.domain(d3_scale_nice(scale.domain(), function() {
8306 return m;
8307 }));
8308 };
8309 scale.ticks = function(m, k) {
8310 var extent = d3_time_scaleExtent(scale.domain());
8311 if (typeof m !== "function") {
8312 var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target);
8313 if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
8314 if (!i) return linear.ticks(m).map(d3_time_scaleDate);
8315 if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i;
8316 m = methods[i];
8317 k = m[1];
8318 m = m[0].range;
8319 }
8320 return m(extent[0], new Date(+extent[1] + 1), k);
8321 };
8322 scale.tickFormat = function() {
8323 return format;
8324 };
8325 scale.copy = function() {
8326 return d3_time_scale(linear.copy(), methods, format);
8327 };
8328 return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
8329 }
8330 function d3_time_scaleExtent(domain) {
8331 var start = domain[0], stop = domain[domain.length - 1];
8332 return start < stop ? [ start, stop ] : [ stop, start ];

Callers 1

d3.v3.jsFile · 0.85

Calls 4

d3_time_scaleDateFunction · 0.85
d3_scale_niceFunction · 0.85
d3_time_scaleExtentFunction · 0.85
mFunction · 0.70

Tested by

no test coverage detected