本文整理汇总了TypeScript中d3-array.range函数的典型用法代码示例。如果您正苦于以下问题:TypeScript range函数的具体用法?TypeScript range怎么用?TypeScript range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了range函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateColorScheme
generateColorScheme(scheme, type, domain) {
if (typeof(scheme) === 'string') {
scheme = colorSets.find(cs => {
return cs.name === scheme;
});
}
let colorScale;
if (type === 'quantile') {
colorScale = scaleQuantile()
.range(scheme.domain)
.domain(domain);
} else if (type === 'ordinal') {
colorScale = scaleOrdinal()
.range(scheme.domain)
.domain(domain);
} else if (type === 'linear') {
// linear schemes must have at least 2 colors
const colorDomain = [...scheme.domain];
if (colorDomain.length === 1) {
colorDomain.push(colorDomain[0]);
this.colorDomain = colorDomain;
}
const points = range(0, 1, 1.0 / colorDomain.length);
colorScale = scaleLinear()
.domain(points)
.range(colorDomain);
}
return colorScale;
}
示例2: Date
mergedArray = d3Array.permute(readonlyMergedArray, [1, 0, 2, 5, 3, 4, 6]);
// Getting an ordered array with object properties
const testObject = {
val: 10,
name: 'Test',
when: new Date(),
more: [10, 30, 40]
};
const x: Array<number | string | Date | number[]> = d3Array.permute(testObject, ['name', 'val', 'when', 'more']);
// range() ---------------------------------------------------------------------
numbersArray = d3Array.range(10);
numbersArray = d3Array.range(1, 10);
numbersArray = d3Array.range(1, 10, 0.5);
// shuffle() -------------------------------------------------------------------
mergedArray = d3Array.shuffle(mergedArray);
mergedArray = d3Array.shuffle(mergedArray, 1);
mergedArray = d3Array.shuffle(mergedArray, 1, 3);
// $ExpectError
mergedArray = d3Array.shuffle(readonlyMergedArray); // fails, shuffle mutates input array in-place
// Test each TypedArray explicitly. Can't use ArrayLike in this case because shuffle is mutable and ArrayLike would include ReadonlyArray
const resultInt8: Int8Array = d3Array.shuffle(new Int8Array(numbersArray));
const resultUint8: Uint8Array = d3Array.shuffle(new Uint8Array(numbersArray));
const resultUint8Clamped: Uint8ClampedArray = d3Array.shuffle(new Uint8ClampedArray(numbersArray));
示例3: range
size = contGen.size();
// smooth(...) -----------------------------------------------------------------
// set with chainability
contGen = contGen.smooth(true);
boolFlag = contGen.smooth();
// thresholds(...) -------------------------------------------------------------
// set with count
contGen = contGen.thresholds(10);
// set with array
const thresholds1 = range(1, 21)
.map(p => Math.pow(2, p));
contGen = contGen.thresholds(thresholds1);
// set with threshold array generator
contGen = contGen.thresholds(thresholdArrayGen); // mock
// set with threshold count generator
contGen = contGen.thresholds(thresholdSturges);
// get
thresholdGenerator = contGen.thresholds();
// Use contour generator =======================================================
示例4: select
import { select, event as d3event } from 'd3-selection'
import { range } from 'd3-array'
import { measureAll } from '../bench'
import { zoom, ZoomTransform } from 'd3-zoom'
import { ViewWindowTransform } from '../../ViewWindowTransform'
// import { transformVector, pSubP, pSubV, Vector, newVector, newPoint, identityTransform } from '../../affine'
import { identityTransform } from '../../affine'
import { betweenBasesAR1 } from '../../viewZoomTransform'
import { updateNode } from '../../MyTransform'
var svg = select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var points = range(2000).map(phyllotaxis(10));
var g = svg.append("g");
// var refNode: SVGGElement = svg.append("g").node() as SVGGElement
const svgNode = svg.node() as SVGSVGElement
g.selectAll("circle")
.data(points)
.enter().append("circle")
.attr("cx", function(d) { return d[0]; })
.attr("cy", function(d) { return d[1]; })
.attr("r", 2.5);
svg.append("rect")
.attr("width", width)