여보세요,
이 같은 막대 차트를 스크립팅하려고합니다.
Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables(
Y( :Name( "A" ) ),
Y( :Name( "B" ), Position( 1 ) ),
Y( :Name( "C" ), Position( 1 ) ),
),
Elements(
Bar(
Y( 1 ),
Y( 2 ),
Y( 3 ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
)
도전 과제는 목록에서 Y 변수를 수시로 변경하는 것입니다 (예 : {A, B, D, Test, Bla}).
나는 막대 차트를 목록 "l"에 의존하여 자동으로 조정하도록하고 싶습니다. 예 :
l = {"A", "B", "D", "Test", "Bla"};
...the script should then be looks like this:
Variables(
Y( :Name( "A" ) ),
Y( :Name( "B" ), Position( 1 ) ),
Y( :Name( "D" ), Position( 1 ) ),
Y( :Name( "Test" ), Position( 1 ) ),
Y( :Name( "Bla" ), Position( 1 ) ),
),
Elements(
Bar(
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
)
...
데이터베이스 쿼리 후 목록 l이 변경되고 막대 그래프의 자동 업데이트가 필요합니다.
이미 목록을 열로 변환하고 목록 항목 수를 반복하려고했지만 하나의 막 대형 차트 대신 여러 항목을 생성합니다.
for (i=1, i <= Nitems(l), i++,
show (l[i]);
dt << Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables(
Y( Eval (l[i] ))
),
Elements(
Bar(
Y( i ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
));
문안 인사,
원하는 열을 쌓으면 얼마나 많은가가 중요하지 않습니다. 이 코드는 시작해야합니다.
dt1 = New Table( "Untitled 27", Add Rows( 3 ),
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [6, 5, 4] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [7, 8, 9] ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [3, 2, 1] ) )
);
col_list = dt1 << get column names(string);
dt2 = dt1 << Stack(
columns(col_list),
Source Label Column( "Variable" ),
Stacked Data Column( "Value" )
);
dt2 << Graph Builder(
Size( 526, 415 ),
Show Control Panel( 0 ),
Variables( Y( :Value ), Overlay( :Variable ) ),
Elements( Bar( Y, Legend( 8 ), Bar Style( "Stacked" ) ) ),
SendToReport( Dispatch( {}, "X title", TextEditBox, {Set Wrap( 2 )} ) )
)