大家好,
我想用預定義的填充模式自動填充指定變量的一些條。 但是,變量的數量正在發生變化,我想在迭代中根據當前保存在數據表中的變量來做到這一點。 在這種情況下,我需要向 Fill Pattern() 提供參數作為索引(這似乎不起作用)或列表中的一些引用,但為此我需要一個填充模式列表。 然後我可以使用列表中的項目索引。 我將不勝感激幫助如何做到這一點。
此致
Graph Builder(
Size( 734, 660 ),
Variables( //that would be good to have it in iteration
X( :Run ),
Y( :Param0 ),
Y( :Param1, Position( 2 ) ),
Y( :Param2, Position( 2 ) ),
Y( :Param3, Position( 2 ) ),
// there is much more of such variables to be displayed
),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 455 ) ) ),
Elements( //that would be good to have it in iteration
Position( 1, 2 ),
Bar(
X,
Y( 3 ),
Y( 5 ),
Y( 6 ),
Y( 7 ),
Legend( 454 ),
Bar Style( "Stacked" )
)
),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
455,
Properties( 0, {Line Color( 25 )}, Item ID( "Param0", 1 ) )
), Legend Model(
454,
//that would be good to have it in iteration
Properties(
0,
{Fill Pattern( "left slant light" )},
Item ID( "Mittelwert(Param1)", 1 )
),
Properties(
2,
{Fill Pattern( "right slant light" )},
Item ID( "Mittelwert(Param2)", 1 )
),
Properties(
3,
{Fill Pattern( "grid heavy" )},
Item ID( "Mittelwert(Param3)", 1 )
),
// there is much more of such properties
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{455, [0], 454, [10, -1, 1, 11]}
), Position(
{0, 10, -1, 1, 11}
)}
)
)
);
編輯:
我開始通過使用可以傳遞數據的表達式來解決上述問題。
我想在“for-loop”中設置條形圖圖例的屬性,並插入到 for-loop 之前定義的 legend_model_expr 中。 然後我會在 Graph Builder 中的適當位置替換該表達式。 在這種情況下,出現了兩個問題。 首先,如果兩個“insert into”命令都被註釋掉了,就會出現錯誤:
名稱未解析:訪問或評估屬性時的屬性。 我使用正確嗎? 其次,如果我取消註釋“插入”(甚至其中一個),則會顯示另一個錯誤:訪問或評估 For 時參數過多。
我將不勝感激提示我錯過了什麼。 此致。
//pattern list
fill_patterns_shuffled = {"left slant light", "horizontal light", "right slant light", "vertical light"};
//list of parameters, it can change depending on data available
list2 = {"Param1", "Param2", "Param3"};
legend_model_expr = Expr( Legend Model (53) );
For( c = 1, c <= N Items( list2 ), c++,
y_expr3 = Eval(Parse( "Properties( " || char(c-1) || ", {Fill Pattern( \!"" || fill_patterns_shuffled[ c ] || "\!") }, Item ID( \!"Mittelwert(" || char(list2[ c ]) || ")\!", 1 ) ),"
),
),
//write(y_expr3);
//Insert Into( y_expr3, 1 );
//Insert Into( legend_model_expr, Name Expr( y_expr3) );
);編輯:
好的,通過使用 Eval JMP 查找實際上不存在的“Properties”函數,所以可能這就是發生錯誤的原因。 然而,第二個錯誤仍然存在。
好的,我讓它工作了。 下面我粘貼了正確的代碼。 此致
//legend
legend_model_expr = Expr( Legend Model (26) );
For( c = 1, c <= N Items( list2 ), c++,
y_expr3 = substitute(expr( Properties( c1, {Fill Pattern( fill ) }, Item ID( "Mittelwert(" || name || ")" , 1 ), ), ), expr(c1), c, expr(fill), char(fill_patterns_shuffled[c]), expr(name), list2[c]);
//show(y_expr3);
Insert Into( y_expr3, "");
Insert Into( legend_model_expr, Name Expr( y_expr3) );
);