PivotTable.js - 总和聚合器不显示零
PivotTable.js - sum aggregator does not show zeros
我正在使用 PivotTable.js 为报告透视一些数据。在报告中,我需要显示总和为零的行,并希望在总计列中显示该零。当使用 aggregatorTemplates.sum 时,零的总和似乎是一个黑色单元格。我想知道有没有办法渲染零?
我正在做的一个简化示例是
var sum = $.pivotUtilities.aggregatorTemplates.sum;
var numberFormat = $.pivotUtilities.numberFormat;
var intFormat = numberFormat({digitsAfterDecimal: 0});
$("#output").pivot(
[
{color: "green", shape: "null", value: 0},
{color: "blue", shape: "circle", value: 1},
{color: "red", shape: "triangle", value: 2},
{color: "blue", shape: "circle", value: 3},
{color: "red", shape: "triangle", value: 4}
],
{
rows: ["color"],
cols: ["shape"],
aggregator: sum(intFormat)(["value"])
}
);
这是来自 https://pivottable.js.org/examples/simple_agg.html, modified to illustrate the issue I'm facing. This is also available in a fiddle https://jsfiddle.net/rgs258/dky0hh1y/ 的示例。
作为次要问题,我想知道是否有办法隐藏我的示例中的 'null' 列?
感谢任何解决此问题的帮助或建议。
(我是图书馆作者 :)
您可以通过创建语言环境文件来覆盖内置数字格式(隐藏零):https://github.com/nicolaskruchten/pivottable/wiki/Localization
您可以使用 filter
或 exclusions
参数隐藏空列:https://github.com/nicolaskruchten/pivottable/wiki/Parameters
我正在使用 PivotTable.js 为报告透视一些数据。在报告中,我需要显示总和为零的行,并希望在总计列中显示该零。当使用 aggregatorTemplates.sum 时,零的总和似乎是一个黑色单元格。我想知道有没有办法渲染零?
我正在做的一个简化示例是
var sum = $.pivotUtilities.aggregatorTemplates.sum;
var numberFormat = $.pivotUtilities.numberFormat;
var intFormat = numberFormat({digitsAfterDecimal: 0});
$("#output").pivot(
[
{color: "green", shape: "null", value: 0},
{color: "blue", shape: "circle", value: 1},
{color: "red", shape: "triangle", value: 2},
{color: "blue", shape: "circle", value: 3},
{color: "red", shape: "triangle", value: 4}
],
{
rows: ["color"],
cols: ["shape"],
aggregator: sum(intFormat)(["value"])
}
);
这是来自 https://pivottable.js.org/examples/simple_agg.html, modified to illustrate the issue I'm facing. This is also available in a fiddle https://jsfiddle.net/rgs258/dky0hh1y/ 的示例。
作为次要问题,我想知道是否有办法隐藏我的示例中的 'null' 列?
感谢任何解决此问题的帮助或建议。
(我是图书馆作者 :)
您可以通过创建语言环境文件来覆盖内置数字格式(隐藏零):https://github.com/nicolaskruchten/pivottable/wiki/Localization
您可以使用 filter
或 exclusions
参数隐藏空列:https://github.com/nicolaskruchten/pivottable/wiki/Parameters