pivottable.js 的使用
PivotTable.js 是 JavaScript Pivo 表格 (又称为 Pivot网格,Pivot 图标,交叉表) 库,通过数据可以自定义展示想要的数据,相对还是非常的方便的。
github地址:
https://github.com/nicolaskruchten/pivottable
使用说明:
pivottable使用方式分为两种,一种是为简易形式的pivot()、一种是带图形的pivotUI()。
pivot依赖Jquery、可以自定义rows和cols的选择框、比较适合有固定需求界面的项目。
pivotUI在pivot的基础上新增了依赖JqueryUI、多了系统定义好的rows和cols,比较适合自我展示的项目。
请求示例:
$("#output").pivot(
data,
{
rows: rowList,
cols: columnList,
aggregator: aggregatorName,
rendererOptions: {
table: {
rowTotals: _this.totalStauts.row,
colTotals: _this.totalStauts.column,
local: 'zh',
localList: _this.localList,
tableLocalList: _this.tableLocalList
}
}
}
);
请求参数说明:
参数名 | 类型 | 说明 |
---|---|---|
data | array | 数据 |
rows | array | 横向条件 |
cols | array | 列项条件 |
aggregator | function | 请求方法 |
rendererOptions | object | 表格配置 |
rendererOptions.table | object | 表格配置(可以自定义一些参数在里面,后修改原JS可以达到一些效果,比如我的示例中,我将字段的翻译元素给加入了进去) |
rendererOptions.table.rowTotals | boolean | 横向统计开关 |
rendererOptions.table.rowTotals | boolean | 纵向统计开关 |
aggregator参数说明:
aggregator的使用方法如下:
const type = 'Count'
const aggregatorName= $.pivotUtilities.aggregators[type];
type数据类型:
参数名 | 说明 | 值数量 |
---|---|---|
Count | 计数 | 无需值 |
Count Unique Values | 计算唯一值 | 未知(待使用) |
List Unique Values | 列出唯一值 | 未知(待使用) |
Sum | 和 | 一个值 |
Integer Sum | 整数和 | 未知(待使用) |
Average | 平均 | 未知(待使用) |
Median | 中位数 | 未知(待使用) |
Sample Variance | 样本差异 | 未知(待使用) |
Sample Standard Deviation | 样本标准偏差 | 未知(待使用) |
Minimum | 最低要求 | 未知(待使用) |
Maximum | 最大值 | 未知(待使用) |
First | 第一 | 未知(待使用) |
Last | 持续 | 未知(待使用) |
Sum over Sum | 总和 | 未知(待使用) |
80% Upper Bound | 80%上限 | 未知(待使用) |
80% Lower Bound | 下限80% | 未知(待使用) |
Sum as Fraction of Total | 总和的分数 | 未知(待使用) |
Sum as Fraction of Rows | 行总和 | 未知(待使用) |
Sum as Fraction of Columns | 列总和 | 未知(待使用) |
Count as Fraction of Total | 计为总计的分数 | 未知(待使用) |
Count as Fraction of Rows | 计算为行的分数 | 未知(待使用) |
Count as Fraction of Columns | 计为列的分数 | 未知(待使用) |
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
评论已关闭