你好,
我正在编写一个脚本,该脚本将处理具有各种列的文件,因此我必须修改我在此处找到的示例,该示例根据列数连接 Graph Builder 调用。尽管笨拙,但它似乎确实有效,但我的问题是我随后想将 X 轴更改为对数刻度、更改限制等。我尝试了脚本索引和示例中的几种方法,但似乎都不起作用。
非常感谢在轴设置上指向正确方向的指针,但是如果有人知道如何更好地进行初始绘图部分,那也很好,谢谢!
dt = Current Data Table();
ColNameList = dt << Get Column Names (continuous, string);
//Start with initial graph builder
GraphExpr = "
TestGraph = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables(";
//Add X Entry
GraphExpr = GraphExpr || "
X( :Name( \!"" || ColNameList[1] || "\!") ),";
//Add the first Y entry
GraphExpr = GraphExpr || "
Y( :Name( \!"" || ColNameList[2] || "\!") ),";
//Add the second Y entry
For( i = 3, i <= N items (ColNameList), i++,
GraphExpr = GraphExpr || "
Y( :Name( \!"" || ColNameList[i] || "\!"), Position (1) ),";
);
//Close out Variables section
GraphExpr = GraphExpr || "
),
Elements(
Line( X, Y( 1 )";
//Build out the lines for all columns
For( i = 2, i <= N items (ColNameList), i++,
GraphExpr = GraphExpr || ", Y( " || char(i) || " )"
);
GraphExpr = GraphExpr || ", Legend( 1 )
)
)
)";
eval(parse(GraphExpr));
TestGraph << Show Legend (0);
是否有说明如何为渐变图例设置完成此操作?
我试过
Report( gb)[Legend Box(1)] << Legend Model( ...
但它没有用
嘿吉姆,感谢您对此的快速回应。这很好用。我没有意识到您需要使用 report() 来引用该图形项,我只是想使用 TestGraph[AxisBox(2)] << scale(log)
谢谢,
托德
所有改变轴的消息都在 AxisBox 的脚本索引条目中可用
你想要使用的是
report(TestGraph)[AxisBox(2)] << scale(log);
你好,
这确实是构建 Graph Builder 表达式的相当复杂的方式。 您可能想研究使用“占位符”定义整个 GB 表达式的方法 (gbe = Expr (Graph Builder(...));使用替代函数将占位符替换为列、变量、标签等。 ,然后使用 Eval() 函数生成图形(抱歉,我现在没有时间提供更多详细信息)
对于您的特定问题,如果您将 Graph Builder 表达式分配给一个变量(例如,gb = Graph Builder (...);),您可以使用下面的方法以您需要的任何方式更新轴:
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :age, Size( 23 ) ),
Y( :height, Size( 37 ) ),
Y( :weight, Position( 1 ), Size( 37 ), Side( "Right" ) )
),
Elements( Points( X, Y( 1 ), Legend( 1 ), Jitter( 1 ) ), Points( X, Y( 2 ), Legend( 3 ), Jitter( 1 ) ) )
);
framebox = Report( gb )[framebox( 1 )];
framebox << Y Axis(
Scale ("Log"),
Add Ref Line( 61.25, "Solid", "Medium Dark Green" ),
Show Major Grid( 1 ),
Show Minor Grid( 1 ),
Format( "Fixed Dec", 5, 2 ),
Rotated Labels( "Perpendicular" )
);我希望这有帮助。
最好的,
TS
大家好,
我有类似的问题,关于如何自动化 X 轴,即时间刻度,我希望它自动显示最后一个所需周期的数据。例如(n=7)。
非常感谢您的帮助。
神圣
我的脚本如下:

Hi Pmroz,<BR />Script with JSL, <BR />Thank you,<BR />
// → Data Table( "GSB" )
Local( {obj},
obj = Data Table( "GSB" ) <<
Graph Builder(
Size( 604, 659 ),
Variables(
X(
Transform Column(
"Month Year[Date Measured]",
Ordinal,
Format( "m/y", 23 ),
Formula(
Date DMY(
1,
Month( :Date Measured ),
Year( :Date Measured )
)
)
)
),
Overlay( GSB Validation )
),
Elements(
Bar(
X,
Legend( 11 ),
Bar Style( "Stacked" ),
Summary Statistic( "% of Factor" ),
Label( "Label by Value" )
)
),
Local Data Filter(
Add Filter(
columns(
:"Inferred Value (Yes/No)"n,
Transform Column(
"Month Year[Date Measured]",
Ordinal,
Format( "m/y", 23 ),
Formula(
Date DMY(
1,
Month( :Date Measured ),
Year( :Date Measured )
)
)
)
),
Where( :"Inferred Value (Yes/No)"n == "Yes" ),
Where(
Transform Column(
"Month Year[Date Measured]",
Ordinal,
Format( "m/y", 23 ),
Formula(
Date DMY(
1,
Month( :Date Measured ),
Year( :Date Measured )
)
)
) == {3755376000, 3758054400, 3760473600, 3763152000, 3765744000,
3768422400, 3771014400, 3773692800, 3776371200, 3778963200,
3781641600}
),
Display(
Transform Column(
"Month Year[Date Measured]",
Ordinal,
Format( "m/y", 23 ),
Formula(
Date DMY(
1,
Month( :Date Measured ),
Year( :Date Measured )
)
)
),
N Items( 15 )
)
)
),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( "Monthly GSB Validation (%)" )}
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "%" )} ),
Dispatch( {}, "Where((Inferred Value (Yes", TextBox, {Hide( 1 )} )
)
);
obj << Save Script to Data Table(
"Monthly GSB Validation (%)", <<REPLACE> = 12, y + 1, w / m >= 52, y - 1, y ) ) ||如果( w >= 10, "W", "W0" ) || Char( w ) ) ) ) )、大小( 570, 619 )、变量( X( :"年周[测量日期]"n )、叠加( :最佳产品 ) )、元素(条形图( X, 图例( 2 ) , 条形样式( "Stacked" ), 摘要统计( "% of Factor" ), 标签( "Label by Value" ) ) ), 本地数据过滤器( 添加过滤器( columns( :"年周[测量日期]"n ) , 其中( :"年周[测量日期]"n == {"2023W48", "2023W49", "2023W50", "2023W51", "2023W52", "2024W01", "2024W02", "2024W03", "2024W04 ", "2024W05", "2024W06", "2024W07", "2024W08"} ), Display( :"年周[测量日期]"n, N 项( 15 ), Find( 设置文本( "" ) ) ) ) ), SendToReport( Dispatch( {}, "其中(年周[测量日期] = 2023W48, 2023W49, 2023W50, 2023W51, 2023W52, 2024W01, 2024W02, 2024W03, 2024W04, 2024W05, 2024 W06、2024W07、2024W08)",文本框,{隐藏( 1 )} ) ) );</REPLACE>