How to use the d3-scale.scaleImplicit function in d3-scale

To help you get started, we’ve selected a few d3-scale 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 DefinitelyTyped / DefinitelyTyped / d3-scale / d3-scale-tests.ts View on Github external
ordinalScaleStringNumber = ordinalScaleStringNumber.domain(['negative', 'neutral', 'positive']);

// range(...) -----------------------------------------------------------------

ordinalScaleStringString = ordinalScaleStringString.range(['crimson', 'midnightblue', 'seagreen']);
rangeStrings = ordinalScaleStringString.range();

ordinalScaleStringNumber = ordinalScaleStringNumber.range([-1, 0, 1]);
rangeNumbers = ordinalScaleStringNumber.range();


// unknown(...) and d3Scale.scaleImplicit --------------------------------------

let implicit: { name: 'implicit' } = d3Scale.scaleImplicit;

ordinalScaleStringString = ordinalScaleStringString.unknown(d3Scale.scaleImplicit);

ordinalScaleStringNumber = ordinalScaleStringNumber.unknown(0);

let unknownValue: string | { name: 'implicit' } = ordinalScaleStringString.unknown();

if (typeof unknownValue === 'string') {
    console.log(unknownValue);
} else {
    console.log(unknownValue.name);
}

// (...) value mapping from domain to output -----------------------------------

outputString = ordinalScaleStringString('neutral');

outputNumber = ordinalScaleStringNumber('negative');
github DefinitelyTyped / DefinitelyTyped / types / d3-scale / d3-scale-tests.ts View on Github external
domainStrings = ordinalScaleStringString.domain();

ordinalScaleStringNumber = ordinalScaleStringNumber.domain(['negative', 'neutral', 'positive']);

// range(...) -----------------------------------------------------------------

ordinalScaleStringString = ordinalScaleStringString.range(['crimson', 'midnightblue', 'seagreen']);
ordinalScaleStringString = ordinalScaleStringString.range(schemePuRd[3]);
rangeStrings = ordinalScaleStringString.range();

ordinalScaleStringNumber = ordinalScaleStringNumber.range([-1, 0, 1]);
rangeNumbers = ordinalScaleStringNumber.range();

// unknown(...) and d3Scale.scaleImplicit --------------------------------------

const implicit: { name: 'implicit' } = d3Scale.scaleImplicit;

ordinalScaleStringString = ordinalScaleStringString.unknown(d3Scale.scaleImplicit);

ordinalScaleStringNumber = ordinalScaleStringNumber.unknown(0);

const unknownValue: string | { name: 'implicit' } = ordinalScaleStringString.unknown();

if (typeof unknownValue === 'string') {
    console.log(unknownValue);
} else {
    console.log(unknownValue.name);
}

// (...) value mapping from domain to output -----------------------------------

outputString = ordinalScaleStringString('neutral');
github DefinitelyTyped / DefinitelyTyped / types / d3-scale / d3-scale-tests.ts View on Github external
ordinalScaleStringNumber = ordinalScaleStringNumber.domain(['negative', 'neutral', 'positive']);

// range(...) -----------------------------------------------------------------

ordinalScaleStringString = ordinalScaleStringString.range(['crimson', 'midnightblue', 'seagreen']);
ordinalScaleStringString = ordinalScaleStringString.range(schemePuRd[3]);
rangeStrings = ordinalScaleStringString.range();

ordinalScaleStringNumber = ordinalScaleStringNumber.range([-1, 0, 1]);
rangeNumbers = ordinalScaleStringNumber.range();

// unknown(...) and d3Scale.scaleImplicit --------------------------------------

const implicit: { name: 'implicit' } = d3Scale.scaleImplicit;

ordinalScaleStringString = ordinalScaleStringString.unknown(d3Scale.scaleImplicit);

ordinalScaleStringNumber = ordinalScaleStringNumber.unknown(0);

const unknownValue: string | { name: 'implicit' } = ordinalScaleStringString.unknown();

if (typeof unknownValue === 'string') {
    console.log(unknownValue);
} else {
    console.log(unknownValue.name);
}

// (...) value mapping from domain to output -----------------------------------

outputString = ordinalScaleStringString('neutral');

outputNumber = ordinalScaleStringNumber('negative');
github DefinitelyTyped / DefinitelyTyped / d3-scale / d3-scale-tests.ts View on Github external
domainStrings = ordinalScaleStringString.domain();

ordinalScaleStringNumber = ordinalScaleStringNumber.domain(['negative', 'neutral', 'positive']);

// range(...) -----------------------------------------------------------------

ordinalScaleStringString = ordinalScaleStringString.range(['crimson', 'midnightblue', 'seagreen']);
rangeStrings = ordinalScaleStringString.range();

ordinalScaleStringNumber = ordinalScaleStringNumber.range([-1, 0, 1]);
rangeNumbers = ordinalScaleStringNumber.range();


// unknown(...) and d3Scale.scaleImplicit --------------------------------------

let implicit: { name: 'implicit' } = d3Scale.scaleImplicit;

ordinalScaleStringString = ordinalScaleStringString.unknown(d3Scale.scaleImplicit);

ordinalScaleStringNumber = ordinalScaleStringNumber.unknown(0);

let unknownValue: string | { name: 'implicit' } = ordinalScaleStringString.unknown();

if (typeof unknownValue === 'string') {
    console.log(unknownValue);
} else {
    console.log(unknownValue.name);
}

// (...) value mapping from domain to output -----------------------------------

outputString = ordinalScaleStringString('neutral');