本文整理汇总了TypeScript中chroma-js.scale函数的典型用法代码示例。如果您正苦于以下问题:TypeScript scale函数的具体用法?TypeScript scale怎么用?TypeScript scale使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scale函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: validateLineColors
export const getLineColorsHexes = (
colors: Color[],
numSeries: number
): string[] => {
const validatedColors = validateLineColors(colors, numSeries) // ensures safe defaults
const colorsHexArray = validatedColors.map(color => color.hex)
if (numSeries === 1 || numSeries === 0) {
return [colorsHexArray[0]]
}
if (numSeries === 2) {
return [colorsHexArray[0], colorsHexArray[1]]
}
return chroma
.scale(colorsHexArray)
.mode('lch')
.colors(numSeries)
}
示例2: getScale
getScale (params: Partial<ScaleParameters> = {}) {
const p = createParams(params, this.parameters)
if (p.scale === 'rainbow') {
p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]
} else if (p.scale === 'rwb') {
p.scale = [ 'red', 'white', 'blue' ]
}
if (p.reverse) {
p.domain.reverse()
}
return chroma
.scale(p.scale as any) // TODO
.mode(p.mode)
.domain(p.domain)
.out('num' as any) // TODO
}
示例3: test_scale
function test_scale() {
var f = chroma.scale();
f(0.25);
f(0.5);
f(0.75);
chroma.scale(['yellow', '008ae5']);
chroma.scale(['yellow', 'red', 'black']);
// default domain is [0,1]
chroma.scale(['yellow', '008ae5']);
// set domain to [0,100]
chroma.scale(['yellow', '008ae5']).domain([0, 100]);
// default domain is [0,1]
chroma.scale(['yellow', 'lightgreen', '008ae5'])
.domain([0, 0.25, 1]);
chroma.scale(['yellow', '008ae5']);
chroma.scale(['yellow', 'navy']);
chroma.scale(['yellow', 'navy']).mode('lab');
chroma.scale(['yellow', 'navy']).mode('lab');
chroma.scale(['yellow', 'navy']).mode('hsl');
chroma.scale(['yellow', 'navy']).mode('lch');
chroma.scale('YlGnBu');
chroma.scale('Spectral');
chroma.scale('Spectral').domain([1, 0]);
chroma.brewer.OrRd;
chroma.scale(['yellow', '008ae5']).mode('lch');
chroma.scale(['yellow', '008ae5'])
.mode('lch')
.correctLightness();
// linear interpolation
chroma.scale(['yellow', 'red', 'black']);
// bezier interpolation
chroma.bezier(['yellow', 'red', 'black']);
// convert bezier interpolator into chroma.scale
chroma.bezier(['yellow', 'red', 'black'])
.scale().colors(5);
// use the default helix...
chroma.cubehelix();
// or customize it
chroma.cubehelix()
.start(200)
.rotations(-0.5)
.gamma(0.8)
.lightness([0.3, 0.8]);
chroma.cubehelix()
.start(200)
.rotations(-0.35)
.gamma(0.7)
.lightness([0.3, 0.8])
.scale() // convert to chroma.scale
.correctLightness()
.colors(5);
chroma.scale('RdYlBu');
chroma.scale('RdYlBu').padding(0.15);
chroma.scale('OrRd');
chroma.scale('OrRd').padding([0.2, 0]);
chroma.scale('OrRd').classes(5);
chroma.scale('OrRd').classes(8);
myChroma.cubehelix()
.start(200)
.rotations(-0.35)
.gamma(0.7)
.lightness([0.3, 0.8])
.scale() // convert to chroma.scale
.correctLightness()
.colors(5);
myChroma.scale('RdYlBu');
myChroma.scale('RdYlBu').padding(0.15);
}