Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const domain = () => {
const base = customExtent()
.pad([0, 0.1])
.padUnit("percent");
let valueNames = ["crossValue"];
const _domain = data => {
base.accessors(valueNames.map(v => d => parseFloat(d[v])));
return getDataExtent(flattenArray(data));
};
fc.rebindAll(_domain, base);
const getMinimumGap = data => {
const gaps = valueNames.map(valueName =>
data
.map(d => d[valueName])
.sort((a, b) => a - b)
.filter((d, i, a) => i === 0 || d !== a[i - 1])
.reduce((acc, d, i, src) => (i === 0 || acc <= d - src[i - 1] ? acc : Math.abs(d - src[i - 1])))
);
return Math.min(...gaps);
};
const getDataExtent = data => {
if (base.padUnit() == "domain") {
const dataWidth = getMinimumGap(data);
function customScale(value) {
const values = value.domain;
return values.reduce((sum, d) => sum + scale(d), 0) / values.length;
}
customScale.ticks = () => {
return group;
};
customScale.tickFormat = () => d => {
return d.text;
};
customScale.copy = () => scaleFromGroup(scale, group);
customScale.step = value => value.domain.length * scale.step();
rebindAll(customScale, scale, exclude("ticks", "step", "copy"));
return customScale;
};
const minBandwidth = adaptee => {
const min = arg => {
return adaptee(arg);
};
fc.rebindAll(min, adaptee);
min.bandwidth = (...args) => {
if (!args.length) {
return adaptee.bandwidth();
}
adaptee.bandwidth(Math.max(args[0], 1));
return min;
};
return min;
};
if (!args.length) {
return decorate;
}
decorate = args[0];
return multiAxis;
};
multiAxis.groups = (...args) => {
if (!args.length) {
return groups;
}
groups = args[0];
return multiAxis;
};
rebindAll(multiAxis, axisStore);
return multiAxis;
};