refactor(*): refactor d3-scale and d3-scale-chromatic

BREAKING CHANGE:
* refactor(d3-scale) update to major version 2.0. As a breaking change all color related features are removed. schemeCategory20x features are removed without replacement. All other color features are moved to d3-scale-chromatic 1.2
* refactor(d3-scale-chromatic): update to minor version 1.2 by including refactored features dropped from  d3-scale 2.0: schemeCategory10 and color interpolators.
* fix(d3-scale) All input arguments for domain or range arrays now also permit ReadonlyArray<T> as inputs. This change allows seamless integration with the color schemes defined in d3-scale-chromatic. This change has been applied to both d3-scale 1.x and 2.x.
* chore(d3-scale-chromatic) activate strictNullChecks
* chore(d3-scale) move d3-scale 1.x into legacy folder `v1` and update tsconfig.json including path mapping for d3-scale itself to pick up legacy version in its own legacy tests
* test(d3-scale) update tests including integration test with d3-scale-chromatic
* test(d3-scale-chromatic) update tests. Including generalized assignment tests for interplators and schemes.
* chore(*) update version numbers for d3-scale and d3-scale-chromatic
This commit is contained in:
Tom Wanzek
2018-02-08 16:50:46 -05:00
parent ff2359e74c
commit 9ecd90e9e8
9 changed files with 3087 additions and 202 deletions
@@ -8,9 +8,29 @@
import * as d3ScaleChromatic from 'd3-scale-chromatic';
// -----------------------------------------------------------------------
// Preparatory Steps
// -----------------------------------------------------------------------
let colorInterpolator: ((t: number) => string);
let simpleScheme: ReadonlyArray<string>;
let nestedScheme: ReadonlyArray<ReadonlyArray<string>>;
// -----------------------------------------------------------------------
// Categorical
// -----------------------------------------------------------------------
simpleScheme = d3ScaleChromatic.schemeCategory10;
simpleScheme = d3ScaleChromatic.schemeAccent;
simpleScheme = d3ScaleChromatic.schemeDark2;
simpleScheme = d3ScaleChromatic.schemePaired;
simpleScheme = d3ScaleChromatic.schemePastel1;
simpleScheme = d3ScaleChromatic.schemePastel2;
simpleScheme = d3ScaleChromatic.schemeSet1;
simpleScheme = d3ScaleChromatic.schemeSet2;
simpleScheme = d3ScaleChromatic.schemeSet3;
const category10: string = d3ScaleChromatic.schemeCategory10[0]; // #1f77b4
const accent: string = d3ScaleChromatic.schemeAccent[0]; // #7fc97f
const dark: string = d3ScaleChromatic.schemeDark2[0]; // #1b9e77
const paired: string = d3ScaleChromatic.schemePaired[0]; // #a6cee3
@@ -23,6 +43,17 @@ const set3: string = d3ScaleChromatic.schemeSet3[0]; // #8dd3c7
// -----------------------------------------------------------------------
// Diverging
// -----------------------------------------------------------------------
colorInterpolator = d3ScaleChromatic.interpolateBrBG;
colorInterpolator = d3ScaleChromatic.interpolatePRGn;
colorInterpolator = d3ScaleChromatic.interpolatePiYG;
colorInterpolator = d3ScaleChromatic.interpolatePuOr;
colorInterpolator = d3ScaleChromatic.interpolateRdBu;
colorInterpolator = d3ScaleChromatic.interpolateRdGy;
colorInterpolator = d3ScaleChromatic.interpolateRdYlBu;
colorInterpolator = d3ScaleChromatic.interpolateRdYlGn;
colorInterpolator = d3ScaleChromatic.interpolateSpectral;
const BrBG: string = d3ScaleChromatic.interpolateBrBG(0); // rgb(84, 48, 5)
const PRGn: string = d3ScaleChromatic.interpolatePRGn(0); // rgb(64, 0, 75)
const PiYG: string = d3ScaleChromatic.interpolatePiYG(0); // rgb(142, 1, 82)
@@ -33,6 +64,16 @@ const RdYlBu: string = d3ScaleChromatic.interpolateRdYlBu(0); // rgb(103, 0, 31)
const RdYlGn: string = d3ScaleChromatic.interpolateRdYlGn(0); // rgb(103, 0, 31)
const Spectral: string = d3ScaleChromatic.interpolateSpectral(0); // rgb(158, 1, 66)
nestedScheme = d3ScaleChromatic.schemeBrBG;
nestedScheme = d3ScaleChromatic.schemePRGn;
nestedScheme = d3ScaleChromatic.schemePiYG;
nestedScheme = d3ScaleChromatic.schemePuOr;
nestedScheme = d3ScaleChromatic.schemeRdBu;
nestedScheme = d3ScaleChromatic.schemeRdGy;
nestedScheme = d3ScaleChromatic.schemeRdYlBu;
nestedScheme = d3ScaleChromatic.schemeRdYlGn;
nestedScheme = d3ScaleChromatic.schemeSpectral;
const schemeBrBG: string = d3ScaleChromatic.schemeBrBG[3][0]; // #d8b365
const schemePRGn: string = d3ScaleChromatic.schemePRGn[3][0]; // #af8dc3
const schemePiYG: string = d3ScaleChromatic.schemePiYG[3][0]; // #e9a3c9
@@ -46,6 +87,14 @@ const schemeSpectral: string = d3ScaleChromatic.schemeSpectral[3][0]; // #fc8d59
// -----------------------------------------------------------------------
// Sequential
// -----------------------------------------------------------------------
colorInterpolator = d3ScaleChromatic.interpolateBlues;
colorInterpolator = d3ScaleChromatic.interpolateGreens;
colorInterpolator = d3ScaleChromatic.interpolateGreys;
colorInterpolator = d3ScaleChromatic.interpolateOranges;
colorInterpolator = d3ScaleChromatic.interpolatePurples;
colorInterpolator = d3ScaleChromatic.interpolateReds;
const Blue: string = d3ScaleChromatic.interpolateBlues(1); // rgb(8, 48, 107)
const Green: string = d3ScaleChromatic.interpolateGreens(1); // rgb(0, 68, 27)
const Grey: string = d3ScaleChromatic.interpolateGreys(1); // rgb(0, 0, 0)
@@ -53,6 +102,13 @@ const Orange: string = d3ScaleChromatic.interpolateOranges(1); // rgb(127, 39, 4
const Purple: string = d3ScaleChromatic.interpolatePurples(1); // rgb(63, 0, 125)
const Red: string = d3ScaleChromatic.interpolateReds(1); // rgb(103, 0, 13)
nestedScheme = d3ScaleChromatic.schemeBlues;
nestedScheme = d3ScaleChromatic.schemeGreens;
nestedScheme = d3ScaleChromatic.schemeGreys;
nestedScheme = d3ScaleChromatic.schemeOranges;
nestedScheme = d3ScaleChromatic.schemePurples;
nestedScheme = d3ScaleChromatic.schemeReds;
const schemeBlues: string = d3ScaleChromatic.schemeBlues[3][0]; // #deebf7
const schemeGreens: string = d3ScaleChromatic.schemeGreens[3][0]; // #e5f5e0
const schemeGreys: string = d3ScaleChromatic.schemeGreys[3][0]; // #f0f0f0
@@ -63,6 +119,28 @@ const schemeReds: string = d3ScaleChromatic.schemeReds[3][0]; // #fee0d2
// -----------------------------------------------------------------------
// Sequential(Multi-Hue)
// -----------------------------------------------------------------------
colorInterpolator = d3ScaleChromatic.interpolateViridis;
colorInterpolator = d3ScaleChromatic.interpolateMagma;
colorInterpolator = d3ScaleChromatic.interpolateInferno;
colorInterpolator = d3ScaleChromatic.interpolatePlasma;
colorInterpolator = d3ScaleChromatic.interpolateRainbow;
colorInterpolator = d3ScaleChromatic.interpolateWarm;
colorInterpolator = d3ScaleChromatic.interpolateCool;
colorInterpolator = d3ScaleChromatic.interpolateCubehelixDefault;
colorInterpolator = d3ScaleChromatic.interpolateBuGn;
colorInterpolator = d3ScaleChromatic.interpolateBuPu;
colorInterpolator = d3ScaleChromatic.interpolateGnBu;
colorInterpolator = d3ScaleChromatic.interpolateOrRd;
colorInterpolator = d3ScaleChromatic.interpolatePuBuGn;
colorInterpolator = d3ScaleChromatic.interpolatePuBu;
colorInterpolator = d3ScaleChromatic.interpolatePuRd;
colorInterpolator = d3ScaleChromatic.interpolateRdPu;
colorInterpolator = d3ScaleChromatic.interpolateYlGnBu;
colorInterpolator = d3ScaleChromatic.interpolateYlGn;
colorInterpolator = d3ScaleChromatic.interpolateYlOrBr;
colorInterpolator = d3ScaleChromatic.interpolateYlOrRd;
const BuGn: string = d3ScaleChromatic.interpolateBuGn(1); // rgb(0, 68, 27)
const BuPu: string = d3ScaleChromatic.interpolateBuPu(1); // rgb(77, 0, 75)
const GnBu: string = d3ScaleChromatic.interpolateGnBu(1); // rgb(8, 64, 129)
@@ -76,6 +154,19 @@ const YlGn: string = d3ScaleChromatic.interpolateYlGn(1); // rgb(0, 69, 41)
const YlOrBr: string = d3ScaleChromatic.interpolateYlOrBr(1); // rgb(102, 37, 6)
const YlOrRd: string = d3ScaleChromatic.interpolateYlOrRd(1); // rgb(128, 0, 38)
nestedScheme = d3ScaleChromatic.schemeBuGn;
nestedScheme = d3ScaleChromatic.schemeBuPu;
nestedScheme = d3ScaleChromatic.schemeGnBu;
nestedScheme = d3ScaleChromatic.schemeOrRd;
nestedScheme = d3ScaleChromatic.schemePuBuGn;
nestedScheme = d3ScaleChromatic.schemePuBu;
nestedScheme = d3ScaleChromatic.schemePuRd;
nestedScheme = d3ScaleChromatic.schemeRdPu;
nestedScheme = d3ScaleChromatic.schemeYlGnBu;
nestedScheme = d3ScaleChromatic.schemeYlGn;
nestedScheme = d3ScaleChromatic.schemeYlOrBr;
nestedScheme = d3ScaleChromatic.schemeYlOrRd;
const schemeBuGn: string = d3ScaleChromatic.schemeBuGn[3][0]; // #e5f5f9
const schemeBuPu: string = d3ScaleChromatic.schemeBuPu[3][0]; // #e0ecf4
const schemeGnBu: string = d3ScaleChromatic.schemeGnBu[3][0]; // #e0f3db
+122 -57
View File
@@ -1,4 +1,4 @@
// Type definitions for D3JS d3-scale-chromatic module 1.1
// Type definitions for D3JS d3-scale-chromatic module 1.2
// Project: https://github.com/d3/d3-scale-chromatic/
// Definitions by: Hugues Stefanski <https://github.com/Ledragon>,
// Alex Ford <https://github.com/gustavderdrache>,
@@ -6,11 +6,15 @@
// Henrique Machado <https://github.com/henriquefm>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.0.2
// Last module patch version validated against: 1.2.0
// -----------------------------------------------------------------------
// Categorical
// -----------------------------------------------------------------------
/**
* An array of ten categorical colors represented as RGB hexadecimal strings.
*/
export const schemeCategory10: ReadonlyArray<string>;
/**
* An array of eight categorical colors represented as RGB hexadecimal strings.
*/
@@ -48,11 +52,11 @@ export const schemeSet3: ReadonlyArray<string>;
// Diverging
// -----------------------------------------------------------------------
/**
* Given a number value in the range [0,1], returns the corresponding color from the “BrBG” diverging color scheme represented as an RGB string.
* Given a number t in the range [0,1], returns the corresponding color from the “BrBG” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateBrBG(value: number): string;
export function interpolateBrBG(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “BrBG” diverging color scheme. The kth element of this array contains
@@ -64,9 +68,9 @@ export const schemeBrBG: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “PRGn” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePRGn(value: number): string;
export function interpolatePRGn(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “PRGn” diverging color scheme. The kth element of this array contains
@@ -78,9 +82,9 @@ export const schemePRGn: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “PiYG” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePiYG(value: number): string;
export function interpolatePiYG(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “PiYG” diverging color scheme. The kth element of this array contains
@@ -92,9 +96,9 @@ export const schemePiYG: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “PuOr” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePuOr(value: number): string;
export function interpolatePuOr(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “PuOr” diverging color scheme. The kth element of this array contains
@@ -106,9 +110,9 @@ export const schemePuOr: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “RdBu” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateRdBu(value: number): string;
export function interpolateRdBu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “RdBu” diverging color scheme. The kth element of this array contains
@@ -120,9 +124,9 @@ export const schemeRdBu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “RdGy” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateRdGy(value: number): string;
export function interpolateRdGy(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “RdGy” diverging color scheme. The kth element of this array contains
@@ -134,9 +138,9 @@ export const schemeRdGy: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “RdYlBu” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateRdYlBu(value: number): string;
export function interpolateRdYlBu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “RdYlBu” diverging color scheme. The kth element of this array contains
@@ -148,9 +152,9 @@ export const schemeRdYlBu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “RdYlGn” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateRdYlGn(value: number): string;
export function interpolateRdYlGn(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “RdYlGn” diverging color scheme. The kth element of this array contains
@@ -162,9 +166,9 @@ export const schemeRdYlGn: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Spectral” diverging color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateSpectral(value: number): string;
export function interpolateSpectral(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Spectral” diverging color scheme. The kth element of this array contains
@@ -179,9 +183,9 @@ export const schemeSpectral: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Blues” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateBlues(value: number): string;
export function interpolateBlues(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Blues” sequential color scheme. The kth element of this array contains
@@ -193,9 +197,9 @@ export const schemeBlues: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Greens” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateGreens(value: number): string;
export function interpolateGreens(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Greens” sequential color scheme. The kth element of this array contains
@@ -207,9 +211,9 @@ export const schemeGreens: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Greys” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateGreys(value: number): string;
export function interpolateGreys(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Greys” sequential color scheme. The kth element of this array contains
@@ -221,9 +225,9 @@ export const schemeGreys: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Oranges” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateOranges(value: number): string;
export function interpolateOranges(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Oranges” sequential color scheme. The kth element of this array contains
@@ -235,9 +239,9 @@ export const schemeOranges: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Purples” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePurples(value: number): string;
export function interpolatePurples(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Purples” sequential color scheme. The kth element of this array contains
@@ -249,9 +253,9 @@ export const schemePurples: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “Reds” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateReds(value: number): string;
export function interpolateReds(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “Reds” sequential color scheme. The kth element of this array contains
@@ -264,12 +268,73 @@ export const schemeReds: ReadonlyArray<ReadonlyArray<string>>;
// Sequential(Multi-Hue)
// -----------------------------------------------------------------------
/**
* Given a number t in the range [0,1], returns the corresponding color from the “viridis” perceptually-uniform color scheme designed by van der Walt, Smith and Firing for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateViridis(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “inferno” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateInferno(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “magma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateMagma(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “plasma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolatePlasma(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from a 180° rotation of Niccolis perceptual rainbow, represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateWarm(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from Niccolis perceptual rainbow, represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateCool(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from d3.interpolateWarm scale from [0.0, 0.5] followed by the d3.interpolateCool scale from [0.5, 1.0],
* thus implementing the cyclical less-angry rainbow color scheme.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateRainbow(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from Greens default Cubehelix represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateCubehelixDefault(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “BuGn” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateBuGn(value: number): string;
export function interpolateBuGn(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “BuGn” sequential color scheme. The kth element of this array contains
@@ -281,9 +346,9 @@ export const schemeBuGn: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “BuPu” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateBuPu(value: number): string;
export function interpolateBuPu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “BuPu” sequential color scheme. The kth element of this array contains
@@ -295,9 +360,9 @@ export const schemeBuPu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “GnBu” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateGnBu(value: number): string;
export function interpolateGnBu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “GnBu” sequential color scheme. The kth element of this array contains
@@ -309,9 +374,9 @@ export const schemeGnBu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “OrRd” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateOrRd(value: number): string;
export function interpolateOrRd(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “OrRd” sequential color scheme. The kth element of this array contains
@@ -323,9 +388,9 @@ export const schemeOrRd: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “PuBuGn” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePuBuGn(value: number): string;
export function interpolatePuBuGn(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “PuBuGn” sequential color scheme. The kth element of this array contains
@@ -337,9 +402,9 @@ export const schemePuBuGn: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “PuBu” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePuBu(value: number): string;
export function interpolatePuBu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “PuBu” sequential color scheme. The kth element of this array contains
@@ -351,9 +416,9 @@ export const schemePuBu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “PuRd” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolatePuRd(value: number): string;
export function interpolatePuRd(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “PuRd” sequential color scheme. The kth element of this array contains
@@ -365,9 +430,9 @@ export const schemePuRd: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “RdPu” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateRdPu(value: number): string;
export function interpolateRdPu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “RdPu” sequential color scheme. The kth element of this array contains
@@ -379,9 +444,9 @@ export const schemeRdPu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “YlGnBu” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateYlGnBu(value: number): string;
export function interpolateYlGnBu(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “YlGnBu” sequential color scheme. The kth element of this array contains
@@ -393,9 +458,9 @@ export const schemeYlGnBu: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “YlGn” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateYlGn(value: number): string;
export function interpolateYlGn(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “YlGn” sequential color scheme. The kth element of this array contains
@@ -407,9 +472,9 @@ export const schemeYlGn: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “YlOrBr” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateYlOrBr(value: number): string;
export function interpolateYlOrBr(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “YlOrBr” sequential color scheme. The kth element of this array contains
@@ -421,9 +486,9 @@ export const schemeYlOrBr: ReadonlyArray<ReadonlyArray<string>>;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “YlOrRd” sequential color scheme represented as an RGB string.
*
* @param value Number in the range [0, 1].
* @param t Number in the range [0, 1].
*/
export function interpolateYlOrRd(value: number): string;
export function interpolateYlOrRd(t: number): string;
/**
* An array of arrays of hexadecimal color strings from the “YlOrRd” sequential color scheme. The kth element of this array contains
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
@@ -21,4 +21,4 @@
"index.d.ts",
"d3-scale-chromatic-tests.ts"
]
}
}
+12 -39
View File
@@ -9,6 +9,12 @@
import * as d3Scale from 'd3-scale';
import { interpolateCubehelix } from 'd3-interpolate';
import { timeHour } from 'd3-time';
import {
schemePuRd,
interpolateRainbow,
interpolateCool,
interpolateInferno
} from 'd3-scale-chromatic';
// -------------------------------------------------------------------------------
// Preparatory Steps
@@ -549,8 +555,8 @@ const copiedTimeScale: d3Scale.ScaleTime<number, string> = localTimeScaleNumStri
let sequentialScaleColorString: d3Scale.ScaleSequential<string>;
sequentialScaleColorString = d3Scale.scaleSequential<string>(d3Scale.interpolateRainbow);
sequentialScaleColorString = d3Scale.scaleSequential(d3Scale.interpolateCool); // inferred Output type string
sequentialScaleColorString = d3Scale.scaleSequential<string>(interpolateRainbow);
sequentialScaleColorString = d3Scale.scaleSequential(interpolateCool); // inferred Output type string
// ScaleSequential Interface ========================================================
@@ -567,7 +573,7 @@ clampFlag = sequentialScaleColorString.clamp();
// interpolate(...) -----------------------------------------------------------------
sequentialScaleColorString = sequentialScaleColorString.interpolator(d3Scale.interpolateInferno);
sequentialScaleColorString = sequentialScaleColorString.interpolator(interpolateInferno);
let sequentialInterpolator: (t: number) => string;
sequentialInterpolator = sequentialScaleColorString.interpolator();
@@ -580,28 +586,6 @@ outputString = sequentialScaleColorString(10);
const copiedSequentialScale: d3Scale.ScaleSequential<string> = sequentialScaleColorString.copy();
// -------------------------------------------------------------------------------
// Color Interpolators for Sequential Scale Factory
// -------------------------------------------------------------------------------
let colorInterpolator: ((t: number) => string);
colorInterpolator = d3Scale.interpolateViridis;
colorInterpolator = d3Scale.interpolateMagma;
colorInterpolator = d3Scale.interpolateInferno;
colorInterpolator = d3Scale.interpolatePlasma;
colorInterpolator = d3Scale.interpolateRainbow;
colorInterpolator = d3Scale.interpolateWarm;
colorInterpolator = d3Scale.interpolateCool;
colorInterpolator = d3Scale.interpolateCubehelixDefault;
// -------------------------------------------------------------------------------
// Quantize Scale Factory
// -------------------------------------------------------------------------------
@@ -764,7 +748,9 @@ let ordinalScaleStringString: d3Scale.ScaleOrdinal<string, string>;
let ordinalScaleStringNumber: d3Scale.ScaleOrdinal<string, number>;
ordinalScaleStringString = d3Scale.scaleOrdinal<string>();
ordinalScaleStringString = d3Scale.scaleOrdinal<string>(schemePuRd[3]);
ordinalScaleStringNumber = d3Scale.scaleOrdinal<string, number>();
ordinalScaleStringString = d3Scale.scaleOrdinal<string, string>(schemePuRd[3]);
// ScaleOrdinal Interface ========================================================
@@ -778,6 +764,7 @@ ordinalScaleStringNumber = ordinalScaleStringNumber.domain(['negative', 'neutral
// range(...) -----------------------------------------------------------------
ordinalScaleStringString = ordinalScaleStringString.range(['crimson', 'midnightblue', 'seagreen']);
ordinalScaleStringString = ordinalScaleStringString.range(schemePuRd[3]);
rangeStrings = ordinalScaleStringString.range();
ordinalScaleStringNumber = ordinalScaleStringNumber.range([-1, 0, 1]);
@@ -950,17 +937,3 @@ outputNumberMaybe = pointScaleCoercible(new StringCoercible('negative'));
// copy(...) -----------------------------------------------------------------
const copiedPointScale: d3Scale.ScalePoint<StringCoercible> = pointScaleCoercible.copy();
// -------------------------------------------------------------------------------
// Categorical Color Schemas for Ordinal Scales
// -------------------------------------------------------------------------------
let colorStrings: string[];
colorStrings = d3Scale.schemeCategory10;
colorStrings = d3Scale.schemeCategory20;
colorStrings = d3Scale.schemeCategory20b;
colorStrings = d3Scale.schemeCategory20c;
+14 -104
View File
@@ -1,9 +1,9 @@
// Type definitions for D3JS d3-scale module 1.0
// Type definitions for D3JS d3-scale module 2.0
// Project: https://github.com/d3/d3-scale/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.0.4
// Last module patch version validated against: 2.0.0
import { CountableTimeInterval, TimeInterval } from 'd3-time';
@@ -87,7 +87,7 @@ export interface ScaleContinuousNumeric<Range, Output> {
*
* @param range Array of range values.
*/
range(range: Range[]): this;
range(range: Range[] | ReadonlyArray<Range>): this;
/**
* Sets the scales range to the specified array of values while also setting the scales interpolator to interpolateRound.
@@ -756,7 +756,7 @@ export interface ScaleTime<Range, Output> {
*
* @param range Array of range values.
*/
range(range: Range[]): this;
range(range: Range[] | ReadonlyArray<Range>): this;
/**
* Sets the scales range to the specified array of values while also setting the scales interpolator to interpolateRound.
@@ -1081,71 +1081,6 @@ export interface ScaleSequential<Output> {
*/
export function scaleSequential<Output>(interpolator: ((t: number) => Output)): ScaleSequential<Output>;
// -------------------------------------------------------------------------------
// Color Interpolators for Sequential Scale Factory
// -------------------------------------------------------------------------------
/**
* Given a number t in the range [0,1], returns the corresponding color from the “viridis” perceptually-uniform color scheme designed by van der Walt, Smith and Firing for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateViridis(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “inferno” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateInferno(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “magma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateMagma(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from the “plasma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib,
* represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolatePlasma(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from a 180° rotation of Niccolis perceptual rainbow, represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateWarm(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from Niccolis perceptual rainbow, represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateCool(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from d3.interpolateWarm scale from [0.0, 0.5] followed by the d3.interpolateCool scale from [0.5, 1.0],
* thus implementing the cyclical less-angry rainbow color scheme.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateRainbow(t: number): string;
/**
* Given a number t in the range [0,1], returns the corresponding color from Greens default Cubehelix represented as an RGB string.
*
* @param t A number in the interval [0, 1].
*/
export function interpolateCubehelixDefault(t: number): string;
// -------------------------------------------------------------------------------
// Quantize Scale Factory
// -------------------------------------------------------------------------------
@@ -1195,7 +1130,7 @@ export interface ScaleQuantize<Range> {
*
* @param range Array of range values.
*/
range(range: Range[]): this;
range(range: Range[] | ReadonlyArray<Range>): this;
/**
* Returns approximately count representative values from the scales domain.
@@ -1311,7 +1246,7 @@ export interface ScaleQuantile<Range> {
*
* @param range Array of range values.
*/
range(range: Range[]): this;
range(range: Range[] | ReadonlyArray<Range>): this;
/**
* Returns the quantile thresholds. If the range contains n discrete values, the returned array will contain n - 1 thresholds.
@@ -1385,7 +1320,7 @@ export interface ScaleThreshold<Domain extends number | string | Date, Range> {
*
* @param domain Array of domain values.
*/
domain(domain: Domain[]): this;
domain(domain: Domain[] | ReadonlyArray<Domain>): this;
/**
* Returns the scales current range.
@@ -1398,7 +1333,7 @@ export interface ScaleThreshold<Domain extends number | string | Date, Range> {
*
* @param range Array of range values.
*/
range(range: Range[]): this;
range(range: Range[] | ReadonlyArray<Range>): this;
/**
* Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.
@@ -1463,7 +1398,7 @@ export interface ScaleOrdinal<Domain extends { toString(): string }, Range> {
*
* @param domain Array of domain values.
*/
domain(domain: Domain[]): this;
domain(domain: Domain[] | ReadonlyArray<Domain>): this;
/**
* Returns the scale's current range.
@@ -1478,7 +1413,7 @@ export interface ScaleOrdinal<Domain extends { toString(): string }, Range> {
*
* @param range Array of range values.
*/
range(range: Range[]): this;
range(range: Range[] | ReadonlyArray<Range>): this;
/**
* Returns the current unknown value, which defaults to "implicit".
@@ -1509,7 +1444,7 @@ export interface ScaleOrdinal<Domain extends { toString(): string }, Range> {
*
* @parm range An optional array of range values to initialize the scale with.
*/
export function scaleOrdinal<Range>(range?: Range[]): ScaleOrdinal<string, Range>;
export function scaleOrdinal<Range>(range?: Range[] | ReadonlyArray<Range>): ScaleOrdinal<string, Range>;
/**
* Constructs a new ordinal scale with an empty domain and the specified range.
* If a range is not specified, it defaults to the empty array; an ordinal scale always returns undefined until a non-empty range is defined.
@@ -1522,7 +1457,7 @@ export function scaleOrdinal<Range>(range?: Range[]): ScaleOrdinal<string, Range
*
* @parm range An optional array of range values to initialize the scale with.
*/
export function scaleOrdinal<Domain extends { toString(): string }, Range>(range?: Range[]): ScaleOrdinal<Domain, Range>;
export function scaleOrdinal<Domain extends { toString(): string }, Range>(range?: Range[] | ReadonlyArray<Range>): ScaleOrdinal<Domain, Range>;
/**
* A special value for ordinal.unknown that enables implicit domain construction: unknown values are implicitly added to the domain.
@@ -1561,7 +1496,7 @@ export interface ScaleBand<Domain extends { toString(): string }> {
*
* @param domain Array of domain values.
*/
domain(domain: Domain[]): this;
domain(domain: Domain[] | ReadonlyArray<Domain>): this;
/**
* Returns the scales current range, which defaults to [0, 1].
@@ -1713,7 +1648,7 @@ export interface ScalePoint<Domain extends { toString(): string }> {
*
* @param domain Array of domain values.
*/
domain(domain: Domain[]): this;
domain(domain: Domain[] | ReadonlyArray<Domain>): this;
/**
* Returns the scales current range, which defaults to [0, 1].
@@ -1813,28 +1748,3 @@ export function scalePoint(): ScalePoint<string>;
* The generic corresponds to the data type of domain elements.
*/
export function scalePoint<Domain extends { toString(): string }>(): ScalePoint<Domain>;
// -------------------------------------------------------------------------------
// Categorical Color Schemas for Ordinal Scales
// -------------------------------------------------------------------------------
/**
* An array of ten categorical colors represented as RGB hexadecimal strings.
*/
export const schemeCategory10: string[];
/**
* An array of twenty categorical colors represented as RGB hexadecimal strings.
*/
export const schemeCategory20: string[];
/**
* An array of twenty categorical colors represented as RGB hexadecimal strings.
*/
export const schemeCategory20b: string[];
/**
* An array of twenty categorical colors represented as RGB hexadecimal strings.
* This color scale includes color specifications and designs developed by Cynthia Brewer (colorbrewer2.org).
*/
export const schemeCategory20c: string[];
+970
View File
@@ -0,0 +1,970 @@
/**
* Typescript definition tests for d3/d3-scale module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Scale from 'd3-scale';
import { interpolateCubehelix } from 'd3-interpolate';
import { timeHour } from 'd3-time';
import { schemePuRd } from 'd3-scale-chromatic';
// -------------------------------------------------------------------------------
// Preparatory Steps
// -------------------------------------------------------------------------------
class NumCoercible {
a: number;
constructor(a: number) {
this.a = a;
}
valueOf() {
return this.a;
}
}
class StringCoercible {
txt: string;
constructor(txt: string) {
this.txt = txt;
}
toString() {
return this.txt;
}
}
let num: number;
let date: Date;
let clampFlag: boolean;
let outputNumber: number;
let outputString: string;
let domainNumbers: number[] = [1, 100];
const domainNumeric: NumCoercible[] = [new NumCoercible(0), new NumCoercible(100)];
let domainStrings: string[];
let domainDates: Date[] = [new Date(2016, 0, 15), new Date(2016, 5, 15)];
let ticksNumbers: number[];
let ticksDates: Date[];
let tickFormatNumberFn: ((d: number | { valueOf(): number }) => string);
let tickFormatDateFn: ((d: Date) => string);
let rangeNumbers: number[] = [2, 200];
let rangeStrings: string[] = ['2px', '200px'];
let numExtent: [number, number];
let numOrUndefinedExtent: [number | undefined, number | undefined];
let outputNumberMaybe: number | undefined;
// -------------------------------------------------------------------------------
// Linear Scale Factory
// -------------------------------------------------------------------------------
// scaleLinear() -----------------------------------------------------------------
let linearScaleNumber: d3Scale.ScaleLinear<number, number>;
let linearScaleString: d3Scale.ScaleLinear<string, string>;
let linearScaleNumString: d3Scale.ScaleLinear<number, string>;
linearScaleNumber = d3Scale.scaleLinear();
linearScaleString = d3Scale.scaleLinear<string>();
linearScaleNumString = d3Scale.scaleLinear<number, string>();
// ScaleLinear Interface ========================================================
// domain(...) -----------------------------------------------------------------
linearScaleNumber = linearScaleNumber.domain(domainNumeric);
linearScaleNumber = linearScaleNumber.domain(domainNumbers);
domainNumbers = linearScaleNumber.domain();
linearScaleString = linearScaleString.domain(domainNumeric);
linearScaleString = linearScaleString.domain([10, 100]);
domainNumbers = linearScaleString.domain();
linearScaleNumString = linearScaleNumString.domain(domainNumeric);
linearScaleNumString = linearScaleNumString.domain(domainNumbers);
domainNumbers = linearScaleNumString.domain();
// range(...) -----------------------------------------------------------------
linearScaleNumber = linearScaleNumber.range(rangeNumbers);
rangeNumbers = linearScaleNumber.range();
linearScaleString = linearScaleString.range(['steelblue', 'brown']);
rangeStrings = linearScaleString.range();
linearScaleNumString = linearScaleNumString.range(rangeNumbers);
rangeNumbers = linearScaleNumString.range();
// invert(...) -----------------------------------------------------------------
num = linearScaleNumber.invert(500); // has number range, so inversion is possible
num = linearScaleNumber.invert(new NumCoercible(500)); // has number range, so inversion is possible
num = linearScaleNumString.invert(500); // has number range, so inversion is possible
num = linearScaleNumString.invert(new NumCoercible(500)); // has number range, so inversion is possible
// rangeRound(...) -----------------------------------------------------------------
linearScaleNumber = linearScaleNumber.rangeRound(rangeNumbers);
// clamp(...) -----------------------------------------------------------------
linearScaleNumber = linearScaleNumber.clamp(true);
clampFlag = linearScaleNumber.clamp();
// interpolate(...) -----------------------------------------------------------------
linearScaleString = linearScaleString.interpolate(interpolateCubehelix.gamma(3));
linearScaleNumString = linearScaleNumString.interpolate((a, b) => {
// take two numbers
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
});
// Changes scale output type (inferred generic)
linearScaleNumString = linearScaleNumber.interpolate((a, b) => {
// take two numbers
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
});
// nice(...) -----------------------------------------------------------------------
// chainable
linearScaleNumber = linearScaleNumber.nice();
linearScaleNumber = linearScaleNumber.nice(5);
// ticks(...) -----------------------------------------------------------------
ticksNumbers = linearScaleNumber.ticks();
ticksNumbers = linearScaleNumber.ticks(5);
// tickFormat(...) -----------------------------------------------------------------
tickFormatNumberFn = linearScaleNumber.tickFormat();
tickFormatNumberFn = linearScaleNumber.tickFormat(5);
tickFormatNumberFn = linearScaleNumber.tickFormat(5, '+%');
// (...) value mapping from domain to output -----------------------------------
outputNumber = linearScaleNumber(10);
outputString = linearScaleString(10);
outputString = linearScaleNumString(10);
// copy(...) -----------------------------------------------------------------
const copiedLinearScale: d3Scale.ScaleLinear<number, string> = linearScaleNumString.copy();
// -------------------------------------------------------------------------------
// Power Scale Factories
// -------------------------------------------------------------------------------
// scalePow() and scaleSqrt() ----------------------------------------------------
let powerScaleNumber: d3Scale.ScalePower<number, number>;
let powerScaleString: d3Scale.ScalePower<string, string>;
let powerScaleNumString: d3Scale.ScalePower<number, string>;
powerScaleNumber = d3Scale.scalePow();
powerScaleString = d3Scale.scalePow<string>();
powerScaleNumString = d3Scale.scalePow<number, string>();
let squarerootScaleNumber: d3Scale.ScalePower<number, number>;
let squarerootScaleString: d3Scale.ScalePower<string, string>;
let squarerootScaleNumString: d3Scale.ScalePower<number, string>;
squarerootScaleNumber = d3Scale.scaleSqrt();
squarerootScaleString = d3Scale.scaleSqrt<string>();
squarerootScaleNumString = d3Scale.scaleSqrt<number, string>();
// ScalePower Interface ========================================================
// exponent --------------------------------------------------------------------
const exponent: number = squarerootScaleNumber.exponent();
powerScaleNumber = powerScaleNumber.exponent(5);
// domain(...) -----------------------------------------------------------------
powerScaleNumber = powerScaleNumber.domain(domainNumeric);
powerScaleNumber = powerScaleNumber.domain(domainNumbers);
domainNumbers = powerScaleNumber.domain();
powerScaleString = powerScaleString.domain(domainNumeric);
powerScaleString = powerScaleString.domain([10, 100]);
domainNumbers = powerScaleString.domain();
powerScaleNumString = powerScaleNumString.domain(domainNumeric);
powerScaleNumString = powerScaleNumString.domain(domainNumbers);
domainNumbers = powerScaleNumString.domain();
// range(...) -----------------------------------------------------------------
powerScaleNumber = powerScaleNumber.range(rangeNumbers);
rangeNumbers = powerScaleNumber.range();
powerScaleString = powerScaleString.range(['steelblue', 'brown']);
rangeStrings = powerScaleString.range();
powerScaleNumString = powerScaleNumString.range(rangeNumbers);
rangeNumbers = powerScaleNumString.range();
// invert(...) -----------------------------------------------------------------
num = powerScaleNumber.invert(500); // has number range, so inversion is possible
num = powerScaleNumber.invert(new NumCoercible(500)); // has number range, so inversion is possible
num = powerScaleNumString.invert(500); // has number range, so inversion is possible
num = powerScaleNumString.invert(new NumCoercible(500)); // has number range, so inversion is possible
// rangeRound(...) -----------------------------------------------------------------
powerScaleNumber = powerScaleNumber.rangeRound(rangeNumbers);
// clamp(...) -----------------------------------------------------------------
powerScaleNumber = powerScaleNumber.clamp(true);
clampFlag = powerScaleNumber.clamp();
// interpolate(...) -----------------------------------------------------------------
powerScaleString = powerScaleString.interpolate(interpolateCubehelix.gamma(3));
powerScaleNumString = powerScaleNumString.interpolate((a, b) => {
// take two numbers
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
});
// nice(...) -----------------------------------------------------------------------
// chainable
powerScaleNumber = powerScaleNumber.nice();
powerScaleNumber = powerScaleNumber.nice(5);
// ticks(...) -----------------------------------------------------------------
ticksNumbers = powerScaleNumber.ticks();
ticksNumbers = powerScaleNumber.ticks(5);
// tickFormat(...) -----------------------------------------------------------------
tickFormatNumberFn = powerScaleNumber.tickFormat();
tickFormatNumberFn = powerScaleNumber.tickFormat(5);
tickFormatNumberFn = powerScaleNumber.tickFormat(5, '+%');
// (...) value mapping from domain to output -----------------------------------
outputNumber = powerScaleNumber(10);
outputString = powerScaleString(10);
outputString = powerScaleNumString(10);
// copy(...) -----------------------------------------------------------------
const copiedPowerScale: d3Scale.ScalePower<number, string> = powerScaleNumString.copy();
// -------------------------------------------------------------------------------
// Logarithmic Scale Factory
// -------------------------------------------------------------------------------
// scaleLog() ---------------------------------------------------------------------
let logScaleNumber: d3Scale.ScaleLogarithmic<number, number>;
let logScaleString: d3Scale.ScaleLogarithmic<string, string>;
let logScaleNumString: d3Scale.ScaleLogarithmic<number, string>;
logScaleNumber = d3Scale.scaleLog();
logScaleString = d3Scale.scaleLog<string>();
logScaleNumString = d3Scale.scaleLog<number, string>();
// ScaleLogarithmic Interface ========================================================
// base --------------------------------------------------------------------
const base: number = logScaleNumber.base();
logScaleNumber = logScaleNumber.base(42);
// domain(...) -----------------------------------------------------------------
logScaleNumber = logScaleNumber.domain(domainNumeric);
logScaleNumber = logScaleNumber.domain(domainNumbers);
domainNumbers = logScaleNumber.domain();
logScaleString = logScaleString.domain(domainNumeric);
logScaleString = logScaleString.domain([10, 100]);
domainNumbers = logScaleString.domain();
logScaleNumString = logScaleNumString.domain(domainNumeric);
logScaleNumString = logScaleNumString.domain(domainNumbers);
domainNumbers = logScaleNumString.domain();
// range(...) -----------------------------------------------------------------
logScaleNumber = logScaleNumber.range(rangeNumbers);
rangeNumbers = logScaleNumber.range();
logScaleString = logScaleString.range(['steelblue', 'brown']);
rangeStrings = logScaleString.range();
logScaleNumString = logScaleNumString.range(rangeNumbers);
rangeNumbers = logScaleNumString.range();
// invert(...) -----------------------------------------------------------------
num = logScaleNumber.invert(500); // has number range, so inversion is possible
num = logScaleNumber.invert(new NumCoercible(500)); // has number range, so inversion is possible
num = logScaleNumString.invert(500); // has number range, so inversion is possible
num = logScaleNumString.invert(new NumCoercible(500)); // has number range, so inversion is possible
// rangeRound(...) -----------------------------------------------------------------
logScaleNumber = logScaleNumber.rangeRound(rangeNumbers);
// clamp(...) -----------------------------------------------------------------
logScaleNumber = logScaleNumber.clamp(true);
clampFlag = logScaleNumber.clamp();
// interpolate(...) -----------------------------------------------------------------
logScaleString = logScaleString.interpolate(interpolateCubehelix.gamma(3));
logScaleNumString = logScaleNumString.interpolate((a, b) => {
// take two numbers
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
});
// nice(...) -----------------------------------------------------------------------
// chainable
logScaleNumber = logScaleNumber.nice();
// logScaleNumber = logScaleNumber.nice(5); // fails, logarithmic scale does not support count parameter.
// ticks(...) -----------------------------------------------------------------
ticksNumbers = logScaleNumber.ticks();
ticksNumbers = logScaleNumber.ticks(5);
// tickFormat(...) -----------------------------------------------------------------
tickFormatNumberFn = logScaleNumber.tickFormat();
tickFormatNumberFn = logScaleNumber.tickFormat(5);
tickFormatNumberFn = logScaleNumber.tickFormat(5, '+%');
// (...) value mapping from domain to output -----------------------------------
outputNumber = logScaleNumber(10);
outputString = logScaleString(10);
outputString = logScaleNumString(10);
// copy(...) -----------------------------------------------------------------
const copiedLogScale: d3Scale.ScaleLogarithmic<number, string> = logScaleNumString.copy();
// -------------------------------------------------------------------------------
// Identity Scale Factory
// -------------------------------------------------------------------------------
// scaleIdentity -----------------------------------------------------------------
let identityScale: d3Scale.ScaleIdentity;
identityScale = d3Scale.scaleIdentity();
// ScaleIdentity Interface ========================================================
// domain(...) -----------------------------------------------------------------
identityScale = identityScale.domain(domainNumeric);
identityScale = identityScale.domain(domainNumbers);
domainNumbers = identityScale.domain();
// range(...) -----------------------------------------------------------------
identityScale = identityScale.range(rangeNumbers);
rangeNumbers = identityScale.range();
// invert(...) -----------------------------------------------------------------
num = identityScale.invert(500); // has number range, so inversion is possible
num = identityScale.invert(new NumCoercible(500)); // has number range, so inversion is possible
// nice(...) -----------------------------------------------------------------------
// chainable
identityScale = identityScale.nice();
identityScale = identityScale.nice(5);
// ticks(...) -----------------------------------------------------------------
ticksNumbers = identityScale.ticks();
ticksNumbers = identityScale.ticks(5);
// tickFormat(...) -----------------------------------------------------------------
tickFormatNumberFn = identityScale.tickFormat();
tickFormatNumberFn = identityScale.tickFormat(5);
tickFormatNumberFn = identityScale.tickFormat(5, '+%');
// (...) value mapping from domain to output -----------------------------------
outputNumber = identityScale(10);
// copy(...) -----------------------------------------------------------------
const copiedIdentityScale: d3Scale.ScaleIdentity = identityScale.copy();
// -------------------------------------------------------------------------------
// Time Scale Factories
// -------------------------------------------------------------------------------
// scaleTime() and scaleUtc() ----------------------------------------------------
let localTimeScaleNumber: d3Scale.ScaleTime<number, number>;
let localTimeScaleString: d3Scale.ScaleTime<string, string>;
let localTimeScaleNumString: d3Scale.ScaleTime<number, string>;
localTimeScaleNumber = d3Scale.scaleTime();
localTimeScaleString = d3Scale.scaleTime<string>();
localTimeScaleNumString = d3Scale.scaleTime<number, string>();
let utcScaleNumber: d3Scale.ScaleTime<number, number>;
let utcScaleString: d3Scale.ScaleTime<string, string>;
let utcScaleNumString: d3Scale.ScaleTime<number, string>;
utcScaleNumber = d3Scale.scaleUtc();
utcScaleString = d3Scale.scaleUtc<string>();
utcScaleNumString = d3Scale.scaleUtc<number, string>();
// domain(...) -----------------------------------------------------------------
localTimeScaleNumber = localTimeScaleNumber.domain(domainDates);
domainDates = localTimeScaleNumber.domain();
localTimeScaleString = localTimeScaleString.domain([new Date(2016, 6, 1), Date.now()]);
domainDates = localTimeScaleString.domain();
localTimeScaleNumString = localTimeScaleNumString.domain(domainDates);
domainDates = localTimeScaleNumString.domain();
// range(...) -----------------------------------------------------------------
localTimeScaleNumber = localTimeScaleNumber.range(rangeNumbers);
rangeNumbers = localTimeScaleNumber.range();
localTimeScaleString = localTimeScaleString.range(['steelblue', 'brown']);
rangeStrings = localTimeScaleString.range();
localTimeScaleNumString = localTimeScaleNumString.range(rangeNumbers);
rangeNumbers = localTimeScaleNumString.range();
// invert(...) -----------------------------------------------------------------
date = localTimeScaleNumber.invert(500); // has number range, so inversion is possible
date = localTimeScaleNumber.invert(new NumCoercible(500)); // has number range, so inversion is possible
date = localTimeScaleNumString.invert(500); // has number range, so inversion is possible
date = localTimeScaleNumString.invert(new NumCoercible(500)); // has number range, so inversion is possible
// rangeRound(...) -----------------------------------------------------------------
localTimeScaleNumber = localTimeScaleNumber.rangeRound(rangeNumbers);
// clamp(...) -----------------------------------------------------------------
localTimeScaleNumber = localTimeScaleNumber.clamp(true);
clampFlag = localTimeScaleNumber.clamp();
// interpolate(...) -----------------------------------------------------------------
localTimeScaleString = localTimeScaleString.interpolate(interpolateCubehelix.gamma(3));
localTimeScaleNumString = localTimeScaleNumString.interpolate((a, b) => {
// take two numbers
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
});
// nice(...) -----------------------------------------------------------------------
// chainable
localTimeScaleNumber = localTimeScaleNumber.nice();
localTimeScaleNumber = localTimeScaleNumber.nice(5);
localTimeScaleNumber = localTimeScaleNumber.nice(timeHour);
localTimeScaleNumber = localTimeScaleNumber.nice(timeHour, 5);
// localTimeScaleNumber = localTimeScaleNumber.nice(timeHour.every(5)); // fails, requires CountableTimeInterval
// ticks(...) -----------------------------------------------------------------
const timeInterval = timeHour.every(5);
ticksDates = localTimeScaleNumber.ticks();
ticksDates = localTimeScaleNumber.ticks(50);
if (timeInterval !== null) {
ticksDates = localTimeScaleNumString.ticks(timeInterval);
}
// tickFormat(...) -----------------------------------------------------------------
tickFormatDateFn = localTimeScaleNumber.tickFormat();
tickFormatDateFn = localTimeScaleNumber.tickFormat(50, '%I %p');
if (timeInterval !== null) {
tickFormatDateFn = localTimeScaleNumber.tickFormat(timeInterval, '%I %p');
}
// (...) value mapping from domain to output -----------------------------------
outputNumber = localTimeScaleNumber(new Date(2016, 6, 4));
outputString = localTimeScaleString(new Date(2016, 6, 4));
outputString = localTimeScaleNumString(new Date(2016, 6, 4));
// copy(...) -----------------------------------------------------------------
const copiedTimeScale: d3Scale.ScaleTime<number, string> = localTimeScaleNumString.copy();
// -------------------------------------------------------------------------------
// Sequential Scale Factory
// -------------------------------------------------------------------------------
// scaleSequential() -----------------------------------------------------------------
let sequentialScaleColorString: d3Scale.ScaleSequential<string>;
sequentialScaleColorString = d3Scale.scaleSequential<string>(d3Scale.interpolateRainbow);
sequentialScaleColorString = d3Scale.scaleSequential(d3Scale.interpolateCool); // inferred Output type string
// ScaleSequential Interface ========================================================
// domain(...) -----------------------------------------------------------------
sequentialScaleColorString = sequentialScaleColorString.domain([0, 1]);
sequentialScaleColorString = sequentialScaleColorString.domain([new NumCoercible(0), new NumCoercible(100)]);
const domainSequential: [number, number] = sequentialScaleColorString.domain();
// clamp(...) -----------------------------------------------------------------
sequentialScaleColorString = sequentialScaleColorString.clamp(true);
clampFlag = sequentialScaleColorString.clamp();
// interpolate(...) -----------------------------------------------------------------
sequentialScaleColorString = sequentialScaleColorString.interpolator(d3Scale.interpolateInferno);
let sequentialInterpolator: (t: number) => string;
sequentialInterpolator = sequentialScaleColorString.interpolator();
// (...) value mapping from domain to output -----------------------------------
outputString = sequentialScaleColorString(10);
// copy(...) -----------------------------------------------------------------
const copiedSequentialScale: d3Scale.ScaleSequential<string> = sequentialScaleColorString.copy();
// -------------------------------------------------------------------------------
// Color Interpolators for Sequential Scale Factory
// -------------------------------------------------------------------------------
let colorInterpolator: ((t: number) => string);
colorInterpolator = d3Scale.interpolateViridis;
colorInterpolator = d3Scale.interpolateMagma;
colorInterpolator = d3Scale.interpolateInferno;
colorInterpolator = d3Scale.interpolatePlasma;
colorInterpolator = d3Scale.interpolateRainbow;
colorInterpolator = d3Scale.interpolateWarm;
colorInterpolator = d3Scale.interpolateCool;
colorInterpolator = d3Scale.interpolateCubehelixDefault;
// -------------------------------------------------------------------------------
// Quantize Scale Factory
// -------------------------------------------------------------------------------
// scaleQuantize() -----------------------------------------------------------------
let quantizeScaleNumber: d3Scale.ScaleQuantize<number>;
let quantizeScaleString: d3Scale.ScaleQuantize<string>;
quantizeScaleNumber = d3Scale.scaleQuantize();
quantizeScaleString = d3Scale.scaleQuantize<string>();
// ScaleQuantize Interface ========================================================
// domain(...) -----------------------------------------------------------------
quantizeScaleNumber = quantizeScaleNumber.domain([0, 1]);
quantizeScaleNumber = quantizeScaleNumber.domain([new NumCoercible(0), new NumCoercible(100)]);
const domainQuantize: [number, number] = quantizeScaleNumber.domain();
// range(...) -----------------------------------------------------------------
quantizeScaleNumber = quantizeScaleNumber.range(rangeNumbers);
rangeNumbers = quantizeScaleNumber.range();
quantizeScaleString = quantizeScaleString.range(['steelblue', 'brown']);
rangeStrings = quantizeScaleString.range();
// invertExtent(...) -----------------------------------------------------------------
numExtent = quantizeScaleNumber.invertExtent(500);
numExtent = quantizeScaleString.invertExtent('steelblue');
// nice(...) -----------------------------------------------------------------------
// chainable
quantizeScaleNumber = quantizeScaleNumber.nice();
quantizeScaleNumber = quantizeScaleNumber.nice(5);
// ticks(...) -----------------------------------------------------------------
ticksNumbers = quantizeScaleNumber.ticks();
ticksNumbers = quantizeScaleNumber.ticks(5);
// tickFormat(...) -----------------------------------------------------------------
tickFormatNumberFn = quantizeScaleNumber.tickFormat();
tickFormatNumberFn = quantizeScaleNumber.tickFormat(5);
tickFormatNumberFn = quantizeScaleNumber.tickFormat(5, '+%');
// (...) value mapping from domain to output -----------------------------------
outputNumber = quantizeScaleNumber(0.51);
// copy(...) -----------------------------------------------------------------
const copiedQuantizeScale: d3Scale.ScaleQuantize<number> = quantizeScaleNumber.copy();
// -------------------------------------------------------------------------------
// Quantile Scale Factory
// -------------------------------------------------------------------------------
// scaleQuantile() -----------------------------------------------------------------
let quantileScaleNumber: d3Scale.ScaleQuantile<number>;
let quantileScaleString: d3Scale.ScaleQuantile<string>;
quantileScaleNumber = d3Scale.scaleQuantile();
quantileScaleString = d3Scale.scaleQuantile<string>();
// ScaleQuantile Interface ========================================================
// domain(...) -----------------------------------------------------------------
quantileScaleNumber = quantileScaleNumber.domain(domainNumbers);
domainNumbers = quantileScaleNumber.domain();
quantileScaleString = quantileScaleString.domain(domainNumeric);
// range(...) -----------------------------------------------------------------
quantileScaleNumber = quantileScaleNumber.range([1, 2, 3, 4]);
rangeNumbers = quantileScaleNumber.range();
quantileScaleString = quantileScaleString.range(['q25', 'q50', 'q75']);
rangeStrings = quantileScaleString.range();
// invertExtent(...) -----------------------------------------------------------------
numExtent = quantileScaleNumber.invertExtent(2);
numExtent = quantileScaleString.invertExtent('q50');
// quantile() -----------------------------------------------------------------------
const quantiles: number[] = quantileScaleNumber.quantiles();
// (...) value mapping from domain to output -----------------------------------
outputNumber = quantileScaleNumber(0.51);
// copy(...) -----------------------------------------------------------------
const copiedQuantileScale: d3Scale.ScaleQuantile<number> = quantileScaleNumber.copy();
// -------------------------------------------------------------------------------
// Threshold Scale Factory
// -------------------------------------------------------------------------------
// scaleThreshold() -----------------------------------------------------------------
let thresholdScaleNumberNumber: d3Scale.ScaleThreshold<number, number>;
let thresholdScaleNumberString: d3Scale.ScaleThreshold<number, string>;
thresholdScaleNumberNumber = d3Scale.scaleThreshold();
thresholdScaleNumberString = d3Scale.scaleThreshold<number, string>();
// ScaleThreshold Interface ========================================================
// domain(...) -----------------------------------------------------------------
thresholdScaleNumberNumber = thresholdScaleNumberNumber.domain([0.5]);
domainNumbers = thresholdScaleNumberNumber.domain();
thresholdScaleNumberString = thresholdScaleNumberString.domain([0.2, 0.8]);
// range(...) -----------------------------------------------------------------
thresholdScaleNumberNumber = thresholdScaleNumberNumber.range([100, 200]);
rangeNumbers = thresholdScaleNumberNumber.range();
thresholdScaleNumberString = thresholdScaleNumberString.range(['steelblue', 'seagreen', 'brown']);
rangeStrings = thresholdScaleNumberString.range();
// invertExtent(...) -----------------------------------------------------------------
numOrUndefinedExtent = thresholdScaleNumberNumber.invertExtent(100);
numOrUndefinedExtent = thresholdScaleNumberString.invertExtent('seagreen');
// (...) value mapping from domain to output -----------------------------------
outputNumber = thresholdScaleNumberNumber(0.51);
outputString = thresholdScaleNumberString(0.9);
// copy(...) -----------------------------------------------------------------
const copiedThresholdScale: d3Scale.ScaleThreshold<number, string> = thresholdScaleNumberString.copy();
// -------------------------------------------------------------------------------
// Ordinal Scale Factory
// -------------------------------------------------------------------------------
// scaleOrdinal() -----------------------------------------------------------------
let ordinalScaleStringString: d3Scale.ScaleOrdinal<string, string>;
let ordinalScaleStringNumber: d3Scale.ScaleOrdinal<string, number>;
ordinalScaleStringString = d3Scale.scaleOrdinal<string>();
ordinalScaleStringString = d3Scale.scaleOrdinal<string>(schemePuRd[3]);
ordinalScaleStringNumber = d3Scale.scaleOrdinal<string, number>();
ordinalScaleStringString = d3Scale.scaleOrdinal<string, string>(schemePuRd[3]);
// ScaleOrdinal Interface ========================================================
// domain(...) -----------------------------------------------------------------
ordinalScaleStringString = ordinalScaleStringString.domain(['negative', 'neutral', 'positive']);
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');
outputNumber = ordinalScaleStringNumber('negative');
// copy(...) -----------------------------------------------------------------
const copiedOrdinalScale: d3Scale.ScaleOrdinal<string, number> = ordinalScaleStringNumber.copy();
// -------------------------------------------------------------------------------
// Band Scale Factory
// -------------------------------------------------------------------------------
// scaleBand() -----------------------------------------------------------------
let bandScaleString: d3Scale.ScaleBand<string>;
let bandScaleCoercible: d3Scale.ScaleBand<StringCoercible>;
bandScaleString = d3Scale.scaleBand();
bandScaleCoercible = d3Scale.scaleBand<StringCoercible>();
// ScaleBand Interface ========================================================
// domain(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.domain(['negative', 'neutral', 'positive']);
domainStrings = bandScaleString.domain();
bandScaleCoercible = bandScaleCoercible.domain([new StringCoercible('negative'), new StringCoercible('neutral'), new StringCoercible('positive')]);
// range(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.range([0, 300]);
let rangeExtent: [number, number] = bandScaleString.range();
bandScaleCoercible = bandScaleCoercible.range([0, 300]);
rangeExtent = bandScaleCoercible.range();
// rangeRound(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.rangeRound([0, 300]);
// round(...) -----------------------------------------------------------------
bandScaleCoercible = bandScaleCoercible.round(true);
let roundingFlag: boolean = bandScaleCoercible.round();
// paddingInner(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.paddingInner(0.1);
num = bandScaleString.paddingInner();
// paddingOuter(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.paddingOuter(0.1);
num = bandScaleString.paddingOuter();
// padding(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.padding(0.1);
num = bandScaleString.padding();
// align(...) -----------------------------------------------------------------
bandScaleString = bandScaleString.align(0.5);
num = bandScaleString.align();
// bandwidth(...) -----------------------------------------------------------------
num = bandScaleString.bandwidth();
// step(...) -----------------------------------------------------------------
num = bandScaleString.step();
// (...) value mapping from domain to output -----------------------------------
outputNumberMaybe = bandScaleString('neutral');
outputNumberMaybe = bandScaleCoercible(new StringCoercible('negative'));
// copy(...) -----------------------------------------------------------------
const copiedBandScale: d3Scale.ScaleBand<StringCoercible> = bandScaleCoercible.copy();
// -------------------------------------------------------------------------------
// Point Scale Factory
// -------------------------------------------------------------------------------
// scalePoint() -----------------------------------------------------------------
let pointScaleString: d3Scale.ScalePoint<string>;
let pointScaleCoercible: d3Scale.ScalePoint<StringCoercible>;
pointScaleString = d3Scale.scalePoint();
pointScaleCoercible = d3Scale.scalePoint<StringCoercible>();
// ScalePoint Interface ========================================================
// domain(...) -----------------------------------------------------------------
pointScaleString = pointScaleString.domain(['negative', 'neutral', 'positive']);
domainStrings = pointScaleString.domain();
pointScaleCoercible = pointScaleCoercible.domain([new StringCoercible('negative'), new StringCoercible('neutral'), new StringCoercible('positive')]);
// range(...) -----------------------------------------------------------------
pointScaleString = pointScaleString.range([0, 300]);
rangeExtent = pointScaleString.range();
pointScaleCoercible = pointScaleCoercible.range([0, 300]);
rangeExtent = pointScaleCoercible.range();
// rangeRound(...) -----------------------------------------------------------------
pointScaleString = pointScaleString.rangeRound([0, 300]);
// round(...) -----------------------------------------------------------------
pointScaleCoercible = pointScaleCoercible.round(true);
roundingFlag = pointScaleCoercible.round();
// padding(...) -----------------------------------------------------------------
pointScaleString = pointScaleString.padding(0.1);
num = pointScaleString.padding();
// align(...) -----------------------------------------------------------------
pointScaleString = pointScaleString.align(0.5);
num = pointScaleString.align();
// bandwidth(...) -----------------------------------------------------------------
num = pointScaleString.bandwidth();
// step(...) -----------------------------------------------------------------
num = pointScaleString.step();
// (...) value mapping from domain to output -----------------------------------
outputNumberMaybe = pointScaleString('neutral');
outputNumberMaybe = pointScaleCoercible(new StringCoercible('negative'));
// copy(...) -----------------------------------------------------------------
const copiedPointScale: d3Scale.ScalePoint<StringCoercible> = pointScaleCoercible.copy();
// -------------------------------------------------------------------------------
// Categorical Color Schemas for Ordinal Scales
// -------------------------------------------------------------------------------
let colorStrings: string[];
colorStrings = d3Scale.schemeCategory10;
colorStrings = d3Scale.schemeCategory20;
colorStrings = d3Scale.schemeCategory20b;
colorStrings = d3Scale.schemeCategory20c;
+1840
View File
File diff suppressed because it is too large Load Diff
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"d3-scale": ["d3-scale/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"d3-scale-tests.ts"
]
}
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"unified-signatures": false,
"callable-types": false,
"no-unnecessary-generics": false
}
}