大家好,
不确定这是否可能,但我试试运气。
我想创建(在 jsl 中)一种交叉选项卡框,但使用我自己的值进行自定义。 为了更好地理解我自己:
这是一个表格(图 1),其中包含我要显示的数据:
FIG. 1 - TabulateFIG. 1 - Tabulate如图。 1 - 制表
这很好,但不完全是我想要的。 我想要得到的是类似于我们在调用应急分析时得到的交叉表框,如图2所示:
FIG.2 - contingency tableFIG.2 - contingency table图2-列联表
但我会将与表格中的分析列相对应的平均值放入单元格中,而不是“计数”、“总计%”等。
我在这个设计中喜欢但在表格版本中没有的功能是:
- 可以在一个单元格中显示多个值(并在左上角显示图例)
- 列和行标题上的阴影
- 列标题下缺少“平均”线
我找不到使用选项卡框将表格转换为我想要的内容的方法。 你认为这可能吗?
谢谢
您可以使用 TableBox 和 ColSpan 框相当轻松地重新创建 Tabulate。 请参阅下面的示例。
Names Default To Here( 1 );
New Window( "Col Span Box",
Table Box(
Number Col Box( "CAT_ECH", {1, 2, 3} ),
Col Span Box(
"CAT_MK",
Col Span Box(
"0-100",
Col Span Box("COUT_TOT_ENVIRONNE",Number Col Box( "Mean", {1, 2, 3} )),
Col Span Box("TEMPS",Number Col Box( "Mean", {1, 2, 3} )),
Col Span Box("COUT_CONSOS",Number Col Box( "Mean", {1, 2, 3} ))
),
Col Span Box(
">=100",
Col Span Box("COUT_TOT_ENVIRONNE",Number Col Box( "Mean", {1, 2, 3} )),
Col Span Box("TEMPS",Number Col Box( "Mean", {1, 2, 3} )),
Col Span Box("COUT_CONSOS",Number Col Box( "Mean", {1, 2, 3} ))
)
)
)
);
Col Span Box 方法如下所示:

由于 CrossTabBox DisplayBox 无法使用 JSL 编写脚本,因此您需要使用不同的方法来重新创建类似于 Contingency 平台中使用的方法。
您可以使用我一直致力于使用 LineupBox 创建您自己的自定义表格的概念来完成此操作。 此方法使用自定义函数来创建每个单元格,以避免大量代码重复。 详情请参阅我的评论。
//helper function to create cells in the lineupBOx "table"
getCell = Function( {values, altShading, justify = "left"},
{Default Local},
// Create a lineup box to add each of the values to
lb = Lineup Box( N Col( 1 ), SPacing( 0 ) ); // 1 column and no spacing
// loop through and add each value
For( i = 1, i <= N Items( values ), i++,
// if justify is left, put the spacer box on the right, otherwise, put it on the left
If( justify == "left",
// borderBox to give values some spacing (and for shading)
b = Border Box( Right( 5 ), Left( 5 ), top( 1 ), bottom( 1 ),
H List Box(
//Text box with current value
Text Box( values[i] ),
// Spacing to fill the cell shading all the way to the right (will grow horizontally, but not vertially)
Spacer Box( <<SET max="" size="">=100", "", "", ""}, 0 ),
getCell( {"Total", "", "", ""}, 0 ),
//Row 2
getCell( {"0-250", "", "", ""}, 0 ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
//Row 3
getCell( {"250-3000", "", "", ""}, 0 ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
//Row 4
getCell( {">=3000", "", "", ""}, 0 ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
getCell( {"13", "30.95", "43.33", "68.42"}, 1, "Right" ),
//Row 5
getCell( {"Total", ""}, 0 ),
getCell( {"13", "30.95"}, 1, "Right" ),
getCell( {"13", "30.95"}, 1, "Right" ),
getCell( {"13", "30.95"}, 1, "Right" )
)
)
)
)
)
);</SET>
使用此方法生成的窗口如下所示:
