MCPcopy Index your code
hub / github.com/microsoft/SandDance / linearish

Function linearish

docs/app/js/sanddance-app.js:127399–127441  ·  view source on GitHub ↗
(scale)

Source from the content-addressed store, hash-verified

127397var _tickFormatJs = require("./tickFormat.js");
127398var _tickFormatJsDefault = parcelHelpers.interopDefault(_tickFormatJs);
127399function linearish(scale) {
127400 var domain = scale.domain;
127401 scale.ticks = function(count) {
127402 var d = domain();
127403 return (0, _d3Array.ticks)(d[0], d[d.length - 1], count == null ? 10 : count);
127404 };
127405 scale.tickFormat = function(count, specifier) {
127406 var d = domain();
127407 return (0, _tickFormatJsDefault.default)(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
127408 };
127409 scale.nice = function(count) {
127410 if (count == null) count = 10;
127411 var d = domain();
127412 var i0 = 0;
127413 var i1 = d.length - 1;
127414 var start = d[i0];
127415 var stop = d[i1];
127416 var prestep;
127417 var step;
127418 var maxIter = 10;
127419 if (stop < start) {
127420 step = start, start = stop, stop = step;
127421 step = i0, i0 = i1, i1 = step;
127422 }
127423 while(maxIter-- > 0){
127424 step = (0, _d3Array.tickIncrement)(start, stop, count);
127425 if (step === prestep) {
127426 d[i0] = start;
127427 d[i1] = stop;
127428 return domain(d);
127429 } else if (step > 0) {
127430 start = Math.floor(start / step) * step;
127431 stop = Math.ceil(stop / step) * step;
127432 } else if (step < 0) {
127433 start = Math.ceil(start * step) / step;
127434 stop = Math.floor(stop * step) / step;
127435 } else break;
127436 prestep = step;
127437 }
127438 return scale;
127439 };
127440 return scale;
127441}
127442function linear() {
127443 var scale = (0, _continuousJsDefault.default)();
127444 scale.copy = function() {

Callers 1

linearFunction · 0.70

Calls 1

domainFunction · 0.70

Tested by

no test coverage detected