當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript d3-array.range函數代碼示例

本文整理匯總了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;
  }
開發者ID:emilkpetkov,項目名稱:ngx-charts,代碼行數:33,代碼來源:color.helper.ts

示例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));
開發者ID:itslenny,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:d3-array-tests.ts

示例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 =======================================================
開發者ID:Dru89,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:d3-contour-tests.ts

示例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)
開發者ID:streamcode9,項目名稱:svg-time-series,代碼行數:31,代碼來源:index.ts


注:本文中的d3-array.range函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。