Closed PBrockmann closed 6 years ago
The behavior of the interpolator depends on its implementation, and interpolateViridis (and the other Viridis color schemes) have a different implementation from scales. If you want to convert between formats, you should use d3-color to parse the returned string and convert it into the desired format.
Ok. No problem. Thanks M. Bostock
I get heterogeneous format of color, either HTML code such as "#21918c" or rgba code such as "rgb(255, 94, 99)" with different color schemes.
var interpolators = [ 'interpolateViridis', 'interpolateInferno', 'interpolateMagma', 'interpolatePlasma', 'interpolateWarm', 'interpolateCool', 'interpolateRainbow', 'interpolateCubehelixDefault' ]; for(var i=0, size=interpolators.length; i<size; i++) { interpolator = interpolators[i]; s = d3.scaleSequential().domain([0, 100]).interpolator(d3[interpolator]); console.log(s(50)); }
For the last 4 ones, I get rgba output, but 4 first ones give HTML code. Is there a way to force the format ?