我在javascript中有一个数据透视数组,用于将数据显示为产品矩阵,并使用年份来显示每年的销售额,这里是sqlfiddle演示
https://jsfiddle.net/doLwha7t/
所以我更改了数据,例如季度和月份的加法,所以我想在小计和总计的三个层次上打破。下面是更新的示例数据
更新后的阵列
Product year Quarter Month Sales
Product 1 2009 Q1 JAN 1212
Product 2 2009 Q1 JAN 522
Product 1 2010 Q2 FEB 1337
Product 2 2011 Q2 FEB 711
Product 2 2012 Q3 MAR 2245
Product 3 2012 Q3 MAR 1000
透视JS代码的预期输出
图片
我想用 Updated Array 更改小提琴代码,以显示 image
之类的输出要在小提琴中使用的数组
var arr = [
//["Product", "Year","Quarter","Month", "Sale"],
["Product 1", "2009","Q1","JAN", "1212"],
["Product 2", "2009","Q1","JAN", "522"],
["Product 1", "2010","Q2","JAN","1337"],
["Product 2", "2011","Q2","JAN", "711"],
["Product 2", "2012","Q3","JAN", "2245"],
["Product 3", "2012","Q3","JAN", "1000"]
];