From 88c95a5c06a4e6a649ef3da7dd6129f77c139c39 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 16 Apr 2020 01:27:15 +0200 Subject: [PATCH] [d3-scale-chromatic] Upgrade to v1.5.0 (#43917) --- .../d3-scale-chromatic-tests.ts | 20 ++++++++++------ types/d3-scale-chromatic/index.d.ts | 23 +++++++++++++++++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts b/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts index 18b26b01d6..7ae37bd5ba 100644 --- a/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts +++ b/types/d3-scale-chromatic/d3-scale-chromatic-tests.ts @@ -12,7 +12,7 @@ import * as d3ScaleChromatic from 'd3-scale-chromatic'; // Preparatory Steps // ----------------------------------------------------------------------- -let colorInterpolator: ((t: number) => string); +let colorInterpolator: (t: number) => string; let simpleScheme: ReadonlyArray; let nestedScheme: ReadonlyArray>; @@ -29,6 +29,7 @@ simpleScheme = d3ScaleChromatic.schemePastel2; simpleScheme = d3ScaleChromatic.schemeSet1; simpleScheme = d3ScaleChromatic.schemeSet2; simpleScheme = d3ScaleChromatic.schemeSet3; +simpleScheme = d3ScaleChromatic.schemeTableau10; const category10: string = d3ScaleChromatic.schemeCategory10[0]; // #1f77b4 const accent: string = d3ScaleChromatic.schemeAccent[0]; // #7fc97f @@ -39,6 +40,7 @@ const pastel2: string = d3ScaleChromatic.schemePastel2[0]; // #b3e2cd const set1: string = d3ScaleChromatic.schemeSet1[0]; // #e41a1c const set2: string = d3ScaleChromatic.schemeSet2[0]; // #66c2a5 const set3: string = d3ScaleChromatic.schemeSet3[0]; // #8dd3c7 +const tableau10: string = d3ScaleChromatic.schemeTableau10[0]; // #4e79a7 // ----------------------------------------------------------------------- // Diverging @@ -120,24 +122,28 @@ const schemeReds: string = d3ScaleChromatic.schemeReds[3][0]; // #fee0d2 // Sequential(Multi-Hue) // ----------------------------------------------------------------------- +colorInterpolator = d3ScaleChromatic.interpolateTurbo; colorInterpolator = d3ScaleChromatic.interpolateViridis; -colorInterpolator = d3ScaleChromatic.interpolateMagma; colorInterpolator = d3ScaleChromatic.interpolateInferno; +colorInterpolator = d3ScaleChromatic.interpolateMagma; colorInterpolator = d3ScaleChromatic.interpolatePlasma; -colorInterpolator = d3ScaleChromatic.interpolateRainbow; -colorInterpolator = d3ScaleChromatic.interpolateSinebow; +colorInterpolator = d3ScaleChromatic.interpolateCividis; colorInterpolator = d3ScaleChromatic.interpolateWarm; colorInterpolator = d3ScaleChromatic.interpolateCool; +colorInterpolator = d3ScaleChromatic.interpolateRainbow; +colorInterpolator = d3ScaleChromatic.interpolateSinebow; colorInterpolator = d3ScaleChromatic.interpolateCubehelixDefault; +const Turbo: string = d3ScaleChromatic.interpolateTurbo(0.7); const Viridis: string = d3ScaleChromatic.interpolateViridis(0.7); -const Magma: string = d3ScaleChromatic.interpolateMagma(0.7); const Inferno: string = d3ScaleChromatic.interpolateInferno(0.7); +const Magma: string = d3ScaleChromatic.interpolateMagma(0.7); const Plasma: string = d3ScaleChromatic.interpolatePlasma(0.7); -const Rainbow: string = d3ScaleChromatic.interpolateRainbow(0.7); -const Sinebow: string = d3ScaleChromatic.interpolateSinebow(0.7); +const Cividis: string = d3ScaleChromatic.interpolateCividis(0.7); const Warm: string = d3ScaleChromatic.interpolateWarm(0.7); const Cool: string = d3ScaleChromatic.interpolateCool(0.7); +const Rainbow: string = d3ScaleChromatic.interpolateRainbow(0.7); +const Sinebow: string = d3ScaleChromatic.interpolateSinebow(0.7); const CubehelixDefault: string = d3ScaleChromatic.interpolateCubehelixDefault(0.7); colorInterpolator = d3ScaleChromatic.interpolateBuGn; diff --git a/types/d3-scale-chromatic/index.d.ts b/types/d3-scale-chromatic/index.d.ts index 5b08147a8f..28faf6990f 100644 --- a/types/d3-scale-chromatic/index.d.ts +++ b/types/d3-scale-chromatic/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for D3JS d3-scale-chromatic module 1.3 +// Type definitions for D3JS d3-scale-chromatic module 1.5 // Project: https://github.com/d3/d3-scale-chromatic/, https://d3js.org/d3-scale-chromatic // Definitions by: Hugues Stefanski , // Alex Ford , @@ -6,7 +6,7 @@ // Henrique Machado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.3.2 +// Last module patch version validated against: 1.5.0 // ----------------------------------------------------------------------- // Categorical @@ -47,6 +47,10 @@ export const schemeSet2: ReadonlyArray; * An array of twelve categorical colors represented as RGB hexadecimal strings. */ export const schemeSet3: ReadonlyArray; +/** + * An array of ten categorical colors authored by Tableau as part of Tableau 10 represented as RGB hexadecimal strings. + */ +export const schemeTableau10: ReadonlyArray; // ----------------------------------------------------------------------- // Diverging @@ -268,6 +272,13 @@ export const schemeReds: ReadonlyArray>; // Sequential(Multi-Hue) // ----------------------------------------------------------------------- +/** + * Given a number t in the range [0,1], returns the corresponding color from the “turbo” color scheme by Anton Mikhailov. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateTurbo(t: number): string; + /** * 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. @@ -300,6 +311,14 @@ export function interpolateMagma(t: number): string; */ export function interpolatePlasma(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 interpolateCividis(t: number): string; + /** * Given a number t in the range [0,1], returns the corresponding color from a 180° rotation of Niccoli’s perceptual rainbow, represented as an RGB string. *