How to use the d3fc.rebindAll function in d3fc

To help you get started, we’ve selected a few d3fc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github finos / perspective / packages / perspective-viewer-d3fc / src / js / axis / linearAxis.js View on Github external
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);
github finos / perspective / packages / perspective-viewer-d3fc / src / js / d3fc / axis / multi-axis.js View on Github external
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;
    };
github finos / perspective / packages / perspective-viewer-d3fc / src / js / series / barSeries.js View on Github external
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;
};
github finos / perspective / packages / perspective-viewer-d3fc / src / js / d3fc / axis / multi-axis.js View on Github external
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;
};