Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@d3fc/d3fc-axis

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@d3fc/d3fc-axis - npm Package Compare versions

Comparing version 2.2.5 to 2.3.0

1092

build/d3fc-axis.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-shape')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-shape'], factory) :
(global = global || self, factory(global.fc = global.fc || {}, global.d3, global.d3));
}(this, function (exports, d3Selection, d3Shape) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@d3fc/d3fc-rebind'), require('d3-selection'), require('d3-shape'), require('@d3fc/d3fc-data-join')) :
typeof define === 'function' && define.amd ? define(['exports', '@d3fc/d3fc-rebind', 'd3-selection', 'd3-shape', '@d3fc/d3fc-data-join'], factory) :
(global = global || self, factory(global.fc = global.fc || {}, global.fc, global.d3, global.d3, global.fc));
}(this, function (exports, d3fcRebind, d3Selection, d3Shape, d3fcDataJoin) { 'use strict';
var createReboundMethod = ((target, source, name) => {
const method = source[name];
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
if (typeof method !== 'function') {
throw new Error(`Attempt to rebind ${name} which isn't a function on the source object`);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
return (...args) => {
var value = method.apply(source, args);
return value === source ? target : value;
};
});
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
const createTransform = transforms => name => transforms.reduce((name, fn) => name && fn(name), name);
return arr2;
}
}
var rebindAll = ((target, source, ...transforms) => {
const transform = createTransform(transforms);
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
for (const name of Object.keys(source)) {
const result = transform(name);
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
if (result) {
target[result] = createReboundMethod(target, source, name);
}
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
return target;
});
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
var regexify = (strsOrRegexes => strsOrRegexes.map(strOrRegex => typeof strOrRegex === 'string' ? new RegExp(`^${strOrRegex}$`) : strOrRegex));
var exclude = ((...exclusions) => {
exclusions = regexify(exclusions);
return name => exclusions.every(exclusion => !exclusion.test(name)) && name;
});
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
if (i && _arr.length === i) break;
}
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
} catch (err) {
_d = true;
_e = err;
} finally {
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
if (!_n && _i["return"] != null) _i["return"]();
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
if (_d) throw _e;
}
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
// "Caution: avoid interpolating to or from the number zero when the interpolator is used to generate
// a string (such as with attr).
// Very small values, when stringified, may be converted to scientific notation and
// cause a temporarily invalid attribute or style property value.
// For example, the number 0.0000001 is converted to the string "1e-7".
// This is particularly noticeable when interpolating opacity values.
// To avoid scientific notation, start or end the transition at 1e-6,
// which is the smallest value that is not stringified in exponential notation."
// - https://github.com/mbostock/d3/wiki/Transitions#d3_interpolateNumber
const effectivelyZero = 1e-6; // Wrapper around d3's selectAll/data data-join, which allows decoration of the result.
// This is achieved by appending the element to the enter selection before exposing it.
// A default transition of fade in/out is also implicitly added but can be modified.
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var _dataJoin = ((element, className) => {
element = element || 'g';
var identity = function identity(d) {
return d;
};
let key = (_, i) => i;
var axisBase = function axisBase(orient, scale) {
var custom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var tickArguments = [10];
var tickValues = null;
let explicitTransition = null;
var decorate = function decorate() {};
const dataJoin = function (container, data) {
data = data || (d => d);
var tickFormat = null;
var tickSizeOuter = 6;
var tickSizeInner = 6;
var tickPadding = 3;
var svgDomainLine = d3Shape.line();
const implicitTransition = container.selection ? container : null;
var dataJoin = d3fcDataJoin.dataJoin('g', 'tick').key(identity);
if (implicitTransition) {
container = container.selection();
}
var domainPathDataJoin = d3fcDataJoin.dataJoin('path', 'domain');
const selected = container.selectAll((d, i, nodes) => Array.from(nodes[i].childNodes).filter(node => node.nodeType === 1)).filter(className == null ? element : `${element}.${className}`);
let update = selected.data(data, key);
const enter = update.enter().append(element).attr('class', className);
let exit = update.exit(); // automatically merge in the enter selection
update = update.merge(enter); // if transitions are enabled apply a default fade in/out transition
const transition = implicitTransition || explicitTransition;
if (transition) {
update = update.transition(transition).style('opacity', 1);
enter.style('opacity', effectivelyZero);
exit = exit.transition(transition).style('opacity', effectivelyZero);
}
exit.remove();
update.enter = () => enter;
update.exit = () => exit;
return update;
var defaultLabelOffset = function defaultLabelOffset() {
return {
offset: [0, tickSizeInner + tickPadding]
};
};
dataJoin.element = (...args) => {
if (!args.length) {
return element;
}
element = args[0];
return dataJoin;
var defaultTickPath = function defaultTickPath() {
return {
path: [[0, 0], [0, tickSizeInner]]
};
};
dataJoin.className = (...args) => {
if (!args.length) {
return className;
}
var labelOffset = custom.labelOffset || defaultLabelOffset;
var tickPath = custom.tickPath || defaultTickPath; // returns a function that creates a translation based on
// the bound data
className = args[0];
return dataJoin;
};
var containerTranslate = function containerTranslate(scale, trans) {
var offset = 0;
dataJoin.key = (...args) => {
if (!args.length) {
return key;
}
if (scale.bandwidth) {
offset = scale.bandwidth() / 2;
key = args[0];
return dataJoin;
};
dataJoin.transition = (...args) => {
if (!args.length) {
return explicitTransition;
if (scale.round()) {
offset = Math.round(offset);
}
}
explicitTransition = args[0];
return dataJoin;
return function (d) {
return trans(scale(d) + offset, 0);
};
};
return dataJoin;
});
var translate = function translate(x, y) {
return isVertical() ? "translate(".concat(y, ", ").concat(x, ")") : "translate(".concat(x, ", ").concat(y, ")");
};
var identity = function identity(d) {
return d;
var pathTranspose = function pathTranspose(arr) {
return isVertical() ? arr.map(function (d) {
return [d[1], d[0]];
}) : arr;
};
var axisBase = function axisBase(orient, scale) {
var custom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var tickArguments = [10];
var tickValues = null;
var isVertical = function isVertical() {
return orient === 'left' || orient === 'right';
};
var decorate = function decorate() {};
var tryApply = function tryApply(fn, args, defaultVal) {
return scale[fn] ? scale[fn].apply(scale, args) : defaultVal;
};
var tickFormat = null;
var tickSizeOuter = 6;
var tickSizeInner = 6;
var tickPadding = 3;
var svgDomainLine = d3Shape.line();
var axis = function axis(selection) {
if (selection.selection) {
dataJoin.transition(selection);
domainPathDataJoin.transition(selection);
}
var dataJoin = _dataJoin('g', 'tick').key(identity);
selection.each(function (data, index, group) {
var element = group[index];
var container = d3Selection.select(element);
var domainPathDataJoin = _dataJoin('path', 'domain');
if (!element.__scale__) {
container.attr('fill', 'none').attr('font-size', 10).attr('font-family', 'sans-serif').attr('text-anchor', orient === 'right' ? 'start' : orient === 'left' ? 'end' : 'middle');
} // Stash a snapshot of the new scale, and retrieve the old snapshot.
var defaultLabelOffset = function defaultLabelOffset() {
return {
offset: [0, tickSizeInner + tickPadding]
};
};
var defaultTickPath = function defaultTickPath() {
return {
path: [[0, 0], [0, tickSizeInner]]
};
};
var scaleOld = element.__scale__ || scale;
element.__scale__ = scale.copy();
var ticksArray = tickValues == null ? tryApply('ticks', tickArguments, scale.domain()) : tickValues;
var tickFormatter = tickFormat == null ? tryApply('tickFormat', tickArguments, identity) : tickFormat;
var sign = orient === 'bottom' || orient === 'right' ? 1 : -1;
var labelOffset = custom.labelOffset || defaultLabelOffset;
var tickPath = custom.tickPath || defaultTickPath; // returns a function that creates a translation based on
// the bound data
var withSign = function withSign(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
x = _ref2[0],
y = _ref2[1];
var containerTranslate = function containerTranslate(scale, trans) {
var offset = 0;
return [x, sign * y];
}; // add the domain line
if (scale.bandwidth) {
offset = scale.bandwidth() / 2;
if (scale.round()) {
offset = Math.round(offset);
}
}
var range = scale.range();
var domainPathData = pathTranspose([[range[0], sign * tickSizeOuter], [range[0], 0], [range[1], 0], [range[1], sign * tickSizeOuter]]);
var domainLine = domainPathDataJoin(container, [data]);
domainLine.attr('d', svgDomainLine(domainPathData)).attr('stroke', '#000');
var g = dataJoin(container, ticksArray);
var labelOffsets = ticksArray.map(function (d, i) {
return labelOffset(d, i, ticksArray);
});
var tickPaths = ticksArray.map(function (d, i) {
return tickPath(d, i, ticksArray);
}); // enter
return function (d) {
return trans(scale(d) + offset, 0);
};
};
g.enter().attr('transform', containerTranslate(scaleOld, translate)).append('path').attr('stroke', '#000');
g.enter().append('text').attr('transform', function (d, i) {
return translate.apply(void 0, _toConsumableArray(withSign(labelOffsets[i].offset)));
}).attr('fill', '#000'); // exit
var translate = function translate(x, y) {
return isVertical() ? "translate(".concat(y, ", ").concat(x, ")") : "translate(".concat(x, ", ").concat(y, ")");
};
g.exit().attr('transform', containerTranslate(scale, translate)); // update
var pathTranspose = function pathTranspose(arr) {
return isVertical() ? arr.map(function (d) {
return [d[1], d[0]];
}) : arr;
};
g.select('path').attr('visibility', function (d, i) {
return tickPaths[i].hidden && 'hidden';
}).attr('d', function (d, i) {
return svgDomainLine(pathTranspose(tickPaths[i].path.map(withSign)));
});
g.select('text').attr('visibility', function (d, i) {
return labelOffsets[i].hidden && 'hidden';
}).attr('transform', function (d, i) {
return translate.apply(void 0, _toConsumableArray(withSign(labelOffsets[i].offset)));
}).attr('dy', function () {
var offset = '0em';
var isVertical = function isVertical() {
return orient === 'left' || orient === 'right';
};
if (isVertical()) {
offset = '0.32em';
} else if (orient === 'bottom') {
offset = '0.71em';
}
var tryApply = function tryApply(fn, args, defaultVal) {
return scale[fn] ? scale[fn].apply(scale, args) : defaultVal;
};
return offset;
}).text(tickFormatter);
g.attr('transform', containerTranslate(scale, translate));
decorate(g, data, index);
});
};
var axis = function axis(selection) {
if (selection.selection) {
dataJoin.transition(selection);
domainPathDataJoin.transition(selection);
}
axis.tickFormat = function () {
if (!arguments.length) {
return tickFormat;
}
selection.each(function (data, index, group) {
var element = group[index];
var container = d3Selection.select(element);
tickFormat = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
if (!element.__scale__) {
container.attr('fill', 'none').attr('font-size', 10).attr('font-family', 'sans-serif').attr('text-anchor', orient === 'right' ? 'start' : orient === 'left' ? 'end' : 'middle');
} // Stash a snapshot of the new scale, and retrieve the old snapshot.
axis.tickSize = function () {
if (!arguments.length) {
return tickSizeInner;
}
tickSizeInner = tickSizeOuter = Number(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
var scaleOld = element.__scale__ || scale;
element.__scale__ = scale.copy();
var ticksArray = tickValues == null ? tryApply('ticks', tickArguments, scale.domain()) : tickValues;
var tickFormatter = tickFormat == null ? tryApply('tickFormat', tickArguments, identity) : tickFormat;
var sign = orient === 'bottom' || orient === 'right' ? 1 : -1;
axis.tickSizeInner = function () {
if (!arguments.length) {
return tickSizeInner;
}
var withSign = function withSign(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
x = _ref2[0],
y = _ref2[1];
tickSizeInner = Number(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
return [x, sign * y];
}; // add the domain line
axis.tickSizeOuter = function () {
if (!arguments.length) {
return tickSizeOuter;
}
tickSizeOuter = Number(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
var range = scale.range();
var domainPathData = pathTranspose([[range[0], sign * tickSizeOuter], [range[0], 0], [range[1], 0], [range[1], sign * tickSizeOuter]]);
var domainLine = domainPathDataJoin(container, [data]);
domainLine.attr('d', svgDomainLine(domainPathData)).attr('stroke', '#000');
var g = dataJoin(container, ticksArray);
var labelOffsets = ticksArray.map(function (d, i) {
return labelOffset(d, i, ticksArray);
});
var tickPaths = ticksArray.map(function (d, i) {
return tickPath(d, i, ticksArray);
}); // enter
axis.tickPadding = function () {
if (!arguments.length) {
return tickPadding;
}
g.enter().attr('transform', containerTranslate(scaleOld, translate)).append('path').attr('stroke', '#000');
g.enter().append('text').attr('transform', function (d, i) {
return translate.apply(void 0, _toConsumableArray(withSign(labelOffsets[i].offset)));
}).attr('fill', '#000'); // exit
tickPadding = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
g.exit().attr('transform', containerTranslate(scale, translate)); // update
axis.decorate = function () {
if (!arguments.length) {
return decorate;
}
g.select('path').attr('visibility', function (d, i) {
return tickPaths[i].hidden && 'hidden';
}).attr('d', function (d, i) {
return svgDomainLine(pathTranspose(tickPaths[i].path.map(withSign)));
});
g.select('text').attr('visibility', function (d, i) {
return labelOffsets[i].hidden && 'hidden';
}).attr('transform', function (d, i) {
return translate.apply(void 0, _toConsumableArray(withSign(labelOffsets[i].offset)));
}).attr('dy', function () {
var offset = '0em';
decorate = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
if (isVertical()) {
offset = '0.32em';
} else if (orient === 'bottom') {
offset = '0.71em';
}
axis.scale = function () {
if (!arguments.length) {
return scale;
}
return offset;
}).text(tickFormatter);
g.attr('transform', containerTranslate(scale, translate));
decorate(g, data, index);
});
};
scale = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
axis.tickFormat = function () {
if (!arguments.length) {
return tickFormat;
}
axis.ticks = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
tickFormat = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
tickArguments = [].concat(args);
return axis;
};
axis.tickSize = function () {
if (!arguments.length) {
return tickSizeInner;
}
axis.tickArguments = function () {
if (!arguments.length) {
return tickArguments.slice();
}
tickSizeInner = tickSizeOuter = Number(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
tickArguments = (arguments.length <= 0 ? undefined : arguments[0]) == null ? [] : _toConsumableArray(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
axis.tickSizeInner = function () {
if (!arguments.length) {
return tickSizeInner;
}
axis.tickValues = function () {
if (!arguments.length) {
return tickValues.slice();
}
tickSizeInner = Number(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
tickValues = (arguments.length <= 0 ? undefined : arguments[0]) == null ? [] : _toConsumableArray(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
axis.tickSizeOuter = function () {
if (!arguments.length) {
return tickSizeOuter;
}
axis.orient = function () {
return orient;
};
tickSizeOuter = Number(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
return axis;
};
axis.tickPadding = function () {
if (!arguments.length) {
return tickPadding;
}
var axis = function axis(orient, scale) {
var tickCenterLabel = false;
tickPadding = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
var labelOffset = function labelOffset(tick, index, ticksArray) {
var x = 0;
var y = base.tickSizeInner() + base.tickPadding();
var hidden = false;
axis.decorate = function () {
if (!arguments.length) {
return decorate;
}
if (tickCenterLabel) {
var thisPosition = scale(tick);
var nextPosition = index < ticksArray.length - 1 ? scale(ticksArray[index + 1]) : scale.range()[1];
x = (nextPosition - thisPosition) / 2;
y = base.tickPadding();
hidden = index === ticksArray.length - 1 && thisPosition === nextPosition;
}
decorate = arguments.length <= 0 ? undefined : arguments[0];
return axis;
return {
offset: [x, y],
hidden: hidden
};
};
axis.scale = function () {
if (!arguments.length) {
return scale;
}
var base = axisBase(orient, scale, {
labelOffset: labelOffset
});
scale = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
var axis = function axis(selection) {
return base(selection);
};
axis.ticks = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
axis.tickCenterLabel = function () {
if (!arguments.length) {
return tickCenterLabel;
}
tickArguments = [].concat(args);
return axis;
};
tickCenterLabel = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
axis.tickArguments = function () {
if (!arguments.length) {
return tickArguments.slice();
}
d3fcRebind.rebindAll(axis, base);
return axis;
};
tickArguments = (arguments.length <= 0 ? undefined : arguments[0]) == null ? [] : _toConsumableArray(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
var axisTop = function axisTop(scale) {
return axis('top', scale);
};
var axisBottom = function axisBottom(scale) {
return axis('bottom', scale);
};
var axisLeft = function axisLeft(scale) {
return axis('left', scale);
};
var axisRight = function axisRight(scale) {
return axis('right', scale);
};
axis.tickValues = function () {
if (!arguments.length) {
return tickValues.slice();
}
var axisOrdinal = function axisOrdinal(orient, scale) {
var tickOffset = null;
tickValues = (arguments.length <= 0 ? undefined : arguments[0]) == null ? [] : _toConsumableArray(arguments.length <= 0 ? undefined : arguments[0]);
return axis;
};
var step = function step(tick, index, ticksArray) {
if (scale.step) {
// Use the scale step size
return scale.step();
}
axis.orient = function () {
return orient;
};
var thisPosition = scale(tick);
return axis;
if (index < ticksArray.length - 1) {
// Distance between ticks
return scale(ticksArray[index + 1]) / thisPosition;
} else {
// 2* distance to end
return (scale.range()[1] - thisPosition) * 2;
}
};
var axis = function axis(orient, scale) {
var tickCenterLabel = false;
var tickPath = function tickPath(tick, index, ticksArray) {
var x = 0;
var labelOffset = function labelOffset(tick, index, ticksArray) {
var x = 0;
var y = base.tickSizeInner() + base.tickPadding();
var hidden = false;
if (tickOffset) {
x = tickOffset(tick, index);
} else {
x = step(tick, index, ticksArray) / 2;
}
if (tickCenterLabel) {
var thisPosition = scale(tick);
var nextPosition = index < ticksArray.length - 1 ? scale(ticksArray[index + 1]) : scale.range()[1];
x = (nextPosition - thisPosition) / 2;
y = base.tickPadding();
hidden = index === ticksArray.length - 1 && thisPosition === nextPosition;
}
return {
path: [[x, 0], [x, base.tickSizeInner()]],
hidden: index === ticksArray.length - 1
};
};
return {
offset: [x, y],
hidden: hidden
};
var labelOffset = function labelOffset() {
// Don't include the tickSizeInner in the label positioning
return {
offset: [0, base.tickPadding()]
};
};
var base = axisBase(orient, scale, {
labelOffset: labelOffset
});
var base = axisBase(orient, scale, {
labelOffset: labelOffset,
tickPath: tickPath
});
var axis = function axis(selection) {
return base(selection);
};
var axis = function axis(selection) {
base(selection);
};
axis.tickCenterLabel = function () {
if (!arguments.length) {
return tickCenterLabel;
}
axis.tickOffset = function () {
if (!arguments.length) {
return tickOffset;
}
tickCenterLabel = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
rebindAll(axis, base);
tickOffset = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
var axisTop = function axisTop(scale) {
return axis('top', scale);
};
var axisBottom = function axisBottom(scale) {
return axis('bottom', scale);
};
var axisLeft = function axisLeft(scale) {
return axis('left', scale);
};
var axisRight = function axisRight(scale) {
return axis('right', scale);
};
d3fcRebind.rebindAll(axis, base);
return axis;
};
var axisOrdinal = function axisOrdinal(orient, scale) {
var tickOffset = null;
var axisOrdinalTop = function axisOrdinalTop(scale) {
return axisOrdinal('top', scale);
};
var axisOrdinalBottom = function axisOrdinalBottom(scale) {
return axisOrdinal('bottom', scale);
};
var axisOrdinalLeft = function axisOrdinalLeft(scale) {
return axisOrdinal('left', scale);
};
var axisOrdinalRight = function axisOrdinalRight(scale) {
return axisOrdinal('right', scale);
};
var step = function step(tick, index, ticksArray) {
if (scale.step) {
// Use the scale step size
return scale.step();
}
var thisPosition = scale(tick);
if (index < ticksArray.length - 1) {
// Distance between ticks
return scale(ticksArray[index + 1]) / thisPosition;
} else {
// 2* distance to end
return (scale.range()[1] - thisPosition) * 2;
}
var measureLabels = (function (scale) {
var measure = function measure(selection) {
var labels = scale['ticks'] ? scale.ticks() : scale.domain();
var tester = selection.append('text');
var boundingBoxes = labels.map(function (l) {
return tester.text(l).node().getBBox();
});
var maxHeight = Math.max.apply(Math, _toConsumableArray(boundingBoxes.map(function (b) {
return b.height;
})));
var maxWidth = Math.max.apply(Math, _toConsumableArray(boundingBoxes.map(function (b) {
return b.width;
})));
tester.remove();
return {
maxHeight: maxHeight,
maxWidth: maxWidth,
labelCount: labels.length
};
};
var tickPath = function tickPath(tick, index, ticksArray) {
var x = 0;
return measure;
});
if (tickOffset) {
x = tickOffset(tick, index);
} else {
x = step(tick, index, ticksArray) / 2;
}
var axisLabelRotate = (function (adaptee) {
var labelRotate = 'auto';
return {
path: [[x, 0], [x, base.tickSizeInner()]],
hidden: index === ticksArray.length - 1
};
};
var decorate = function decorate() {};
var labelOffset = function labelOffset() {
// Don't include the tickSizeInner in the label positioning
return {
offset: [0, base.tickPadding()]
};
};
var base = axisBase(orient, scale, {
labelOffset: labelOffset,
tickPath: tickPath
});
var axis = function axis(selection) {
base(selection);
};
axis.tickOffset = function () {
if (!arguments.length) {
return tickOffset;
}
tickOffset = arguments.length <= 0 ? undefined : arguments[0];
return axis;
};
rebindAll(axis, base);
return axis;
var isVertical = function isVertical() {
return adaptee.orient() === 'left' || adaptee.orient() === 'right';
};
var axisOrdinalTop = function axisOrdinalTop(scale) {
return axisOrdinal('top', scale);
var sign = function sign() {
return adaptee.orient() === 'top' || adaptee.orient() === 'left' ? -1 : 1;
};
var axisOrdinalBottom = function axisOrdinalBottom(scale) {
return axisOrdinal('bottom', scale);
};
var axisOrdinalLeft = function axisOrdinalLeft(scale) {
return axisOrdinal('left', scale);
};
var axisOrdinalRight = function axisOrdinalRight(scale) {
return axisOrdinal('right', scale);
};
var measureLabels = (function (scale) {
var measure = function measure(selection) {
var labels = scale['ticks'] ? scale.ticks() : scale.domain();
var tester = selection.append('text');
var boundingBoxes = labels.map(function (l) {
return tester.text(l).node().getBBox();
});
var maxHeight = Math.max.apply(Math, _toConsumableArray(boundingBoxes.map(function (b) {
return b.height;
})));
var maxWidth = Math.max.apply(Math, _toConsumableArray(boundingBoxes.map(function (b) {
return b.width;
})));
tester.remove();
return {
maxHeight: maxHeight,
maxWidth: maxWidth,
labelCount: labels.length
};
};
var labelAnchor = function labelAnchor() {
switch (adaptee.orient()) {
case 'top':
case 'right':
return 'start';
return measure;
});
default:
return 'end';
}
};
var axisLabelRotate = (function (adaptee) {
var labelRotate = 'auto';
var calculateRotation = function calculateRotation(s) {
var _measureLabels = measureLabels(adaptee.scale())(s),
maxHeight = _measureLabels.maxHeight,
maxWidth = _measureLabels.maxWidth,
labelCount = _measureLabels.labelCount;
var decorate = function decorate() {};
var measuredSize = labelCount * maxWidth; // The more the overlap, the more we rotate
var isVertical = function isVertical() {
return adaptee.orient() === 'left' || adaptee.orient() === 'right';
};
var rotate;
var sign = function sign() {
return adaptee.orient() === 'top' || adaptee.orient() === 'left' ? -1 : 1;
};
if (labelRotate === 'auto') {
var range = adaptee.scale().range()[1];
rotate = range < measuredSize ? 90 * Math.min(1, (measuredSize / range - 0.8) / 2) : 0;
} else {
rotate = labelRotate;
}
var labelAnchor = function labelAnchor() {
switch (adaptee.orient()) {
case 'top':
case 'right':
return 'start';
default:
return 'end';
}
return {
rotate: isVertical() ? Math.floor(sign() * (90 - rotate)) : Math.floor(-rotate),
maxHeight: maxHeight,
maxWidth: maxWidth,
anchor: rotate ? labelAnchor() : 'middle'
};
};
var calculateRotation = function calculateRotation(s) {
var _measureLabels = measureLabels(adaptee.scale())(s),
maxHeight = _measureLabels.maxHeight,
maxWidth = _measureLabels.maxWidth,
labelCount = _measureLabels.labelCount;
var decorateRotation = function decorateRotation(sel) {
var _calculateRotation = calculateRotation(sel),
rotate = _calculateRotation.rotate,
maxHeight = _calculateRotation.maxHeight,
anchor = _calculateRotation.anchor;
var measuredSize = labelCount * maxWidth; // The more the overlap, the more we rotate
var text = sel.select('text');
var existingTransform = text.attr('transform');
var offset = sign() * Math.floor(maxHeight / 2);
var offsetTransform = isVertical() ? "translate(".concat(offset, ", 0)") : "translate(0, ".concat(offset, ")");
text.style('text-anchor', anchor).attr('transform', "".concat(existingTransform, " ").concat(offsetTransform, " rotate(").concat(rotate, " 0 0)"));
};
var rotate;
var axisLabelRotate = function axisLabelRotate(arg) {
adaptee(arg);
};
if (labelRotate === 'auto') {
var range = adaptee.scale().range()[1];
rotate = range < measuredSize ? 90 * Math.min(1, (measuredSize / range - 0.8) / 2) : 0;
} else {
rotate = labelRotate;
}
adaptee.decorate(function (s) {
decorateRotation(s);
decorate(s);
});
return {
rotate: isVertical() ? Math.floor(sign() * (90 - rotate)) : Math.floor(-rotate),
maxHeight: maxHeight,
maxWidth: maxWidth,
anchor: rotate ? labelAnchor() : 'middle'
};
};
axisLabelRotate.decorate = function () {
if (!arguments.length) {
return decorate;
}
var decorateRotation = function decorateRotation(sel) {
var _calculateRotation = calculateRotation(sel),
rotate = _calculateRotation.rotate,
maxHeight = _calculateRotation.maxHeight,
anchor = _calculateRotation.anchor;
decorate = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelRotate;
};
var text = sel.select('text');
var existingTransform = text.attr('transform');
var offset = sign() * Math.floor(maxHeight / 2);
var offsetTransform = isVertical() ? "translate(".concat(offset, ", 0)") : "translate(0, ".concat(offset, ")");
text.style('text-anchor', anchor).attr('transform', "".concat(existingTransform, " ").concat(offsetTransform, " rotate(").concat(rotate, " 0 0)"));
};
axisLabelRotate.labelRotate = function () {
if (!arguments.length) {
return labelRotate;
}
var axisLabelRotate = function axisLabelRotate(arg) {
adaptee(arg);
};
adaptee.decorate(function (s) {
decorateRotation(s);
decorate(s);
});
axisLabelRotate.decorate = function () {
if (!arguments.length) {
return decorate;
}
decorate = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelRotate;
};
axisLabelRotate.labelRotate = function () {
if (!arguments.length) {
return labelRotate;
}
labelRotate = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelRotate;
};
rebindAll(axisLabelRotate, adaptee, exclude('decorate'));
labelRotate = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelRotate;
});
};
var axisLabelOffset = (function (adaptee) {
var labelOffsetDepth = 'auto';
d3fcRebind.rebindAll(axisLabelRotate, adaptee, d3fcRebind.exclude('decorate'));
return axisLabelRotate;
});
var decorate = function decorate() {};
var axisLabelOffset = (function (adaptee) {
var labelOffsetDepth = 'auto';
var isVertical = function isVertical() {
return adaptee.orient() === 'left' || adaptee.orient() === 'right';
};
var decorate = function decorate() {};
var sign = function sign() {
return adaptee.orient() === 'top' || adaptee.orient() === 'left' ? -1 : 1;
};
var isVertical = function isVertical() {
return adaptee.orient() === 'left' || adaptee.orient() === 'right';
};
var decorateOffset = function decorateOffset(sel) {
var _measureLabels = measureLabels(adaptee.scale())(sel),
maxHeight = _measureLabels.maxHeight,
maxWidth = _measureLabels.maxWidth,
labelCount = _measureLabels.labelCount;
var sign = function sign() {
return adaptee.orient() === 'top' || adaptee.orient() === 'left' ? -1 : 1;
};
var range = adaptee.scale().range()[1];
var offsetLevels = labelOffsetDepth === 'auto' ? Math.floor((isVertical() ? maxHeight : maxWidth) * labelCount / range) + 1 : labelOffsetDepth;
var text = sel.select('text');
var existingTransform = text.attr('transform');
var decorateOffset = function decorateOffset(sel) {
var _measureLabels = measureLabels(adaptee.scale())(sel),
maxHeight = _measureLabels.maxHeight,
maxWidth = _measureLabels.maxWidth,
labelCount = _measureLabels.labelCount;
var transform = function transform(i) {
return isVertical() ? "translate(".concat(i % offsetLevels * maxWidth * sign(), ", 0)") : "translate(0, ".concat(i % offsetLevels * maxHeight * sign(), ")");
};
var range = adaptee.scale().range()[1];
var offsetLevels = labelOffsetDepth === 'auto' ? Math.floor((isVertical() ? maxHeight : maxWidth) * labelCount / range) + 1 : labelOffsetDepth;
var text = sel.select('text');
var existingTransform = text.attr('transform');
text.attr('transform', function (_, i) {
return "".concat(existingTransform, " ").concat(transform(i));
});
var transform = function transform(i) {
return isVertical() ? "translate(".concat(i % offsetLevels * maxWidth * sign(), ", 0)") : "translate(0, ".concat(i % offsetLevels * maxHeight * sign(), ")");
};
var axisLabelOffset = function axisLabelOffset(arg) {
return adaptee(arg);
};
adaptee.decorate(function (s) {
decorateOffset(s);
decorate(s);
text.attr('transform', function (_, i) {
return "".concat(existingTransform, " ").concat(transform(i));
});
};
axisLabelOffset.decorate = function () {
if (!arguments.length) {
return decorate;
}
var axisLabelOffset = function axisLabelOffset(arg) {
return adaptee(arg);
};
decorate = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelOffset;
};
adaptee.decorate(function (s) {
decorateOffset(s);
decorate(s);
});
axisLabelOffset.labelOffsetDepth = function () {
if (!arguments.length) {
return labelOffsetDepth;
}
axisLabelOffset.decorate = function () {
if (!arguments.length) {
return decorate;
}
labelOffsetDepth = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelOffset;
};
decorate = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelOffset;
};
rebindAll(axisLabelOffset, adaptee, exclude('decorate'));
axisLabelOffset.labelOffsetDepth = function () {
if (!arguments.length) {
return labelOffsetDepth;
}
labelOffsetDepth = arguments.length <= 0 ? undefined : arguments[0];
return axisLabelOffset;
});
};
exports.axisBottom = axisBottom;
exports.axisLabelOffset = axisLabelOffset;
exports.axisLabelRotate = axisLabelRotate;
exports.axisLeft = axisLeft;
exports.axisOrdinalBottom = axisOrdinalBottom;
exports.axisOrdinalLeft = axisOrdinalLeft;
exports.axisOrdinalRight = axisOrdinalRight;
exports.axisOrdinalTop = axisOrdinalTop;
exports.axisRight = axisRight;
exports.axisTop = axisTop;
d3fcRebind.rebindAll(axisLabelOffset, adaptee, d3fcRebind.exclude('decorate'));
return axisLabelOffset;
});
Object.defineProperty(exports, '__esModule', { value: true });
exports.axisBottom = axisBottom;
exports.axisLabelOffset = axisLabelOffset;
exports.axisLabelRotate = axisLabelRotate;
exports.axisLeft = axisLeft;
exports.axisOrdinalBottom = axisOrdinalBottom;
exports.axisOrdinalLeft = axisOrdinalLeft;
exports.axisOrdinalRight = axisOrdinalRight;
exports.axisOrdinalTop = axisOrdinalTop;
exports.axisRight = axisRight;
exports.axisTop = axisTop;
Object.defineProperty(exports, '__esModule', { value: true });
}));

@@ -1,1 +0,1 @@

(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("d3-selection"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-shape"],b):(a=a||self,b(a.fc=a.fc||{},a.d3,a.d3))})(this,function(a,b,c){'use strict';var m=Math.floor;function d(a,b){return g(a)||j(a,b)||l()}function e(a){return f(a)||h(a)||k()}function f(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}function g(a){if(Array.isArray(a))return a}function h(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function j(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function k(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function l(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var n=(a,b,c)=>{const d=b[c];if("function"!=typeof d)throw new Error(`Attempt to rebind ${c} which isn't a function on the source object`);return(...c)=>{var e=d.apply(b,c);return e===b?a:e}};const o=a=>b=>a.reduce((a,b)=>a&&b(a),b);var p=(a,b,...c)=>{const d=o(c);for(const e of Object.keys(b)){const c=d(e);c&&(a[c]=n(a,b,e))}return a},q=a=>a.map(a=>"string"==typeof a?new RegExp(`^${a}$`):a),r=(...a)=>(a=q(a),b=>a.every(a=>!a.test(b))&&b);const s=1e-6;var t=(a,b)=>{a=a||"g";let c=(a,b)=>b,d=null;const e=function(e,f){f=f||(a=>a);const g=e.selection?e:null;g&&(e=e.selection());const h=e.selectAll((a,b,c)=>Array.from(c[b].childNodes).filter(a=>1===a.nodeType)).filter(null==b?a:`${a}.${b}`);let i=h.data(f,c);const j=i.enter().append(a).attr("class",b);let k=i.exit();i=i.merge(j);const l=g||d;return l&&(i=i.transition(l).style("opacity",1),j.style("opacity",s),k=k.transition(l).style("opacity",s)),k.remove(),i.enter=()=>j,i.exit=()=>k,i};return e.element=(...b)=>b.length?(a=b[0],e):a,e.className=(...a)=>a.length?(b=a[0],e):b,e.key=(...a)=>a.length?(c=a[0],e):c,e.transition=(...a)=>a.length?(d=a[0],e):d,e},u=function(a){return a},v=function(a,f){var g=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},h=[10],i=null,j=function(){},k=null,l=6,m=6,n=3,o=c.line(),p=t("g","tick").key(u),q=t("path","domain"),r=function(){return{offset:[0,m+n]}},s=function(){return{path:[[0,0],[0,m]]}},v=g.labelOffset||r,w=g.tickPath||s,x=function(a,b){var c=Math.round,e=0;return a.bandwidth&&(e=a.bandwidth()/2,a.round()&&(e=c(e))),function(c){return b(a(c)+e,0)}},y=function(a,b){return A()?"translate(".concat(b,", ").concat(a,")"):"translate(".concat(a,", ").concat(b,")")},z=function(a){return A()?a.map(function(a){return[a[1],a[0]]}):a},A=function(){return"left"===a||"right"===a},B=function(a,b,c){return f[a]?f[a].apply(f,b):c},C=function(c){c.selection&&(p.transition(c),q.transition(c)),c.each(function(c,m,n){var r=n[m],s=b.select(r);r.__scale__||s.attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor","right"===a?"start":"left"===a?"end":"middle");var t=r.__scale__||f;r.__scale__=f.copy();var C=null==i?B("ticks",h,f.domain()):i,D=null==k?B("tickFormat",h,u):k,E="bottom"===a||"right"===a?1:-1,F=function(a){var b=d(a,2),c=b[0],e=b[1];return[c,E*e]},G=f.range(),H=z([[G[0],E*l],[G[0],0],[G[1],0],[G[1],E*l]]),I=q(s,[c]);I.attr("d",o(H)).attr("stroke","#000");var J=p(s,C),g=C.map(function(a,b){return v(a,b,C)}),K=C.map(function(a,b){return w(a,b,C)});J.enter().attr("transform",x(t,y)).append("path").attr("stroke","#000"),J.enter().append("text").attr("transform",function(a,b){return y.apply(void 0,e(F(g[b].offset)))}).attr("fill","#000"),J.exit().attr("transform",x(f,y)),J.select("path").attr("visibility",function(a,b){return K[b].hidden&&"hidden"}).attr("d",function(a,b){return o(z(K[b].path.map(F)))}),J.select("text").attr("visibility",function(a,b){return g[b].hidden&&"hidden"}).attr("transform",function(a,b){return y.apply(void 0,e(F(g[b].offset)))}).attr("dy",function(){var b="0em";return A()?b="0.32em":"bottom"===a&&(b="0.71em"),b}).text(D),J.attr("transform",x(f,y)),j(J,c,m)})};return C.tickFormat=function(){return arguments.length?(k=0>=arguments.length?void 0:arguments[0],C):k},C.tickSize=function(){return arguments.length?(m=l=+(0>=arguments.length?void 0:arguments[0]),C):m},C.tickSizeInner=function(){return arguments.length?(m=+(0>=arguments.length?void 0:arguments[0]),C):m},C.tickSizeOuter=function(){return arguments.length?(l=+(0>=arguments.length?void 0:arguments[0]),C):l},C.tickPadding=function(){return arguments.length?(n=0>=arguments.length?void 0:arguments[0],C):n},C.decorate=function(){return arguments.length?(j=0>=arguments.length?void 0:arguments[0],C):j},C.scale=function(){return arguments.length?(f=0>=arguments.length?void 0:arguments[0],C):f},C.ticks=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return h=[].concat(b),C},C.tickArguments=function(){return arguments.length?(h=null==(0>=arguments.length?void 0:arguments[0])?[]:e(0>=arguments.length?void 0:arguments[0]),C):h.slice()},C.tickValues=function(){return arguments.length?(i=null==(0>=arguments.length?void 0:arguments[0])?[]:e(0>=arguments.length?void 0:arguments[0]),C):i.slice()},C.orient=function(){return a},C},w=function a(b,c){var d=!1,e=function(a,b,e){var g=0,h=f.tickSizeInner()+f.tickPadding(),i=!1;if(d){var j=c(a),k=b<e.length-1?c(e[b+1]):c.range()[1];g=(k-j)/2,h=f.tickPadding(),i=b===e.length-1&&j===k}return{offset:[g,h],hidden:i}},f=v(b,c,{labelOffset:e}),a=function(a){return f(a)};return a.tickCenterLabel=function(){return arguments.length?(d=0>=arguments.length?void 0:arguments[0],a):d},p(a,f),a},x=function(a,b){var c=null,d=function(a,c,d){if(b.step)return b.step();var e=b(a);return c<d.length-1?b(d[c+1])/e:2*(b.range()[1]-e)},e=function(a,b,e){var g=0;return g=c?c(a,b):d(a,b,e)/2,{path:[[g,0],[g,f.tickSizeInner()]],hidden:b===e.length-1}},f=v(a,b,{labelOffset:function(){return{offset:[0,f.tickPadding()]}},tickPath:e}),g=function(a){f(a)};return g.tickOffset=function(){return arguments.length?(c=0>=arguments.length?void 0:arguments[0],g):c},p(g,f),g},y=function(a){return function(b){var c=Math.max,d=a.ticks?a.ticks():a.domain(),f=b.append("text"),g=d.map(function(a){return f.text(a).node().getBBox()}),h=c.apply(Math,e(g.map(function(a){return a.height}))),i=c.apply(Math,e(g.map(function(a){return a.width})));return f.remove(),{maxHeight:h,maxWidth:i,labelCount:d.length}}};a.axisBottom=function(a){return w("bottom",a)},a.axisLabelOffset=function(a){var b="auto",c=function(){},d=function(){return"left"===a.orient()||"right"===a.orient()},e=function(){return"top"===a.orient()||"left"===a.orient()?-1:1},f=function(c){var f=y(a.scale())(c),g=f.maxHeight,h=f.maxWidth,i=f.labelCount,j=a.scale().range()[1],k="auto"===b?m((d()?g:h)*i/j)+1:b,l=c.select("text"),n=l.attr("transform"),o=function(a){return d()?"translate(".concat(a%k*h*e(),", 0)"):"translate(0, ".concat(a%k*g*e(),")")};l.attr("transform",function(a,b){return"".concat(n," ").concat(o(b))})},g=function(b){return a(b)};return a.decorate(function(a){f(a),c(a)}),g.decorate=function(){return arguments.length?(c=0>=arguments.length?void 0:arguments[0],g):c},g.labelOffsetDepth=function(){return arguments.length?(b=0>=arguments.length?void 0:arguments[0],g):b},p(g,a,r("decorate")),g},a.axisLabelRotate=function(a){var b="auto",c=function(){},d=function(){return"left"===a.orient()||"right"===a.orient()},e=function(){return"top"===a.orient()||"left"===a.orient()?-1:1},f=function(){switch(a.orient()){case"top":case"right":return"start";default:return"end";}},g=function(c){var h,g=Math.min,i=y(a.scale())(c),j=i.maxHeight,k=i.maxWidth,l=i.labelCount,n=l*k;if("auto"===b){var o=a.scale().range()[1];h=o<n?90*g(1,(n/o-.8)/2):0}else h=b;return{rotate:d()?m(e()*(90-h)):m(-h),maxHeight:j,maxWidth:k,anchor:h?f():"middle"}},h=function(a){var b=g(a),c=b.rotate,f=b.maxHeight,h=b.anchor,i=a.select("text"),j=i.attr("transform"),k=e()*m(f/2),l=d()?"translate(".concat(k,", 0)"):"translate(0, ".concat(k,")");i.style("text-anchor",h).attr("transform","".concat(j," ").concat(l," rotate(").concat(c," 0 0)"))},i=function(b){a(b)};return a.decorate(function(a){h(a),c(a)}),i.decorate=function(){return arguments.length?(c=0>=arguments.length?void 0:arguments[0],i):c},i.labelRotate=function(){return arguments.length?(b=0>=arguments.length?void 0:arguments[0],i):b},p(i,a,r("decorate")),i},a.axisLeft=function(a){return w("left",a)},a.axisOrdinalBottom=function(a){return x("bottom",a)},a.axisOrdinalLeft=function(a){return x("left",a)},a.axisOrdinalRight=function(a){return x("right",a)},a.axisOrdinalTop=function(a){return x("top",a)},a.axisRight=function(a){return w("right",a)},a.axisTop=function(a){return w("top",a)},Object.defineProperty(a,"__esModule",{value:!0})});
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("@d3fc/d3fc-rebind"),require("d3-selection"),require("d3-shape"),require("@d3fc/d3fc-data-join")):"function"==typeof define&&define.amd?define(["exports","@d3fc/d3fc-rebind","d3-selection","d3-shape","@d3fc/d3fc-data-join"],b):(a=a||self,b(a.fc=a.fc||{},a.fc,a.d3,a.d3,a.fc))})(this,function(a,b,c,d,e){'use strict';var o=Math.floor;function f(a,b){return j(a)||l(a,b)||n()}function g(a){return h(a)||k(a)||m()}function h(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}function j(a){if(Array.isArray(a))return a}function k(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function l(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function m(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var p=function(a){return a},q=function(a,b){var h=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=[10],j=null,k=function(){},l=null,m=6,n=6,o=3,q=d.line(),r=e.dataJoin("g","tick").key(p),s=e.dataJoin("path","domain"),t=function(){return{offset:[0,n+o]}},u=function(){return{path:[[0,0],[0,n]]}},v=h.labelOffset||t,w=h.tickPath||u,x=function(a,b){var c=Math.round,e=0;return a.bandwidth&&(e=a.bandwidth()/2,a.round()&&(e=c(e))),function(c){return b(a(c)+e,0)}},y=function(a,b){return A()?"translate(".concat(b,", ").concat(a,")"):"translate(".concat(a,", ").concat(b,")")},z=function(a){return A()?a.map(function(a){return[a[1],a[0]]}):a},A=function(){return"left"===a||"right"===a},B=function(a,c,d){return b[a]?b[a].apply(b,c):d},C=function(d){d.selection&&(r.transition(d),s.transition(d)),d.each(function(d,e,h){var n=h[e],o=c.select(n);n.__scale__||o.attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor","right"===a?"start":"left"===a?"end":"middle");var t=n.__scale__||b;n.__scale__=b.copy();var u=null==j?B("ticks",i,b.domain()):j,C=null==l?B("tickFormat",i,p):l,D="bottom"===a||"right"===a?1:-1,E=function(a){var b=f(a,2),c=b[0],d=b[1];return[c,D*d]},F=b.range(),G=z([[F[0],D*m],[F[0],0],[F[1],0],[F[1],D*m]]),H=s(o,[d]);H.attr("d",q(G)).attr("stroke","#000");var I=r(o,u),J=u.map(function(a,b){return v(a,b,u)}),K=u.map(function(a,b){return w(a,b,u)});I.enter().attr("transform",x(t,y)).append("path").attr("stroke","#000"),I.enter().append("text").attr("transform",function(a,b){return y.apply(void 0,g(E(J[b].offset)))}).attr("fill","#000"),I.exit().attr("transform",x(b,y)),I.select("path").attr("visibility",function(a,b){return K[b].hidden&&"hidden"}).attr("d",function(a,b){return q(z(K[b].path.map(E)))}),I.select("text").attr("visibility",function(a,b){return J[b].hidden&&"hidden"}).attr("transform",function(a,b){return y.apply(void 0,g(E(J[b].offset)))}).attr("dy",function(){var b="0em";return A()?b="0.32em":"bottom"===a&&(b="0.71em"),b}).text(C),I.attr("transform",x(b,y)),k(I,d,e)})};return C.tickFormat=function(){return arguments.length?(l=0>=arguments.length?void 0:arguments[0],C):l},C.tickSize=function(){return arguments.length?(n=m=+(0>=arguments.length?void 0:arguments[0]),C):n},C.tickSizeInner=function(){return arguments.length?(n=+(0>=arguments.length?void 0:arguments[0]),C):n},C.tickSizeOuter=function(){return arguments.length?(m=+(0>=arguments.length?void 0:arguments[0]),C):m},C.tickPadding=function(){return arguments.length?(o=0>=arguments.length?void 0:arguments[0],C):o},C.decorate=function(){return arguments.length?(k=0>=arguments.length?void 0:arguments[0],C):k},C.scale=function(){return arguments.length?(b=0>=arguments.length?void 0:arguments[0],C):b},C.ticks=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return i=[].concat(b),C},C.tickArguments=function(){return arguments.length?(i=null==(0>=arguments.length?void 0:arguments[0])?[]:g(0>=arguments.length?void 0:arguments[0]),C):i.slice()},C.tickValues=function(){return arguments.length?(j=null==(0>=arguments.length?void 0:arguments[0])?[]:g(0>=arguments.length?void 0:arguments[0]),C):j.slice()},C.orient=function(){return a},C},r=function a(c,d){var e=!1,f=function(a,b,c){var f=0,h=g.tickSizeInner()+g.tickPadding(),i=!1;if(e){var j=d(a),k=b<c.length-1?d(c[b+1]):d.range()[1];f=(k-j)/2,h=g.tickPadding(),i=b===c.length-1&&j===k}return{offset:[f,h],hidden:i}},g=q(c,d,{labelOffset:f}),a=function(a){return g(a)};return a.tickCenterLabel=function(){return arguments.length?(e=0>=arguments.length?void 0:arguments[0],a):e},b.rebindAll(a,g),a},s=function(a,c){var d=null,e=function(a,b,d){if(c.step)return c.step();var e=c(a);return b<d.length-1?c(d[b+1])/e:2*(c.range()[1]-e)},f=function(a,b,c){var f=0;return f=d?d(a,b):e(a,b,c)/2,{path:[[f,0],[f,g.tickSizeInner()]],hidden:b===c.length-1}},g=q(a,c,{labelOffset:function(){return{offset:[0,g.tickPadding()]}},tickPath:f}),h=function(a){g(a)};return h.tickOffset=function(){return arguments.length?(d=0>=arguments.length?void 0:arguments[0],h):d},b.rebindAll(h,g),h},t=function(a){return function(b){var c=Math.max,d=a.ticks?a.ticks():a.domain(),e=b.append("text"),f=d.map(function(a){return e.text(a).node().getBBox()}),h=c.apply(Math,g(f.map(function(a){return a.height}))),i=c.apply(Math,g(f.map(function(a){return a.width})));return e.remove(),{maxHeight:h,maxWidth:i,labelCount:d.length}}};a.axisBottom=function(a){return r("bottom",a)},a.axisLabelOffset=function(a){var c="auto",d=function(){},e=function(){return"left"===a.orient()||"right"===a.orient()},f=function(){return"top"===a.orient()||"left"===a.orient()?-1:1},g=function(b){var d=t(a.scale())(b),g=d.maxHeight,h=d.maxWidth,i=d.labelCount,j=a.scale().range()[1],k="auto"===c?o((e()?g:h)*i/j)+1:c,l=b.select("text"),m=l.attr("transform"),n=function(a){return e()?"translate(".concat(a%k*h*f(),", 0)"):"translate(0, ".concat(a%k*g*f(),")")};l.attr("transform",function(a,b){return"".concat(m," ").concat(n(b))})},h=function(b){return a(b)};return a.decorate(function(a){g(a),d(a)}),h.decorate=function(){return arguments.length?(d=0>=arguments.length?void 0:arguments[0],h):d},h.labelOffsetDepth=function(){return arguments.length?(c=0>=arguments.length?void 0:arguments[0],h):c},b.rebindAll(h,a,b.exclude("decorate")),h},a.axisLabelRotate=function(a){var c="auto",d=function(){},e=function(){return"left"===a.orient()||"right"===a.orient()},f=function(){return"top"===a.orient()||"left"===a.orient()?-1:1},g=function(){switch(a.orient()){case"top":case"right":return"start";default:return"end";}},h=function(b){var h,d=Math.min,i=t(a.scale())(b),j=i.maxHeight,k=i.maxWidth,l=i.labelCount,m=l*k;if("auto"===c){var n=a.scale().range()[1];h=n<m?90*d(1,(m/n-.8)/2):0}else h=c;return{rotate:e()?o(f()*(90-h)):o(-h),maxHeight:j,maxWidth:k,anchor:h?g():"middle"}},i=function(a){var b=h(a),c=b.rotate,d=b.maxHeight,g=b.anchor,i=a.select("text"),j=i.attr("transform"),k=f()*o(d/2),l=e()?"translate(".concat(k,", 0)"):"translate(0, ".concat(k,")");i.style("text-anchor",g).attr("transform","".concat(j," ").concat(l," rotate(").concat(c," 0 0)"))},j=function(b){a(b)};return a.decorate(function(a){i(a),d(a)}),j.decorate=function(){return arguments.length?(d=0>=arguments.length?void 0:arguments[0],j):d},j.labelRotate=function(){return arguments.length?(c=0>=arguments.length?void 0:arguments[0],j):c},b.rebindAll(j,a,b.exclude("decorate")),j},a.axisLeft=function(a){return r("left",a)},a.axisOrdinalBottom=function(a){return s("bottom",a)},a.axisOrdinalLeft=function(a){return s("left",a)},a.axisOrdinalRight=function(a){return s("right",a)},a.axisOrdinalTop=function(a){return s("top",a)},a.axisRight=function(a){return r("right",a)},a.axisTop=function(a){return r("top",a)},Object.defineProperty(a,"__esModule",{value:!0})});

@@ -6,2 +6,13 @@ # Change Log

# 2.3.0 (2020-03-19)
### Features
* add fill to webgl boxplot ([7ea7859](https://github.com/d3fc/d3fc/commit/7ea7859))
## [2.2.5](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-axis@2.2.4...@d3fc/d3fc-axis@2.2.5) (2019-11-28)

@@ -8,0 +19,0 @@

{
"name": "@d3fc/d3fc-axis",
"version": "2.2.5",
"version": "2.3.0",
"description": "A drop-in replacement for d3 axis, with support for the d3fc decorate pattern",

@@ -28,3 +28,3 @@ "license": "MIT",

"dependencies": {
"@d3fc/d3fc-data-join": "^5.0.11",
"@d3fc/d3fc-data-join": "^5.1.0",
"@d3fc/d3fc-rebind": "^5.0.10",

@@ -38,3 +38,3 @@ "d3-scale": "^1.0.3",

},
"gitHead": "de82a1a109ddce4b5721fc4e0d2039ddd497817d"
"gitHead": "8a27597494353a1441a1a71ca06707d9e28c4381"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc