Mathematica 中另一个 Dynamic 中的动态列表选择
以贝利撒留在“操作自定义表格”中提出的解决方案为基础。
考虑以下函数来创建自定义表格表示:
DataSampleXX[数据_、行数_、列列表_、颜色 1_、颜色 2_、颜色 3_] := 网格[ 加入[ {columnsList}, {地图[旋转[文本[#], 90 度] &, 数据[[1,列列表]]]},数据[[2 ;;行数,列列表]]], 背景-> {{{{颜色1,颜色2}},{1 ->颜色3}}}, 分隔线 -> {全部,{1 ->正确,2 ->正确,3 ->正确,0 ->真的}}, 项目尺寸 -> {1->自动,自动}, 对齐->顶部, 框架->真的, 框架样式->厚度[2], 项目样式 -> {自动的, 自动,{{1, 1}, {1,长度[数据]}} ->指令[字体大小 -> 15、黑色、粗体]} ];
以及以下数据:
soData = {{"col1", "col2", "col3", "col4", "col5", "col6", "col7", "col8", "col9", "col10"}, 范围[1, 10], 范围[11, 20], 范围[21, 30], 范围[31, 40]} 和[ {列列表 = {1, 3}, 数据=所以数据, 行数 = 3, 颜色1 = 浅蓝色, 颜色2 = 浅红色, color3 = 浅灰色}, DataSampleXX[数据,行数,列列表,颜色1,颜色2,颜色3]]
我想将以下动态集成到提供
DataSampleXX
函数的columnsList
参数。Manipulate[Sort@Join[Sequence @@ {a, b}], 评估[序列@@ MapThread[{{#1, {}, ""}, #2, 控制类型-> TogglerBar} &, {{a, b}, 分区[规则@@@转置[{范围[10], soData[[1]]}], 5]}]], 控制放置 ->顶部]
- 这应该使我能够动态选择列(VS 中的一系列列)我之前的问题)使用
DataSampleXX
显示,但我还不知道如何合并这两种机制。
Building up on the solution proposed by Belisarius in "Manipulate custom Tabular".
Consider the following Function to create custom Tabular representation :
DataSampleXX[data_, linesNumber_, columnsList_, color1_, color2_, color3_] := Grid[ Join[ {columnsList}, {Map[Rotate[Text[#], 90 Degree] &, data[[1, columnsList]]]}, data[[2 ;; linesNumber, columnsList]]], Background -> {{{{color1, color2}}, {1 -> color3}}}, Dividers -> {All, {1 -> True, 2 -> True, 3 -> True, 0 -> True}}, ItemSize -> {1 -> Automatic, Automatic}, Alignment -> Top, Frame -> True, FrameStyle -> Thickness[2], ItemStyle -> {Automatic, Automatic, {{1, 1}, {1, Length[data]}} -> Directive[FontSize -> 15, Black, Bold]} ];
And the following data :
soData = {{"col1", "col2", "col3", "col4", "col5", "col6", "col7", "col8", "col9", "col10"}, Range[1, 10], Range[11, 20], Range[21, 30], Range[31, 40]} With[ {columnsList = {1, 3}, data = soData, linesNumber = 3, color1 = LightBlue, color2 = LightRed, color3 = LightGray}, DataSampleXX[data, linesNumber, columnsList, color1, color2, color3]]
I would like to integrate the following Dynamic to feed the
columnsList
argument of theDataSampleXX
Function.Manipulate[Sort@Join[Sequence @@ {a, b}], Evaluate[Sequence @@ MapThread[{{#1, {}, ""}, #2, ControlType -> TogglerBar} &, {{a, b}, Partition[Rule @@@ Transpose[{Range[10], soData[[1]]}], 5]}]], ControlPlacement -> Top]
- This should enable me to dynamically choose the columns (VS a range of column in my previous question) to display using
DataSampleXX
but I yet can`t figure out how to merge the 2 mechanisms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想做的事情需要一些技巧。
例如:
和 类似的构造不起作用(并在文档中进行了解释),因为
a[_]
在表达式中不明确,因此很难拥有可变数量的控件。我发现的解决方案是:另一个问题是该构造
本身不允许二维分区,因此我们必须使用两个 Control@ 语法选项( Control@ 和 { ... }),这没有记录。
您可以在下面的代码中找到其他麻烦。
所以:
What you want to do needs a few tricks.
For example:
and similar constructs do not work (and is explained in the docs), because the
a[_]
are not explicit in the expression, so making it difficult to have a variable number of controls. The solution I found is:Other problem is that the construct
does not allow per se a two dimensional partition, so we have to use both Control@ syntax options ( Control@ and { ... }), which is not documented.
Other nuisances you can find in the code below.
So: