当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript d3.quantile函数代码示例

本文整理汇总了TypeScript中d3.quantile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript quantile函数的具体用法?TypeScript quantile怎么用?TypeScript quantile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了quantile函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getQuartiles

 getQuartiles(arr) {
     arr.sort((el1, el2) => el1 - el2);
     let quartiles = [];
     for (let i = 0; i <= 1; i += 0.25) {
         quartiles.push(d3.quantile(arr, i));
     }
     return quartiles;
 }
开发者ID:MaxBoykoII,项目名称:gold-pulse-angular2,代码行数:8,代码来源:quantile.service.ts

示例2: computeDomain

export function computeDomain(values: number[], ignoreOutliers: boolean) {
  // Don't include infinities and NaNs in the domain computation.
  values = values.filter(z => isFinite(z));

  if (values.length === 0) {
    return [-0.1, 1.1];
  }
  let a: number;
  let b: number;
  if (ignoreOutliers) {
    let sorted = _.sortBy(values);
    a = d3.quantile(sorted, 0.05);
    b = d3.quantile(sorted, 0.95);
  } else {
    a = d3.min(values);
    b = d3.max(values);
  }

  let padding: number;
  let span = b - a;
  if (span === 0) {
    // If b===a, we would create an empty range. We instead select the range
    // [0, 2*a] if a > 0, or [-2*a, 0] if a < 0, plus a little bit of
    // extra padding on the top and bottom of the plot.
    padding = Math.abs(a) * 1.1 + 1.1;
  } else {
    padding = span * 0.2;
  }

  let lower: number;
  if (a >= 0 && a < span) {
    // We include the intercept (y = 0) if doing so less than doubles the span
    // of the y-axis. (We actually select a lower bound that's slightly less
    // than 0 so that 0.00 will clearly be written on the lower edge of the
    // chart. The label on the lowest tick is often filtered out.)
    lower = -0.1 * b;
  } else {
    lower = a - padding;
  }


  let domain = [lower, b + padding];
  domain = d3.scaleLinear().domain(domain).nice().domain();
  return domain;
}
开发者ID:astorfi,项目名称:tensorflow,代码行数:45,代码来源:vz-chart-helpers.ts

示例3: expect

		summaries.forEach((summary: ScoreFunctionDataSummary, i: number) => {
			expect(summary.element).to.equal(elements[i]);

			let scores = _.map(scoreFunctions, (scoreFunction) => {
				return scoreFunction.getScore(summary.element);
			});

			scores.sort((a: number, b: number) => {
				if (a < b)
					return -1;
				else
					return 1;
			});


			expect(summary.min).to.equal(_.min(scores));
			expect(summary.max).to.equal(_.max(scores));
			expect(summary.median).to.equal(d3.median(scores));
			expect(summary.firstQuartile).to.equal(d3.quantile(scores, 0.25));
			expect(summary.thirdQuartile).to.equal(d3.quantile(scores, 0.75));
		});
开发者ID:ValueChart,项目名称:WebValueCharts,代码行数:21,代码来源:RendererScoreFunction.test.ts


注:本文中的d3.quantile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。