D3 Array

1.统计(Statistics)

https://github.com/d3/d3/blob/master/API.md#statistics

方法描述
d3.min(array[, accessor])最小值,可以传入一个asscessor,相当于先调用array.map(accessor),再求最小值.相比Math.min,其忽视null
d3.max(array[, accessor])最大值 compute the maximum value in an array.
d3.extent(array[, accessor])最大值和最小值 compute the minimum and maximum value in an array.
d3.sum(array[, accessor])求和 compute the sum of an array of numbers.
d3.mean(array[, accessor])求均值 compute the arithmetic mean of an array of numbers.
d3.median(array[, accessor])求中位数 compute the median of an array of numbers (the 0.5-quantile).
d3.quantile(array, p[, accessor])求分位数 compute a quantile for a sorted array of numbers.
d3.variance(array[, accessor])求方法 compute the variance of an array of numbers.
d3.deviation(array[, accessor])求偏差 compute the standard deviation of an array of numbers.

2.查找(Search)

https://github.com/d3/d3/blob/master/API.md#search

方法描述
d3.scan(array[, comparator])线性扫描,返回最小元素的索引,默认升序,min是返回最小值,而其是返回索引
d3.bisectd3.bisectRight
d3.bisectRight(array, x[, lo[, hi]])返回插入值,在已排序的数组的位置,如果值相等,位置在右边 +1
d3.bisectLeft(array, x[, lo[, hi]])返回插入值,在已排序的数组的位置,如果值相等,位置在左边 +0
d3.bisector(accessor)d3.bisectLeftd3.bisectRight的另一种使用方式
bisector.left(array, x[, lo[, hi]])bisectLeft, with the given comparator.
bisector.right(array, x[, lo[, hi]])bisectRight, with the given comparator.
d3.ascending(a, b)升序
d3.descending(a, b)降序

3.转换(Transformations)

https://github.com/d3/d3/blob/master/API.md#transformations

方法描述
d3.cross(a, b[, reducer])计算数组的笛卡尔积,可以指定的形式
d3.merge(arrays)横向合并两个数组
d3.pairs(array[, reducer])操作相邻的数组,默认是将两个相邻元素组合
d3.permute(array, indexes)根据索引排序
d3.shuffle(array[, start[, stop]])随机重排数组
d3.ticks(start, stop, count)生成countstartstop(inclusive)之间等差为1的 数组,注意count会四舍五入
d3.tickIncrementgenerate representative values from a numeric interval.
d3.tickStep(start, stop, count)返回刻度间的大小
d3.range([start, ]stop[, step])generate a range of numeric values.
d3.transpose(matrix)矩阵(二维数组)转置
d3.zip纵向合并数组

4.Histograms

https://github.com/d3/d3/blob/master/API.md#histograms

方法描述
d3.histogram()创建直方图生成自
histogram(data)计算bins,x0表示bin的下边界,x1表示bin的上边界
histogram.valuespecify a value accessor for each sample.
histogram.domainspecify the interval of observable values.
histogram.thresholdsspecify how values are divided into bins.
d3.thresholdFreedmanDiaconisthe Freedman–Diaconis binning rule.
d3.thresholdScottScott’s normal reference binning rule.
d3.thresholdSturgesSturges’ binning formula.

排序

升序

var arr = [3,2,1];
arr.sort(d3.ascending);
console.log(arr); //[1, 2, 3]

降序

var arr = [1,2,3];
arr.sort(d3.ascending);
console.log(arr); //[3,2,1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值